Skip to content

Commit d13268c

Browse files
committed
fix: add redirecting to field report listing page in playwright tests
1 parent d0501e6 commit d13268c

File tree

10 files changed

+21
-14372
lines changed

10 files changed

+21
-14372
lines changed

.github/workflows/playwright.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Playwright
22

33
env:
44
PLAYWRIGHT_APP_BASE_URL: ${{ vars.PLAYWRIGHT_APP_BASE_URL }}
5-
PLAYWRIGHT_USER_NAME: ${{ secrets.PLAYWRIGHT_USER_NAME }}
5+
PLAYWRIGHT_USER_EMAIL: ${{ secrets.PLAYWRIGHT_USER_EMAIL }}
66
PLAYWRIGHT_USER_PASSWORD: ${{ secrets.PLAYWRIGHT_USER_PASSWORD }}
77

88
on:

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"storybook": "pnpm -F go-ui-storybook storybook",
2121
"build-storybook": "pnpm -F go-ui-storybook build-storybook",
2222
"chromatic": "pnpm -F go-ui-storybook chromatic",
23-
"test:e2e": "pnpm -F e2e-tests playwright test"
23+
"test:e2e": "pnpm -F e2e-tests test"
2424
},
2525
"engines": {
2626
"node": "20",
@@ -30,6 +30,10 @@
3030
"@changesets/cli": "^2.27.10",
3131
"knip": "^5.36.3"
3232
},
33+
"engines": {
34+
"node": "20",
35+
"pnpm": "8.6.0"
36+
},
3337
"packageManager": "[email protected]+sha1.71f9126a20cd3d00fa47c188f956918858180e54",
3438
"pnpm": {
3539
"patchedDependencies": {

packages/e2e-tests/.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Base URL for the application where Playwright will run tests
22
PLAYWRIGHT_APP_BASE_URL=
33
# User name of the test user for Playwright
4-
PLAYWRIGHT_USER_NAME=
4+
PLAYWRIGHT_USER_EMAIL=
55
# Password of the test user for Playwright
66
PLAYWRIGHT_USER_PASSWORD=

packages/e2e-tests/playwright.config.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import 'dotenv/config';
88
require('dotenv').config();
99

1010
/**
11-
* See https://playwright.dev/docs/test-configuration.
11+
* See https://playwright.dev/docs/test-configuration
1212
*/
1313
export default defineConfig({
1414
testDir: './tests',
@@ -22,7 +22,7 @@ export default defineConfig({
2222
workers: process.env.CI ? 1 : undefined,
2323
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
2424
reporter: 'html',
25-
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
25+
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions */
2626
use: {
2727
/* Base URL to use in actions like `await page.goto('/')`. */
2828
baseURL: process.env.PLAYWRIGHT_APP_BASE_URL,
@@ -93,11 +93,4 @@ export default defineConfig({
9393
dependencies: ['setup'],
9494
},
9595
],
96-
97-
/* Run your local dev server before starting the tests */
98-
// webServer: {
99-
// command: 'npm run start',
100-
// url: 'http://127.0.0.1:3000',
101-
// reuseExistingServer: !process.env.CI,
102-
// },
10396
});

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ const authFile = 'playwright/.auth/user.json';
44

55
setup('authenticate', async ({ page }) => {
66
if (
7-
process.env.PLAYWRIGHT_USER_NAME &&
7+
process.env.PLAYWRIGHT_USER_EMAIL &&
88
process.env.PLAYWRIGHT_USER_PASSWORD
99
) {
1010
await login(
1111
page,
12-
process.env.PLAYWRIGHT_USER_NAME,
12+
process.env.PLAYWRIGHT_USER_EMAIL,
1313
process.env.PLAYWRIGHT_USER_PASSWORD,
1414
);
1515
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,8 @@ test.describe('Field Report', () => {
265265
.filter({ hasText: visibiltyOptTwo })
266266
.click();
267267
await page.getByRole('button', { name: 'Submit' }).click();
268+
// Wait for redirection to field reports listing page
269+
await page.waitForURL(/\/field-reports\/\d+/);
268270
await expect(page.locator('h1')).toContainText(
269271
`${newtitle} - ${title}`,
270272
);

packages/e2e-tests/tests/epidemic-field-report/epidemic-field-report.spec.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,8 @@ test.describe('Field report flow', async () => {
252252
.filter({ hasText: visibiltyOptTwo })
253253
.click();
254254
await page.getByRole('button', { name: 'Submit' }).click();
255-
await expect(page.locator('body')).toContainText(
256-
'Field report updated, redirecting...',
257-
);
255+
// Wait for redirection to field reports listing page
256+
await page.waitForURL(/\/field-reports\/\d+/);
258257
// Title Assertion
259258
await expect(page.locator('h1')).toContainText(
260259
`${newtitle} - ${title}`,

packages/e2e-tests/tests/field-report/fieldReport.spec.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,8 @@ test.describe('Field Report', () => {
266266
.filter({ hasText: visibiltyOptTwo })
267267
.click();
268268
await page.getByRole('button', { name: 'Submit' }).click();
269-
await expect(page.locator('body')).toContainText(
270-
'Field report updated, redirecting...',
271-
);
269+
// Wait for redirection to field reports listing page
270+
await page.waitForURL(/\/field-reports\/\d+/);
272271
// Title Assertion
273272
await expect(page.locator('h1')).toContainText(
274273
`${newtitle} - ${title}`,

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { login } from '#utils/auth';
33
test('should login', async ({ page }) => {
44
await login(
55
page,
6-
process.env.PLAYWRIGHT_USER_NAME,
6+
process.env.PLAYWRIGHT_USER_EMAIL,
77
process.env.PLAYWRIGHT_USER_PASSWORD,
88
);
99
await page.waitForURL('/');
@@ -15,13 +15,12 @@ test('should login', async ({ page }) => {
1515
test('should logout', async ({ page }) => {
1616
await login(
1717
page,
18-
process.env.PLAYWRIGHT_USER_NAME,
18+
process.env.PLAYWRIGHT_USER_EMAIL,
1919
process.env.PLAYWRIGHT_USER_PASSWORD,
2020
);
2121
await page.waitForURL('/');
22-
await page
23-
.getByRole('button', { name: process.env.PLAYWRIGHT_USER_NAME })
24-
.click();
22+
const name = process.env.PLAYWRIGHT_USER_EMAIL.match(/^[^@]+(?=@)/);
23+
await page.getByRole('button', { name: name[0] }).click();
2524
await page.getByRole('button', { name: 'Logout' }).click();
2625
await page.getByRole('button', { name: 'Ok' }).click();
2726
await expect(page.getByRole('navigation')).toContainText('Login');

0 commit comments

Comments
 (0)