Skip to content

Commit 750e0f3

Browse files
committed
minor refactor of e2e tests
1 parent 113470b commit 750e0f3

File tree

12 files changed

+424
-425
lines changed

12 files changed

+424
-425
lines changed

.github/workflows/playwright.yml

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ on:
1818
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
1919
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
2020
concurrency:
21-
group: "pages"
21+
group: "playwright"
2222
cancel-in-progress: false
2323

2424
jobs:
2525
typecheck-lint:
2626
name: Typecheck & Lint
27-
runs-on: ubuntu-latest
27+
runs-on: ubuntu-22.04 #TODO upgrade when playwright dependencies are fully supported in latest ubuntu image
2828
defaults:
2929
run:
3030
working-directory: packages/e2e-tests
@@ -52,28 +52,32 @@ jobs:
5252
run:
5353
working-directory: packages/e2e-tests
5454
steps:
55-
- uses: actions/checkout@v4
56-
- uses: actions/setup-node@v4
57-
with:
58-
node-version: lts/*
59-
- name: Install dependencies
60-
run: npm install -g pnpm && pnpm install
61-
- name: Install Playwright Browsers
62-
run: pnpm exec playwright install --with-deps
63-
- name: Run Playwright Tests
64-
run: pnpm exec playwright test
65-
- uses: actions/upload-artifact@v4
66-
id: playwright-report-artifact
67-
if: ${{ !cancelled() }}
68-
with:
69-
name: playwright-report
70-
path: ./packages/e2e-tests/playwright-report/
71-
- uses: actions/upload-pages-artifact@v3
72-
id: playwright-report-github-pages-artifact
73-
if: ${{ !cancelled() }}
74-
with:
75-
name: github-pages
76-
path: ./packages/e2e-tests/playwright-report/
55+
- uses: actions/checkout@v4
56+
- name: Install pnpm
57+
uses: pnpm/action-setup@v4
58+
- name: Install Node.js
59+
uses: actions/setup-node@v4
60+
with:
61+
node-version: 20
62+
cache: 'pnpm'
63+
- name: Install dependencies
64+
run: pnpm install
65+
- name: Install Playwright Browsers
66+
run: pnpm exec playwright install --with-deps
67+
- name: Run Playwright Tests
68+
run: pnpm exec playwright test
69+
- uses: actions/upload-artifact@v4
70+
id: playwright-report-artifact
71+
if: ${{ !cancelled() }}
72+
with:
73+
name: playwright-report
74+
path: ./packages/e2e-tests/playwright-report/
75+
- uses: actions/upload-pages-artifact@v3
76+
id: playwright-report-github-pages-artifact
77+
if: ${{ !cancelled() }}
78+
with:
79+
name: github-pages
80+
path: ./packages/e2e-tests/playwright-report/
7781
deploy:
7882
name: Deploy Playwright Test Report to GitHub Pages
7983
needs: test-e2e

package.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@
3030
"@changesets/cli": "^2.27.10",
3131
"knip": "^5.36.3"
3232
},
33-
"engines": {
34-
"node": "20",
35-
"pnpm": "8.6.0"
36-
},
3733
"packageManager": "[email protected]+sha1.71f9126a20cd3d00fa47c188f956918858180e54",
3834
"pnpm": {
3935
"patchedDependencies": {

packages/e2e-tests/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
{
22
"name": "e2e-tests",
33
"version": "0.0.1",
4+
"description": "End-to-End (E2E) tests using Playwright for IFRC GO",
45
"main": "index.js",
56
"license": "MIT",
7+
"repository": {
8+
"type": "git",
9+
"url": "git+https://github.com/IFRCGo/go-web-app.git",
10+
"directory": "packages/e2e-tests"
11+
},
612
"devDependencies": {
713
"@biomejs/biome": "1.7.3",
814
"@playwright/test": "^1.44.0",

packages/e2e-tests/tests/auth.setup.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { test as setup } from '@playwright/test';
22
import { login } from '#utils/auth';
33
const authFile = 'playwright/.auth/user.json';
44

5+
/** @knipignore */
56
setup('authenticate', async ({ page }) => {
67
if (
78
process.env.PLAYWRIGHT_USER_EMAIL &&

packages/e2e-tests/tests/example.spec.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.

packages/e2e-tests/tests/earlyWarning/earlyWarning.spec.ts renamed to packages/e2e-tests/tests/field-report/earlyWarning.spec.ts

Lines changed: 69 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,74 @@
11
import { expect, test } from '@playwright/test';
22
import { formatNumber } from '#utils/common';
3-
import fixtureData from './earlywarning.json';
3+
import earlyWarning from './fixtures/earlyWarning.json';
4+
45
test.use({ storageState: 'playwright/.auth/user.json' });
5-
test.describe('Field Report', () => {
6-
test('test', async ({ page }) => {
6+
7+
test.describe('Field Report early warning flow', () => {
8+
test('creates an early warning field report and assert the submitted values', async ({
9+
page,
10+
}) => {
711
const {
8-
country,
9-
province,
10-
disasterType,
11-
date,
12-
title,
13-
govRequest,
14-
nationalSocietyRequest,
15-
potentiallyAffectedRc,
16-
potentiallyAffectedGov,
17-
potentiallyAffectedOther,
18-
peopleAtRiskRc,
19-
peopleAtRiskGov,
20-
peopleAtRiskOther,
21-
likelyToBeAffectedRc,
22-
likelyToBeAffectedGov,
23-
likelyToBeAffectedOther,
24-
sourceDetails,
25-
riskAnalysis,
26-
govNumAssisted,
27-
rcrcAssisted,
28-
actionWash,
12+
actionCash,
2913
actionEvacuation,
3014
actionHealth,
31-
actionShelter,
32-
actionCash,
33-
actionNfi,
34-
actionMovement,
35-
actionMonitor,
3615
actionInteragency,
37-
generalSummary,
38-
fedSummary,
39-
rcrcSummary,
40-
informationBulletin,
16+
actionMonitor,
17+
actionMovement,
18+
actionNfi,
4119
actionOther,
42-
interventionOptionOne,
43-
interventionOptionTwo,
44-
interventionOptionThree,
20+
actionShelter,
21+
actionWash,
22+
country,
23+
date,
24+
disasterType,
4525
drefRequested,
4626
emergencyAppeal,
47-
rapidResponse,
4827
emergencyResponse,
28+
fedSummary,
4929
forecastAction,
50-
originatorName,
51-
originatorTitle,
52-
originatorEmail,
53-
originatorPhone,
54-
nationalName,
55-
nationalTitle,
56-
nationalEmail,
57-
nationalPhone,
58-
ifrcName,
59-
ifrcTitle,
30+
generalSummary,
31+
govNumAssisted,
32+
govRequest,
6033
ifrcEmail,
34+
ifrcName,
6135
ifrcPhone,
62-
mediaName,
63-
mediaTitle,
36+
ifrcTitle,
37+
informationBulletin,
38+
interventionOptionOne,
39+
interventionOptionThree,
40+
interventionOptionTwo,
41+
likelyToBeAffectedGov,
42+
likelyToBeAffectedOther,
43+
likelyToBeAffectedRc,
6444
mediaEmail,
45+
mediaName,
6546
mediaPhone,
66-
visibiltyOptOne,
67-
visibiltyOptTwo,
68-
} = fixtureData;
47+
mediaTitle,
48+
nationalEmail,
49+
nationalName,
50+
nationalPhone,
51+
nationalSocietyRequest,
52+
nationalTitle,
53+
originatorEmail,
54+
originatorName,
55+
originatorPhone,
56+
originatorTitle,
57+
peopleAtRiskGov,
58+
peopleAtRiskOther,
59+
peopleAtRiskRc,
60+
potentiallyAffectedGov,
61+
potentiallyAffectedOther,
62+
potentiallyAffectedRc,
63+
province,
64+
rapidResponse,
65+
rcrcAssisted,
66+
rcrcSummary,
67+
riskAnalysis,
68+
sourceDetails,
69+
title,
70+
visibilityOptTwo,
71+
} = earlyWarning;
6972
await page.goto('/');
7073
await page.getByRole('button', { name: 'Create a Report' }).click();
7174
await page.getByRole('link', { name: 'New Field Report' }).click();
@@ -85,7 +88,7 @@ test.describe('Field Report', () => {
8588
);
8689
await page.locator('input[name="start_date"]').fill(date);
8790
await page.getByPlaceholder('Example: Cyclone Cody').fill(title);
88-
const newtitle = await page.inputValue('input[type="text"]');
91+
const newTitle = await page.inputValue('input[type="text"]');
8992
await page
9093
.locator('label')
9194
.filter({ hasText: govRequest })
@@ -262,13 +265,13 @@ test.describe('Field Report', () => {
262265
}
263266
await page
264267
.locator('label')
265-
.filter({ hasText: visibiltyOptTwo })
268+
.filter({ hasText: visibilityOptTwo })
266269
.click();
267270
await page.getByRole('button', { name: 'Submit' }).click();
268271
// Wait for redirection to field reports listing page
269272
await page.waitForURL(/\/field-reports\/\d+/);
270273
await expect(page.locator('h1')).toContainText(
271-
`${newtitle} - ${title}`,
274+
`${newTitle} - ${title}`,
272275
);
273276
// Assertion for Early Warning Type of Field Report
274277
const parentElement = page
@@ -277,7 +280,7 @@ test.describe('Field Report', () => {
277280
.locator('..')
278281
.locator('..')
279282
.locator('..');
280-
await expect(parentElement).toContainText(visibiltyOptTwo);
283+
await expect(parentElement).toContainText(visibilityOptTwo);
281284
const parent = page
282285
.getByText('Forecasted Date of Impact')
283286
.locator('..')
@@ -333,11 +336,11 @@ test.describe('Field Report', () => {
333336
},
334337
];
335338
for (const element of elements) {
336-
const pElement = await page
339+
const pElement = page
337340
.getByText(element.text, { exact: true })
338341
.locator('..');
339342
const cElement = await pElement.nth(0).innerText();
340-
await expect(cElement).toContain(element.expectedText);
343+
expect(cElement).toContain(element.expectedText);
341344
}
342345
// Assertions for Sources for data marked as other
343346
const sourceElement = page.getByText(
@@ -369,7 +372,7 @@ test.describe('Field Report', () => {
369372
.getByText('NS Requests International Assistance', { exact: true })
370373
.locator('..');
371374
await expect(nsRequestElement).toContainText(nationalSocietyRequest);
372-
// Assertions for Information Bulletion Published
375+
// Assertions for Information Bulletin Published
373376
const infoElement = page.getByText('Information Bulletin Published', {
374377
exact: true,
375378
});
@@ -496,7 +499,7 @@ test.describe('Field Report', () => {
496499
const dateValue = page.locator('input[name="start_date"]');
497500
await expect(dateValue).toHaveValue(date);
498501
const titleValue = page.getByPlaceholder('Example: Cyclone Cody');
499-
await expect(titleValue).toHaveValue(`${newtitle} - ${title}`);
502+
await expect(titleValue).toHaveValue(`${newTitle} - ${title}`);
500503
// Government request international assistance
501504
const govReqValue = page
502505
.locator('label')
@@ -533,9 +536,7 @@ test.describe('Field Report', () => {
533536
},
534537
];
535538
for (const field of fields) {
536-
const valueLocator = await page.locator(
537-
`input[name="${field.name}"]`,
538-
);
539+
const valueLocator = page.locator(`input[name="${field.name}"]`);
539540
await expect(valueLocator).toHaveValue(field.value);
540541
}
541542
// Assertions for Source Details Value
@@ -589,11 +590,11 @@ test.describe('Field Report', () => {
589590
.locator('textarea[name="summary"]')
590591
.nth(2);
591592
await expect(rcrcActionsValue).toHaveValue(rcrcSummary);
592-
// Assertions for Information Bulletion Value
593-
const informationBulletionValue = page
593+
// Assertions for Information Bulletin Value
594+
const informationBulletinValue = page
594595
.locator('label')
595596
.filter({ hasText: informationBulletin });
596-
await expect(informationBulletionValue).toBeChecked();
597+
await expect(informationBulletinValue).toBeChecked();
597598
// Assertions for Action Taken by Other Value
598599
const otherActionValue = page.locator(
599600
'textarea[name="actions_others"]',
@@ -610,7 +611,7 @@ test.describe('Field Report', () => {
610611
await expect(drefValue).toBeChecked();
611612
const drefSummaryValue = page.locator('input[name="dref_amount"]');
612613
await expect(drefSummaryValue).toHaveValue(drefRequested);
613-
// Emmergency Appeal
614+
// Emergency Appeal
614615
const emergencyAppealValue = page
615616
.locator('label')
616617
.filter({ hasText: interventionOptionTwo })
@@ -700,7 +701,7 @@ test.describe('Field Report', () => {
700701
// Assertions for Field Report Visibility Value
701702
const frVisibilityValue = page
702703
.locator('label')
703-
.filter({ hasText: visibiltyOptTwo });
704+
.filter({ hasText: visibilityOptTwo });
704705
await expect(frVisibilityValue).toBeChecked();
705706
});
706707
});

0 commit comments

Comments
 (0)