-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: added more e2e tests in playwright
- Loading branch information
1 parent
45e1afb
commit 651c570
Showing
16 changed files
with
507 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
WEBAPP_URL={URL OF THE HOME PAGE} | ||
AUTH_SECRET={PASSWORD FOR ENVIRONMENT} | ||
DOMAIN={DOMAIN FOR COOKIE TO BE ADDED TO (when local: localhost)} |
16 changes: 15 additions & 1 deletion
16
tests/Dfe.EarlyYearsQualification.E2ETests/playwright/package-lock.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
157 changes: 59 additions & 98 deletions
157
tests/Dfe.EarlyYearsQualification.E2ETests/playwright/tests/journey/back-button.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,110 +1,71 @@ | ||
import { test, expect } from '@playwright/test'; | ||
import { | ||
test | ||
} from '@playwright/test'; | ||
|
||
import { | ||
startJourney, | ||
checkUrl, | ||
clickBackButton, | ||
whereWasTheQualificationAwarded, | ||
whenWasQualificationStarted, | ||
whatLevelIsTheQualification, | ||
whatIsTheAwardingOrganisation, | ||
selectQualification, | ||
confirmQualificiation, | ||
processAdditionalRequirement, | ||
confirmAdditonalRequirementsAnswers, | ||
checkDetailsPage | ||
} from '../shared/processLogic'; | ||
|
||
test.describe("A spec used to test the main back button route through the journey", () => { | ||
// Mock details found in Dfe.EarlyYearsQualification.Mock.Content.MockContentfulService. | ||
test("back buttons should all navigate to the appropriate pages in the main journey", async ({ page, context }) => { | ||
await context.addCookies([ | ||
{ name: 'auth-secret', value: process.env.AUTH_SECRET, path: '/', domain: process.env.WEBAPP_URL } | ||
]); | ||
|
||
// home page | ||
await page.goto("/"); | ||
await expect(page.locator("#start-now-button")).toHaveCount(1); | ||
await page.locator("#start-now-button").click(); | ||
|
||
// where-was-the-qualification-awarded page - england selection moves us on | ||
expect(page.url()).toContain("/questions/where-was-the-qualification-awarded"); | ||
await page.locator("#england").click(); | ||
await page.locator("#question-submit").click(); | ||
|
||
// when-was-the-qualification-started page - valid date moves us on | ||
expect(page.url()).toContain("/questions/when-was-the-qualification-started"); | ||
await page.locator("#date-started-month").fill("6"); | ||
await page.locator("#date-started-year").fill("2022"); | ||
await page.locator("#question-submit").click(); | ||
|
||
// what-level-is-the-qualification page - valid level moves us on | ||
expect(page.url()).toContain("/questions/what-level-is-the-qualification"); | ||
await page.locator("#3").click(); | ||
await page.locator("#question-submit").click(); | ||
|
||
// what-is-the-awarding-organisation page - valid awarding organisation moves us on | ||
expect(page.url()).toContain("/questions/what-is-the-awarding-organisation"); | ||
await page.locator("#awarding-organisation-select").selectOption("1"); | ||
await page.locator("#question-submit").click(); | ||
|
||
// qualifications page - click a qualification in the list to move us on | ||
expect(page.url()).toContain("/qualifications"); | ||
await page.locator("a[href=\"/confirm-qualification/EYQ-240\"]").click(); | ||
|
||
// check additional questions first page | ||
expect(page.url()).toContain("/qualifications/check-additional-questions/EYQ-240/1"); | ||
await page.locator("#yes").click(); | ||
await page.locator("#additional-requirement-button").click(); | ||
|
||
// check additional questions second page | ||
expect(page.url()).toContain("/qualifications/check-additional-questions/EYQ-240/2"); | ||
await page.locator("#no").click(); | ||
await page.locator("#additional-requirement-button").click(); | ||
|
||
// confirm answers page | ||
expect(page.url()).toContain("/qualifications/check-additional-questions/EYQ-240/confirm-answers"); | ||
await page.locator("#confirm-answers").click(); | ||
|
||
// qualifications page | ||
expect(page.url()).toContain("/qualifications/qualification-details/EYQ-240"); | ||
|
||
/// Time to go back through the journey! | ||
await page.locator("#back-button").click(); | ||
|
||
// confirm answers page | ||
expect(page.url()).toContain("/qualifications/check-additional-questions/EYQ-240/confirm-answers"); | ||
await page.locator("#back-button").click(); | ||
|
||
// answered additional questions, so back to second additional questions page | ||
expect(page.url()).toContain("/qualifications/check-additional-questions/EYQ-240/2"); | ||
await page.locator("#back-button").click(); | ||
|
||
// answered additional questions, so back to first additional questions page | ||
expect(page.url()).toContain("/qualifications/check-additional-questions/EYQ-240/1"); | ||
await page.locator("#back-button").click(); | ||
|
||
// qualifications page | ||
expect(page.url()).toContain("/qualifications"); | ||
await page.locator("#back-button").click(); | ||
|
||
expect(page.url()).toContain("/questions/what-is-the-awarding-organisation"); | ||
await page.locator("#back-button").click(); | ||
|
||
expect(page.url()).toContain("/questions/what-level-is-the-qualification"); | ||
await page.locator("#back-button").click(); | ||
|
||
expect(page.url()).toContain("/questions/when-was-the-qualification-started"); | ||
await page.locator("#back-button").click(); | ||
|
||
expect(page.url()).toContain("/questions/where-was-the-qualification-awarded"); | ||
await page.locator("#back-button").click(); | ||
|
||
expect(page.url()).toBe(process.env.WEBAPP_URL + "/"); | ||
//Mock details found in Dfe.EarlyYearsQualification.Mock.Content.MockContentfulService. | ||
test.beforeEach(async ({page, context}) => { | ||
await startJourney(page, context); | ||
}); | ||
test("back buttons should all navigate to the appropriate pages in the main journey", async ({page}) => { | ||
|
||
await whereWasTheQualificationAwarded(page, "#england"); | ||
await whenWasQualificationStarted(page, "6", "2022"); | ||
await whatLevelIsTheQualification(page, 3); | ||
await whatIsTheAwardingOrganisation(page, 1); | ||
await selectQualification(page, "EYQ-240"); | ||
await confirmQualificiation(page, "#yes"); | ||
await processAdditionalRequirement(page, "EYQ-240", 1, "#yes"); | ||
await processAdditionalRequirement(page, "EYQ-240", 2, "#no"); | ||
await confirmAdditonalRequirementsAnswers(page, "EYQ-240"); | ||
checkDetailsPage(page, "EYQ-240"); | ||
|
||
await clickBackButton(page); | ||
checkUrl(page, "/qualifications/check-additional-questions/EYQ-240/confirm-answers"); | ||
await clickBackButton(page); | ||
checkUrl(page, "/qualifications/check-additional-questions/EYQ-240/2"); | ||
await clickBackButton(page); | ||
checkUrl(page, "/qualifications/check-additional-questions/EYQ-240/1"); | ||
await clickBackButton(page); | ||
checkUrl(page, "/qualifications"); | ||
await clickBackButton(page); | ||
checkUrl(page, "/questions/what-is-the-awarding-organisation"); | ||
await clickBackButton(page); | ||
checkUrl(page, "/questions/what-level-is-the-qualification"); | ||
await clickBackButton(page); | ||
checkUrl(page, "/questions/when-was-the-qualification-started"); | ||
await clickBackButton(page); | ||
checkUrl(page, "/questions/where-was-the-qualification-awarded"); | ||
await clickBackButton(page); | ||
checkUrl(page, process.env.WEBAPP_URL + "/"); | ||
}); | ||
|
||
test.describe("back buttons should all navigate to the appropriate pages in the main journey", async () => { | ||
test.beforeEach(async ({page, context}) => { | ||
await context.addCookies([ | ||
{ name: 'auth-secret', value: process.env.AUTH_SECRET, path: '/', domain: process.env.WEBAPP_URL } | ||
]); | ||
}); | ||
|
||
test("the back button on the accessibility statement page navigates back to the home page", async ({ page, context }) => { | ||
test("the back button on the accessibility statement page navigates back to the home page", async ({page}) => { | ||
await page.goto("/accessibility-statement"); | ||
await page.locator("#back-button").click(); | ||
expect(page.url()).toBe(process.env.WEBAPP_URL + "/"); | ||
await clickBackButton(page); | ||
checkUrl(page, process.env.WEBAPP_URL + "/"); | ||
}); | ||
|
||
test("the back button on the cookies preference page navigates back to the home page", async ({ page, context }) => { | ||
test("the back button on the cookies preference page navigates back to the home page", async ({page}) => { | ||
await page.goto("/cookies"); | ||
await page.locator("#back-button").click(); | ||
expect(page.url()).toBe(process.env.WEBAPP_URL + "/"); | ||
await clickBackButton(page); | ||
checkUrl(page, process.env.WEBAPP_URL + "/"); | ||
}); | ||
}); | ||
}); |
20 changes: 20 additions & 0 deletions
20
...e.EarlyYearsQualification.E2ETests/playwright/tests/journey/date-missing-redirect.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import {test} from '@playwright/test'; | ||
import {pagesThatRedirectIfDateMissing} from "../shared/urls-to-check"; | ||
import {startJourney, checkUrl} from '../shared/processLogic'; | ||
|
||
test.describe('A spec used to check that if the user skips entering the date of the qual, then they are redirected back to the date selection page', () => { | ||
|
||
test.beforeEach(async ({ | ||
page, | ||
context | ||
}) => { | ||
await startJourney(page, context); | ||
}); | ||
|
||
pagesThatRedirectIfDateMissing.forEach((url) => { | ||
test(`navigating to ${url} should redirect the user to the date selection page`, async ({page}) => { | ||
await page.goto(url); | ||
checkUrl(page, "/questions/when-was-the-qualification-started"); | ||
}) | ||
}); | ||
}); |
Oops, something went wrong.