Skip to content

Commit

Permalink
Merge pull request #1571 from hmcts/ADOP-2404
Browse files Browse the repository at this point in the history
ADOP-2402: add accessibility scan, samsung device and improve report to e2e test
  • Loading branch information
Iphiclus authored Jul 19, 2024
2 parents 2d02da7 + 97be221 commit 2ac0071
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 133 deletions.
29 changes: 1 addition & 28 deletions Jenkinsfile_nightly
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ pipelineConf.vaultSecrets = secrets
withNightlyPipeline(type, product, component) {
env.TEST_URL = "https://adoption-web.aat.platform.hmcts.net/"
env.ADOP_WEB_URL = params.FRONTEND_URL
// enableCrossBrowserTest(['chrome','microsoft'])
enableCrossBrowserTest(90)
enableFullFunctionalTest(120)
loadVaultSecrets(secrets)
enablePactAs([ AppPipelineDsl.PactRoles.CONSUMER ])
Expand All @@ -73,14 +71,6 @@ withNightlyPipeline(type, product, component) {
steps.archiveArtifacts allowEmptyArchive: true, artifacts: 'coverage/**/*'
}

before('crossBrowserTest') {

}

afterAlways('crossBrowserTest') {
steps.archiveArtifacts allowEmptyArchive: true, artifacts: 'output/**/*'
}

before('fullFunctionalTest') {
env.PARALLEL_CHUNKS = params.FUNCTIONAL_TESTS_WORKERS
env.IDAM_TOKEN_URL = "${IDAM_TOKEN_URL}"
Expand All @@ -89,7 +79,7 @@ withNightlyPipeline(type, product, component) {
}

afterAlways('fullFunctionalTest') {
stage('Playwright Tests Nightly') {
stage('UI Tests') {
try {
yarnBuilder.yarn('test:functional-nightly')
} catch (Error) {
Expand All @@ -106,23 +96,6 @@ afterAlways('fullFunctionalTest') {
steps.archiveArtifacts allowEmptyArchive: true, artifacts: 'build/reports/tests/functionalTest/**/*'
}
}
stage('Playwright Accessibility Tests Nightly') {
try {
yarnBuilder.yarn('test:accessibility-nightly')
} catch (Error) {
unstable(message: "${STAGE_NAME} is unstable: " + Error.toString())
} finally {
publishHTML([
allowMissing: true,
alwaysLinkToLastBuild: true,
keepAll: true,
reportDir: "playwright-report",
reportFiles: 'index.html',
reportName: 'Playwright Accessibility Functional Test Report'
])
steps.archiveArtifacts allowEmptyArchive: true, artifacts: 'build/reports/tests/functionalTest/**/*'
}
}
}

afterAlways('fortify-scan') {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"test:functional:skip": "echo 'Not running functional cases in Master' && exit 0",
"test:crossbrowser-e2e": "MOCHAWESOME_REPORTFILENAME=crossbrowser codeceptjs run-multiple --grep '@cross-browser' ${BROWSER_GROUP:-'--all'} -c saucelabs.conf.js --reporter mocha-multi",
"test:crossbrowser": "./bin/run-crossbrowser-tests.sh",
"test:functional-nightly": "yarn playwright install chromium && yarn playwright install firefox && yarn playwright install webkit && yarn playwright test --project=chromium --project=webkit --project=firefox",
"test:functional-nightly": "yarn playwright install chromium && yarn playwright install firefox && yarn playwright install webkit && yarn run-all-browsers",
"run-all-browsers": "yarn playwright test --project=chromium --project=firefox --project=webkit --project=MobileChrome --project=MobileSamsungPortrait --project=MobileSamsungLandscape",
"test:accessibility-nightly": "yarn playwright install chromium && yarn playwright install firefox && yarn playwright install webkit && yarn playwright test --grep @accessibility",
"test:local": "codeceptjs run-multiple parallel",
"test:pact": "jest -c jest.pact.config.js --runInBand",
Expand Down
3 changes: 3 additions & 0 deletions playwright-e2e/helpers/accessibilityHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import AxeBuilder from '@axe-core/playwright';
import { TestInfo } from '@playwright/test';

import { expect } from '../fixtures/fixtures';

type MakeAxeBuilder = () => AxeBuilder;
export async function attachTestInfo(testInfo: TestInfo, data: object): Promise<void> {
await testInfo.attach('accessibility-scan-results', {
Expand All @@ -14,7 +15,9 @@ export async function runAccessibilityScan(makeAxeBuilder: MakeAxeBuilder, testI
.disableRules(['aria-allowed-attr', 'target-size'])
//axe-core triggers known GDS issue (https://github.com/alphagov/govuk-frontend/issues/979) on conditional radio buttons (https://design-system.service.gov.uk/components/radios/conditional-reveal/)
//bug raised for target size: https://tools.hmcts.net/jira/browse/ADOP-2445
.withTags(['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa', 'wcag22a', 'wcag22aa'])
.analyze();
await attachTestInfo(testInfo, accessibilityScanResults);
expect(accessibilityScanResults.violations).toEqual([]);
}
export { expect } from '@playwright/test';
212 changes: 113 additions & 99 deletions playwright-e2e/tests/submit-application-journey.spec.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
import AxeBuilder from '@axe-core/playwright';
import { faker } from '@faker-js/faker';
import { test } from '@playwright/test';
import { test as base } from '@playwright/test';
import * as dotenv from 'dotenv';

import { runAccessibilityScan } from '../helpers/accessibilityHelper';
import { setupUser, teardownUser } from '../hooks/createDeleteUser.hook';
import App from '../pages/app.page';

dotenv.config();

test.describe('e2e submit journeys', { tag: '@submit' }, () => {
const test = base.extend<{ makeAxeBuilder: () => AxeBuilder }>({
makeAxeBuilder: async ({ page }, use) => {
await use(() => new AxeBuilder({ page }));
},
});

test.describe('e2e submit journeys', () => {
let userEmail: string;
let userPassword: string;
let userId: string;
Expand All @@ -25,101 +33,107 @@ test.describe('e2e submit journeys', { tag: '@submit' }, () => {
await teardownUser(userId);
});

test('submitting application with spouse or civil partner', async ({ page }) => {
const app = new App(page);

const appOneFirstName = faker.person.firstName();
const appOneLastName = faker.person.lastName();
const appTwoFirstName = faker.person.firstName();
const appTwoLastName = faker.person.lastName();
const appOneFullname = appOneFirstName + ' ' + appOneLastName;
const appTwoFullname = appTwoFirstName + ' ' + appTwoLastName;
const childFirstName = faker.person.firstName();
const childLastName = faker.person.lastName();
await app.signIn.signIn(userEmail, userPassword);
await app.numberOfApplicants.applyWithSpouseOrCivil();
await app.basePage.clickSaveAndContinue();

// Date child moved in with you
await app.tasklist.dateChildMovedIn.click();
await app.dateChildMoved.dateChildMovedInToday();
await app.basePage.clickSaveAndContinue();

// Child's details before adoption
await app.tasklist.childsDetails.click();
await app.basePage.fillFirstLastName(appOneFirstName, appOneLastName);
await app.basePage.clickSaveAndContinue();

// Child's details after adoption
await app.basePage.fillFirstLastName(childFirstName, childLastName);
await app.basePage.clickSaveAndContinue();
await app.childDetails.childsDob();
await app.basePage.clickSaveAndContinue();

await app.tasklist.adoptionAgency.click();
await app.adoptionAgency.childsChildSocialWorkerDetails('Sandwell Metropolitan Council');
await app.basePage.saveAndContinue.click();
await app.adoptionAgency.childsYourSocialWorkerDetails('Sandwell Metropolitan Council');
await app.basePage.saveAndContinue.click();
await app.adoptionAgency.anotherAdoptionAgencyNo();
await app.basePage.saveAndContinue.click();

// The family court details
await app.tasklist.familyCourtDetails.click();
await app.basePage.selectLocation('Leicester County Court');
await app.basePage.clickSaveAndContinue();
await app.familyCourt.sameCourtYes();
await app.basePage.clickSaveAndContinue();

// First applicant Your personal details
await app.tasklist.firstApplicantPersonalDetails.click();
await app.basePage.clickSaveAndContinue();
await app.addApplicants.otherNamesSelectNo();
await app.basePage.clickSaveAndContinue();
await app.addApplicants.dob();
await app.basePage.clickSaveAndContinue();
await app.addApplicants.addOccupationFirst();
await app.basePage.clickSaveAndContinue();
await app.extraSupport.noSupportNeeded();
await app.basePage.clickSaveAndContinue();

// First applicant Your contact details
await app.tasklist.firstApplicantContactDetails.click();
await app.basePage.postcodeFindAddress('BN26 6AL', '0');
await app.basePage.clickSaveAndContinue();
await app.contactDetails.fillContactDetails('[email protected]', '0800800800');
await app.basePage.clickSaveAndContinue();
await app.contactDetails.englishLang.check();
await app.basePage.clickSaveAndContinue();

//Second applicant personal details
await app.tasklist.secondApplicantPersonalDetails.click();
await app.basePage.fillFirstLastName(appTwoFirstName, appTwoLastName);
await app.basePage.clickSaveAndContinue();
await app.addApplicants.otherNamesNo.check();
await app.basePage.clickSaveAndContinue();
await app.addApplicants.dob();
await app.basePage.clickSaveAndContinue();
await app.addApplicants.addOccupationSecond();
await app.basePage.clickSaveAndContinue();
await app.extraSupport.noSupportNeeded();
await app.basePage.clickSaveAndContinue();

//Second applicant contact details
await app.tasklist.secondApplicantContactDetails.click();
await app.page.getByLabel('Yes').check(); //do you live at the same address?
await app.basePage.clickSaveAndContinue();
await app.contactDetails.fillContactDetails('[email protected]', '0800800800');
await app.basePage.clickSaveAndContinue();
await app.contactDetails.englishLang.check();
await app.basePage.clickSaveAndContinue();

//submit
await app.tasklist.reviewAndSubmit.click();
await app.pcq.noPcqAnswers();
await app.reviewSubmit.reviewAnswers();
await app.basePage.clickSaveAndContinue();
await app.reviewSubmit.statementOfTruth(appOneFullname, appTwoFullname);
await app.reviewSubmit.fillCardDetails(appOneFullname, '[email protected]');
});
const e2eTestTags = { tag: ['@e2e', '@citizen', '@accessibility'] };

test(
'submitting application with spouse or civil partner',
e2eTestTags,
async ({ page, makeAxeBuilder }, testInfo) => {
const app = new App(page);
const appOneFirstName = faker.person.firstName();
const appOneLastName = faker.person.lastName();
const appTwoFirstName = faker.person.firstName();
const appTwoLastName = faker.person.lastName();
const appOneFullname = appOneFirstName + ' ' + appOneLastName;
const appTwoFullname = appTwoFirstName + ' ' + appTwoLastName;
const childFirstName = faker.person.firstName();
const childLastName = faker.person.lastName();
await app.signIn.signIn(userEmail, userPassword);
await app.numberOfApplicants.applyWithSpouseOrCivil();
await app.basePage.clickSaveAndContinue();

// Date child moved in with you
await app.tasklist.dateChildMovedIn.click();
await app.dateChildMoved.dateChildMovedInToday();
await app.basePage.clickSaveAndContinue();

// Child's details before adoption
await app.tasklist.childsDetails.click();
await app.basePage.fillFirstLastName(appOneFirstName, appOneLastName);
await app.basePage.clickSaveAndContinue();

// Child's details after adoption
await app.basePage.fillFirstLastName(childFirstName, childLastName);
await app.basePage.clickSaveAndContinue();
await app.childDetails.childsDob();
await app.basePage.clickSaveAndContinue();

await app.tasklist.adoptionAgency.click();
await app.adoptionAgency.childsChildSocialWorkerDetails('Sandwell Metropolitan Council');
await app.basePage.saveAndContinue.click();
await app.adoptionAgency.childsYourSocialWorkerDetails('Sandwell Metropolitan Council');
await app.basePage.saveAndContinue.click();
await app.adoptionAgency.anotherAdoptionAgencyNo();
await app.basePage.saveAndContinue.click();

// The family court details
await app.tasklist.familyCourtDetails.click();
await app.basePage.selectLocation('Leicester County Court');
await app.basePage.clickSaveAndContinue();
await app.familyCourt.sameCourtYes();
await app.basePage.clickSaveAndContinue();

// First applicant Your personal details
await app.tasklist.firstApplicantPersonalDetails.click();
await app.basePage.clickSaveAndContinue();
await app.addApplicants.otherNamesSelectNo();
await app.basePage.clickSaveAndContinue();
await app.addApplicants.dob();
await app.basePage.clickSaveAndContinue();
await app.addApplicants.addOccupationFirst();
await app.basePage.clickSaveAndContinue();
await app.extraSupport.noSupportNeeded();
await app.basePage.clickSaveAndContinue();

// First applicant Your contact details
await app.tasklist.firstApplicantContactDetails.click();
await app.basePage.postcodeFindAddress('BN26 6AL', '0');
await app.basePage.clickSaveAndContinue();
await app.contactDetails.fillContactDetails('[email protected]', '0800800800');
await app.basePage.clickSaveAndContinue();
await app.contactDetails.englishLang.check();
await app.basePage.clickSaveAndContinue();

//Second applicant personal details
await app.tasklist.secondApplicantPersonalDetails.click();
await app.basePage.fillFirstLastName(appTwoFirstName, appTwoLastName);
await app.basePage.clickSaveAndContinue();
await app.addApplicants.otherNamesNo.check();
await app.basePage.clickSaveAndContinue();
await app.addApplicants.dob();
await app.basePage.clickSaveAndContinue();
await app.addApplicants.addOccupationSecond();
await app.basePage.clickSaveAndContinue();
await app.extraSupport.noSupportNeeded();
await app.basePage.clickSaveAndContinue();

//Second applicant contact details
await app.tasklist.secondApplicantContactDetails.click();
await app.page.getByLabel('Yes').check(); //do you live at the same address?
await app.basePage.clickSaveAndContinue();
await app.contactDetails.fillContactDetails('[email protected]', '0800800800');
await app.basePage.clickSaveAndContinue();
await app.contactDetails.englishLang.check();
await app.basePage.clickSaveAndContinue();

//submit
await app.tasklist.reviewAndSubmit.click();
await app.pcq.noPcqAnswers();
await app.reviewSubmit.reviewAnswers();
await app.basePage.clickSaveAndContinue();
await app.reviewSubmit.statementOfTruth(appOneFullname, appTwoFullname);
await app.reviewSubmit.fillCardDetails(appOneFullname, '[email protected]');
await runAccessibilityScan(makeAxeBuilder, testInfo);
}
);
});
18 changes: 13 additions & 5 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ export default defineConfig({
testDir: './playwright-e2e',
/* Run tests in files in parallel */
fullyParallel: true,
timeout: 50000,
timeout: 80000,

expect: { timeout: 50000 },
expect: { timeout: 80000 },
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 1 : 0,
retries: process.env.CI ? 3 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 5 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
Expand Down Expand Up @@ -52,13 +52,21 @@ export default defineConfig({

/* Test against mobile viewports. */
{
name: 'Mobile Chrome',
name: 'MobileChrome',
use: { ...devices['Pixel 5'] },
},
{
name: 'Mobile Safari',
name: 'MobileSafari',
use: { ...devices['iPhone 12'] },
},
{
name: 'MobileSamsungPortrait',
use: { ...devices['Galaxy S III'] },
},
{
name: 'MobileSamsungLandscape',
use: { ...devices['Galaxy S III landscape'] },
},

/* Test against branded browsers. */
// {
Expand Down

0 comments on commit 2ac0071

Please sign in to comment.