generated from hmcts/expressjs-template
-
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.
Merge pull request #1574 from hmcts/ADOP-2505-new
ADOP-2505: Improve playwright smoke test
- Loading branch information
Showing
9 changed files
with
222 additions
and
37 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
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
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
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 |
---|---|---|
@@ -1,23 +1,100 @@ | ||
import AxeBuilder from '@axe-core/playwright'; | ||
import { expect, test } from '@playwright/test'; | ||
import { test as base } from '@playwright/test'; | ||
import * as dotenv from 'dotenv'; | ||
|
||
import { urlConfig } from '../utils/urls'; | ||
import { runAccessibilityScan } from '../helpers/accessibilityHelper'; | ||
import { setupUser, teardownUser } from '../hooks/createDeleteUser.hook'; | ||
import App from '../pages/app.page'; | ||
|
||
test.describe('Adoption', () => { | ||
test('should not have any automatically detectable accessibility issues @accessibility', async ({ page }) => { | ||
await page.goto(`${urlConfig.citizenStartUrl}`); | ||
dotenv.config(); | ||
|
||
const accessibilityScanResults = await new AxeBuilder({ page }) | ||
.withTags(['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa', 'wcag22a', 'wcag22aa']) | ||
.analyze(); | ||
const test = base.extend<{ makeAxeBuilder: () => AxeBuilder }>({ | ||
makeAxeBuilder: async ({ page }, use) => { | ||
await use(() => new AxeBuilder({ page })); | ||
}, | ||
}); | ||
|
||
test.describe('smoke test', () => { | ||
let userEmail: string; | ||
let userPassword: string; | ||
let userId: string; | ||
|
||
expect(accessibilityScanResults.violations).toEqual([]); | ||
test.beforeEach(async () => { | ||
const userInfo = await setupUser(); | ||
if (userInfo) { | ||
userEmail = userInfo.email; | ||
userPassword = userInfo.password; | ||
userId = userInfo.id; | ||
} | ||
}); | ||
}); | ||
|
||
test('has title @smoke-test', async ({ page }) => { | ||
await page.goto(`${urlConfig.citizenStartUrl}`); | ||
test.afterEach('Status check', async () => { | ||
await teardownUser(userId); | ||
}); | ||
|
||
const smokeTestTags = { tag: ['@smoke', '@citizen', '@accessibility'] }; | ||
async function submitSingleApplicationJourney( | ||
page, | ||
makeAxeBuilder, | ||
testInfo, | ||
applicantNumber, | ||
socialWorkLocation, | ||
familyCourtLocation, | ||
postcode1, | ||
telephone1 | ||
) { | ||
const app = new App(page); | ||
|
||
const appOneName = await app.applicantOneNameCreate(); | ||
const childNames = await app.childNameCreate(); | ||
|
||
await app.signIn.signIn(userEmail, userPassword); | ||
await app.numberOfApplicants.numberOfApplication(applicantNumber); | ||
await app.basePage.clickSaveAndContinue(); | ||
|
||
await app.childMoveIn(); // Date child moved in with you | ||
|
||
await app.fillChildDetails( | ||
childNames.prevChildFirstName, | ||
childNames.prevChildLastName, | ||
childNames.newChildFirstName, | ||
childNames.newChildLastName | ||
); // Child's details before adoption | ||
|
||
await app.fillSocialWorkerLocation1(socialWorkLocation); //fill social worker location | ||
await app.fillFamilyCourtLocation(familyCourtLocation); // The family court details | ||
|
||
// Fill personal details | ||
await app.tasklist.yourPersonalDetails.click(); | ||
await app.fillPersonalDetails(); | ||
await app.tasklist.yourContactDetails.click(); | ||
await app.fillContactDetails(postcode1, telephone1); | ||
|
||
// Submit | ||
await app.tasklist.reviewAndSubmit.click(); | ||
await app.pcq.noPcqAnswers(); | ||
await app.reviewSubmit.reviewAnswers(applicantNumber); | ||
await app.basePage.clickSaveAndContinue(); | ||
await app.reviewSubmit.statementOfTruthOne(appOneName.appOneFullname); | ||
await app.reviewSubmit.fillCardDetails(appOneName.appOneFullname, userEmail, postcode1); | ||
|
||
await runAccessibilityScan(makeAxeBuilder, testInfo); //Axe-core accessibility scan using helper function | ||
} | ||
|
||
// Expect a title "to contain" a substring. | ||
await expect(page).toHaveTitle(/Apply for adoption - Apply to adopt a child placed in your care - GOV.UK/); | ||
test( | ||
'smoke test: single person submits an adoption application', | ||
smokeTestTags, | ||
async ({ page, makeAxeBuilder }, testInfo) => { | ||
await submitSingleApplicationJourney( | ||
page, | ||
makeAxeBuilder, | ||
testInfo, | ||
'alone', | ||
'Sandwell Metropolitan Council', | ||
'Leicester County Court', | ||
'BN26 6AL', | ||
'0800800800' | ||
); | ||
} | ||
); | ||
}); |
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