From bd9d160596e25b57cd99dcd7923a32a7d4d6a925 Mon Sep 17 00:00:00 2001 From: Austen Stevens Date: Tue, 8 Oct 2024 11:52:23 +0100 Subject: [PATCH] e2e user journey refactored (#1586) --- playwright-e2e/helpers/e2eJourneyHelper.ts | 135 ++++++++++++ .../tests/submit-application-journey.spec.ts | 195 +++++------------- 2 files changed, 192 insertions(+), 138 deletions(-) create mode 100644 playwright-e2e/helpers/e2eJourneyHelper.ts diff --git a/playwright-e2e/helpers/e2eJourneyHelper.ts b/playwright-e2e/helpers/e2eJourneyHelper.ts new file mode 100644 index 000000000..fdcccea61 --- /dev/null +++ b/playwright-e2e/helpers/e2eJourneyHelper.ts @@ -0,0 +1,135 @@ +import App from '../pages/app.page'; + +export async function citizenAdoptionSignInWithNoPartner( + app: App, + userEmail: string, + userPassword: string, + locator: string +): Promise { + await app.signIn.signIn(userEmail, userPassword); + await app.numberOfApplicants.numberOfApplication(locator); + await app.numberOfApplicants.fillNotSpouseOrCivilPartnerDetails('Text to be randomly generated'); + + await app.basePage.clickSaveAndContinue(); +} + +export async function citizenAdoptionSignInWithPartner( + app: App, + userEmail: string, + userPassword: string, + locator: string +): Promise { + await app.signIn.signIn(userEmail, userPassword); + await app.numberOfApplicants.numberOfApplication(locator); + await app.basePage.clickSaveAndContinue(); +} + +export async function citizenAdoptionDateChildMovedIn(app: App): Promise { + await app.tasklist.dateChildMovedIn.click(); + await app.dateChildMoved.dateChildMovedInToday(); + await app.basePage.clickSaveAndContinue(); +} + +export async function citzenAdoptionChildDetailsBeforeAdoption( + app: App, + firstname: string, + lastName: string +): Promise { + await app.tasklist.childsDetails.click(); + await app.basePage.fillFirstLastName(firstname, lastName); + await app.basePage.clickSaveAndContinue(); // an error could be occuring here +} + +export async function citizenAdoptionChildDetailsAfterAdoption( + app: App, + childFirstName: string, + childLastName: string +): Promise { + await app.basePage.fillFirstLastName(childFirstName, childLastName); + await app.basePage.clickSaveAndContinue(); + await app.childDetails.childsDob(); + await app.basePage.clickSaveAndContinue(); +} + +export async function citizenAdoptionSocialWorkDetails(app: App): Promise { + 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(); +} + +export async function citizenAdoptionFamilyCourtDetails(app: App): Promise { + await app.tasklist.familyCourtDetails.click(); + await app.basePage.selectLocation('Leicester County Court'); + await app.basePage.clickSaveAndContinue(); + await app.familyCourt.sameCourtYes(); + await app.basePage.clickSaveAndContinue(); +} + +export async function citizenAdoptionApplicantPersonalDetails(app: App): Promise { + 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(); +} + +export async function citizenAdoptionApplicantContactDetails(app: App): Promise { + await app.tasklist.firstApplicantContactDetails.click(); + await app.basePage.postcodeFindAddress('BN26 6AL', '0'); + await app.basePage.clickSaveAndContinue(); + await app.contactDetails.fillContactDetails('1234567890@domain.com', '0800800800'); + await app.basePage.clickSaveAndContinue(); + await app.contactDetails.englishLang.check(); + await app.basePage.clickSaveAndContinue(); +} + +export async function citizenAdoptionSecondApplicantPersonalDetails( + app: App, + firstname: string, + lastName: string +): Promise { + await app.tasklist.secondApplicantPersonalDetails.click(); + await app.basePage.fillFirstLastName(firstname, lastName); + 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(); +} + +export async function citizenAdoptionSecondApplicantContactDetails(app: App): Promise { + 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('abcdefg@domain.com', '0800800800'); + await app.basePage.clickSaveAndContinue(); + await app.contactDetails.englishLang.check(); + await app.basePage.clickSaveAndContinue(); +} + +export async function citizenAdoptionSubmitApplication( + app: App, + appOneFullname: string, + appTwoFullname: string, + locator: string +): Promise { + await app.tasklist.reviewAndSubmit.click(); + await app.pcq.noPcqAnswers(); + await app.reviewSubmit.reviewAnswers(locator); + await app.basePage.clickSaveAndContinue(); + await app.reviewSubmit.statementOfTruthTwo(appOneFullname, appTwoFullname); + await app.reviewSubmit.fillCardDetails(appOneFullname, 'abcdefg@domain.com', 'BN26 6AL'); +} diff --git a/playwright-e2e/tests/submit-application-journey.spec.ts b/playwright-e2e/tests/submit-application-journey.spec.ts index 2e61abb28..bdb3f151e 100644 --- a/playwright-e2e/tests/submit-application-journey.spec.ts +++ b/playwright-e2e/tests/submit-application-journey.spec.ts @@ -4,6 +4,7 @@ import { test as base } from '@playwright/test'; import * as dotenv from 'dotenv'; import { runAccessibilityScan } from '../helpers/accessibilityHelper'; +import * as e2eJourneyHelper from '../helpers/e2eJourneyHelper'; import { setupUser, teardownUser } from '../hooks/createDeleteUser.hook'; import App from '../pages/app.page'; @@ -48,93 +49,51 @@ test.describe('e2e submit journeys', () => { const appTwoFullname = appTwoFirstName + ' ' + appTwoFirstName; const childFirstName = faker.person.firstName(); const childLastName = faker.person.lastName(); - await app.signIn.signIn(userEmail, userPassword); - await app.numberOfApplicants.numberOfApplication('notSpouseOrCivilPartner'); - await app.numberOfApplicants.fillNotSpouseOrCivilPartnerDetails('Text to be randomly generated'); - await app.basePage.clickSaveAndContinue(); + const stringNumberOfApplicationLocator = 'notSpouseOrCivilPartner'; + + // Sign in + await e2eJourneyHelper.citizenAdoptionSignInWithNoPartner( + app, + userEmail, + userPassword, + stringNumberOfApplicationLocator + ); // Date child move in with you - await app.tasklist.dateChildMovedIn.click(); - await app.dateChildMoved.dateChildMovedInToday(); - await app.basePage.clickSaveAndContinue(); + await e2eJourneyHelper.citizenAdoptionDateChildMovedIn(app); // Child's details before adoption - await app.tasklist.childsDetails.click(); - await app.basePage.fillFirstLastName(appOneFirstName, appOneLastName); - await app.basePage.clickSaveAndContinue(); // where the error is occurring + await e2eJourneyHelper.citzenAdoptionChildDetailsBeforeAdoption(app, appOneFirstName, appOneLastName); // Child's details after adoption - await app.basePage.fillFirstLastName(childFirstName, childLastName); - await app.basePage.clickSaveAndContinue(); - await app.childDetails.childsDob(); - await app.basePage.clickSaveAndContinue(); - - // This is doing something else now - 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(); + await e2eJourneyHelper.citizenAdoptionChildDetailsAfterAdoption(app, childFirstName, childLastName); + + // Social Worker Details + await e2eJourneyHelper.citizenAdoptionSocialWorkDetails(app); // 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(); + await e2eJourneyHelper.citizenAdoptionFamilyCourtDetails(app); // 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(); + await e2eJourneyHelper.citizenAdoptionApplicantPersonalDetails(app); // 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('1234567890@domain.com', '0800800800'); - await app.basePage.clickSaveAndContinue(); - await app.contactDetails.englishLang.check(); - await app.basePage.clickSaveAndContinue(); + await e2eJourneyHelper.citizenAdoptionApplicantContactDetails(app); //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(); + await e2eJourneyHelper.citizenAdoptionSecondApplicantPersonalDetails(app, appTwoFirstName, appTwoLastName); - //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('abcdefg@domain.com', '0800800800'); - await app.basePage.clickSaveAndContinue(); - await app.contactDetails.englishLang.check(); - await app.basePage.clickSaveAndContinue(); + // Second applicant contact details + await e2eJourneyHelper.citizenAdoptionSecondApplicantContactDetails(app); + + // submit + await e2eJourneyHelper.citizenAdoptionSubmitApplication( + app, + appOneFullname, + appTwoFullname, + stringNumberOfApplicationLocator + ); - //submit - await app.tasklist.reviewAndSubmit.click(); - await app.pcq.noPcqAnswers(); - await app.reviewSubmit.reviewAnswers('notSpouseOrCivilPartner'); - await app.basePage.clickSaveAndContinue(); - await app.reviewSubmit.statementOfTruthTwo(appOneFullname, appTwoFullname); - await app.reviewSubmit.fillCardDetails(appOneFullname, 'abcdefg@domain.com', 'BN26 6AL'); await runAccessibilityScan(makeAxeBuilder, testInfo); } ); @@ -152,91 +111,51 @@ test.describe('e2e submit journeys', () => { const appTwoFullname = appTwoFirstName + ' ' + appTwoLastName; const childFirstName = faker.person.firstName(); const childLastName = faker.person.lastName(); - await app.signIn.signIn(userEmail, userPassword); - await app.numberOfApplicants.numberOfApplication('spouseOrCivilPartner'); - await app.basePage.clickSaveAndContinue(); + const stringNumberOfApplicationLocator = 'spouseOrCivilPartner'; + + // Sign in + await e2eJourneyHelper.citizenAdoptionSignInWithPartner( + app, + userEmail, + userPassword, + stringNumberOfApplicationLocator + ); // Date child moved in with you - await app.tasklist.dateChildMovedIn.click(); - await app.dateChildMoved.dateChildMovedInToday(); - await app.basePage.clickSaveAndContinue(); + await e2eJourneyHelper.citizenAdoptionDateChildMovedIn(app); // Child's details before adoption - await app.tasklist.childsDetails.click(); - await app.basePage.fillFirstLastName(appOneFirstName, appOneLastName); - await app.basePage.clickSaveAndContinue(); + await e2eJourneyHelper.citzenAdoptionChildDetailsBeforeAdoption(app, appOneFirstName, appOneLastName); // 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(); + await e2eJourneyHelper.citizenAdoptionChildDetailsAfterAdoption(app, childFirstName, childLastName); + + // Social Worker Details + await e2eJourneyHelper.citizenAdoptionSocialWorkDetails(app); // 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(); + await e2eJourneyHelper.citizenAdoptionFamilyCourtDetails(app); // 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(); + await e2eJourneyHelper.citizenAdoptionApplicantPersonalDetails(app); // 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('1234567890@domain.com', '0800800800'); - await app.basePage.clickSaveAndContinue(); - await app.contactDetails.englishLang.check(); - await app.basePage.clickSaveAndContinue(); + await e2eJourneyHelper.citizenAdoptionApplicantContactDetails(app); //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(); + await e2eJourneyHelper.citizenAdoptionSecondApplicantPersonalDetails(app, appTwoFirstName, appTwoLastName); //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('abcdefg@domain.com', '0800800800'); - await app.basePage.clickSaveAndContinue(); - await app.contactDetails.englishLang.check(); - await app.basePage.clickSaveAndContinue(); + await e2eJourneyHelper.citizenAdoptionSecondApplicantContactDetails(app); //submit - await app.tasklist.reviewAndSubmit.click(); - await app.pcq.noPcqAnswers(); - await app.reviewSubmit.reviewAnswers('spouseOrCivilPartner'); - await app.basePage.clickSaveAndContinue(); - await app.reviewSubmit.statementOfTruthTwo(appOneFullname, appTwoFullname); - await app.reviewSubmit.fillCardDetails(appOneFullname, 'abcdefg@domain.com', 'BN26 6AL'); + await e2eJourneyHelper.citizenAdoptionSubmitApplication( + app, + appOneFullname, + appTwoFullname, + stringNumberOfApplicationLocator + ); + await runAccessibilityScan(makeAxeBuilder, testInfo); } );