diff --git a/integration-tests/tests/pages/search.page.ts b/integration-tests/tests/pages/search.page.ts index 3ec6e9c040..0a42a7c6e8 100644 --- a/integration-tests/tests/pages/search.page.ts +++ b/integration-tests/tests/pages/search.page.ts @@ -1,6 +1,7 @@ import { Page, expect } from '@playwright/test'; import { getFromLinkTargetAndAssertContent } from '../utils/link-helpers'; import { EditPage } from './edit.page'; +import { ReviewPage } from './review.page'; function makeAccessionVersion({ accession, @@ -120,6 +121,20 @@ export class SearchPage { return new EditPage(this.page); } + async revokeSequence(revocationReason: string = 'Test revocation') { + const revokeButton = this.page.getByRole('button', { name: 'Revoke this sequence' }); + await expect(revokeButton).toBeVisible(); + await revokeButton.click(); + + await expect( + this.page.getByText('Are you sure you want to create a revocation for this sequence?'), + ).toBeVisible(); + await this.page.getByPlaceholder('Enter reason for revocation').fill(revocationReason); + await this.page.getByRole('button', { name: 'Confirm' }).click(); + + return new ReviewPage(this.page); + } + async clickOnSequenceAndGetAccession(rowIndex = 0): Promise { const rows = this.getSequenceRows(); const row = rows.nth(rowIndex); @@ -251,6 +266,26 @@ export class SearchPage { return accessions; } + async waitForAccessionVersionInSearch(expectedAccession: string, expectedVersion: number) { + await expect + .poll( + async () => { + await this.page.reload(); + const accessionVersions = await this.getAccessionVersions(); + return accessionVersions.some( + ({ accession, version }) => + accession === expectedAccession && version === expectedVersion, + ); + }, + { + message: `Did not find accession version ${expectedAccession}.${expectedVersion} in search results`, + timeout: 60000, + intervals: [2000, 5000], + }, + ) + .toBeTruthy(); + } + async expectResultTableCellText(text: string) { await expect(this.page.getByRole('cell', { name: text })).toBeVisible(); } diff --git a/integration-tests/tests/specs/features/multipathogen-submission-flow.spec.ts b/integration-tests/tests/specs/features/multipathogen-submission-flow.spec.ts index 00db7fa1ae..8a4e0f5a4f 100644 --- a/integration-tests/tests/specs/features/multipathogen-submission-flow.spec.ts +++ b/integration-tests/tests/specs/features/multipathogen-submission-flow.spec.ts @@ -35,6 +35,41 @@ test.describe('Multi-pathogen submission flow', () => { await releasedPage.expectResultTableCellText('EV-A71'); }); + test('revoke a sequence', async ({ page, groupId }) => { + test.fail(); + test.setTimeout(120_000); + + void groupId; + const submissionPage = new SingleSequenceSubmissionPage(page); + + await submissionPage.navigateToSubmissionPage('Enterovirus'); + await submissionPage.fillSubmissionForm({ + submissionId: 'id', + collectionCountry: 'Uganda', + collectionDate: '2023-10-15', + authorAffiliations: 'Research Lab, University', + }); + await submissionPage.fillSequenceData({ mySequence: a71Sequence }); + await submissionPage.acceptTerms(); + const reviewPage = await submissionPage.submitSequence(); + + await reviewPage.waitForAllProcessed(); + const releasedPage = await reviewPage.releaseAndGoToReleasedSequences(); + + const accessionVersions = await releasedPage.waitForSequencesInSearch(1); + await releasedPage.expectResultTableCellText('EV-A71'); + const firstAccessionVersion = accessionVersions[0]; + await releasedPage.openPreviewOfAccessionVersion(firstAccessionVersion.accessionVersion); + await releasedPage.revokeSequence('revocation for integration test'); + + await reviewPage.waitForAllProcessed(); + await reviewPage.releaseAndGoToReleasedSequences(); + + await releasedPage.waitForAccessionVersionInSearch(firstAccessionVersion.accession, 2); + await releasedPage.openPreviewOfAccessionVersion(`${firstAccessionVersion.accession}.2`); + await expect(page.getByText(/This is a revocation version/)).toBeVisible(); + }); + test('submit files and revise released version', async ({ page, groupId }) => { test.setTimeout(120_000); @@ -64,7 +99,7 @@ test.describe('Multi-pathogen submission flow', () => { await releasedPage.expectResultTableCellText('EV-D68'); const firstAccessionVersion = accessionVersions[0]; - await releasedPage.openPreviewOfAccessionVersion(firstAccessionVersion.accession); + await releasedPage.openPreviewOfAccessionVersion(firstAccessionVersion.accessionVersion); const editPage = await releasedPage.reviseSequence(); const authorAffiliations = 'integration test affiliation'; @@ -74,24 +109,13 @@ test.describe('Multi-pathogen submission flow', () => { await reviewPage.waitForAllProcessed(); await reviewPage.releaseAndGoToReleasedSequences(); - await expect - .poll( - async () => { - await page.reload(); - const accessionVersions = await releasedPage.getAccessionVersions(); - return accessionVersions.some( - ({ accession, version }) => - accession === firstAccessionVersion.accession && version === 2, - ); - }, - { - message: `Did not find revised accession version ${firstAccessionVersion.accession}.2`, - timeout: 60000, - intervals: [2000, 5000], - }, - ) - .toBeTruthy(); + await releasedPage.waitForAccessionVersionInSearch(firstAccessionVersion.accession, 2); await releasedPage.expectResultTableCellText(authorAffiliations); + await releasedPage.openPreviewOfAccessionVersion(`${firstAccessionVersion.accession}.2`); + const expectedDisplayName = new RegExp( + `^Display Name: Uganda/${firstAccessionVersion.accession}\\.2`, + ); + await expect(page.getByText(expectedDisplayName)).toBeVisible(); }); });