Skip to content

Commit 576384c

Browse files
committed
add e2e assertion
1 parent 3dbac69 commit 576384c

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

frontend/src/components/molecules/PreviewTemplateDetails/PreviewTemplateDetailsLetter.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ export function PreviewTemplateDetailsLetter({
7272
className={styles.container}
7373
target='_blank'
7474
rel='noopener noreferrer'
75+
data-testid='proof-link'
7576
>
7677
<Filename filename={file} />
7778
</Link>

tests/test-team/pages/letter/template-mgmt-preview-letter-page.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ export class TemplateMgmtPreviewLetterPage extends TemplateMgmtPreviewBasePage {
1010

1111
public readonly errorSummary: Locator;
1212
public readonly continueButton: Locator;
13+
public readonly pdfLinks: Locator;
1314

1415
constructor(page: Page) {
1516
super(page);
1617
this.errorSummary = page.locator('[class="nhsuk-error-summary"]');
1718
this.continueButton = page.locator('[id="preview-letter-template-cta"]');
19+
this.pdfLinks = page.locator('[data-testid="proof-link"]');
1820
}
1921

2022
async clickContinueButton() {

tests/test-team/template-mgmt-e2e-tests/template-mgmt-letter-full.e2e.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable sonarjs/no-nested-functions */
12
import { test, expect } from '@playwright/test';
23
import { TemplateMgmtCreateLetterPage } from '../pages/letter/template-mgmt-create-letter-page';
34
import { TemplateStorageHelper } from '../helpers/db/template-storage-helper';
@@ -151,6 +152,15 @@ test.describe.skip('letter complete e2e journey', () => {
151152
await page.reload();
152153

153154
await expect(previewTemplatePage.continueButton).toBeVisible();
155+
156+
const pdfHrefs = await previewTemplatePage.pdfLinks.evaluateAll(
157+
(anchors) => anchors.map((a) => 'href' in a && a.href)
158+
);
159+
160+
expect(pdfHrefs.length).toBeGreaterThan(0);
161+
162+
for (const href of pdfHrefs) expect(href).toContain(templateId);
163+
154164
await previewTemplatePage.clickContinueButton();
155165
}).toPass({ timeout: 60_000 });
156166

0 commit comments

Comments
 (0)