Skip to content

Commit be04e62

Browse files
TASK AS/AJ Update snapshot tests
- Refactor openExpanders into a common function - Remove 'How to get vaccine' from the list of expanders
1 parent 022ecad commit be04e62

File tree

3 files changed

+14
-20
lines changed

3 files changed

+14
-20
lines changed

e2e/helpers.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,13 @@ export const pathForCustomScreenshots = (testFileName: string, screenshotFileNam
5555

5656
return path;
5757
};
58+
59+
export const openExpanders = async (page: Page) => {
60+
const expanderTitles = ["What this vaccine is for", "Who should have this vaccine"];
61+
62+
for (const title of expanderTitles) {
63+
await page.getByText(title).click();
64+
}
65+
66+
await page.mouse.click(0, 0);
67+
};

e2e/snapshot/app.snapshot.spec.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Page, expect, test } from "@playwright/test";
2-
import { pathForCustomScreenshots } from "@project/e2e/helpers";
2+
import { openExpanders, pathForCustomScreenshots } from "@project/e2e/helpers";
33
import { ACCESSIBILITY_STATEMENT_ROUTE } from "@src/app/our-policies/accessibility/constants";
44
import { COOKIES_POLICY_ROUTE } from "@src/app/our-policies/cookies-policy/constants";
55

@@ -16,13 +16,7 @@ const testPageSnapshot = async (
1616
await page.goto(pageRoute);
1717

1818
if ([RSV_PAGE_URL, RSV_PREGNANCY_PAGE_URL].includes(pageRoute)) {
19-
if (pageRoute === RSV_PAGE_URL) {
20-
await page.getByText("How to get the vaccine").click();
21-
}
22-
await page.getByText("Who should have this vaccine").click();
23-
await page.getByText("What this vaccine is for").click();
24-
25-
await page.mouse.click(0, 0);
19+
await openExpanders(page);
2620
}
2721

2822
await page.screenshot({

e2e/snapshot/eligibility.snapshot.spec.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,8 @@
1-
import { Page, expect, test } from "@playwright/test";
1+
import { expect, test } from "@playwright/test";
22
import { RSV_PAGE_URL } from "@project/e2e/constants";
3-
import { pathForCustomScreenshots } from "@project/e2e/helpers";
3+
import { openExpanders, pathForCustomScreenshots } from "@project/e2e/helpers";
44
import users from "@test-data/test-users.json" with { type: "json" };
55

6-
const openExpanders = async (page: Page) => {
7-
const expanderTitles = ["What this vaccine is for", "Who should have this vaccine", "How to get the vaccine"];
8-
9-
for (const title of expanderTitles) {
10-
await page.getByText(title).click();
11-
}
12-
13-
await page.mouse.click(0, 0);
14-
};
15-
166
test.describe("Snapshot Testing - Eligibility", () => {
177
for (const key of Object.keys(users)) {
188
test.describe(key, () => {

0 commit comments

Comments
 (0)