Skip to content

Commit

Permalink
e2e user journey refactored (#1586)
Browse files Browse the repository at this point in the history
  • Loading branch information
AustenStevensMOJ authored Oct 8, 2024
1 parent cd9cf6b commit bd9d160
Show file tree
Hide file tree
Showing 2 changed files with 192 additions and 138 deletions.
135 changes: 135 additions & 0 deletions playwright-e2e/helpers/e2eJourneyHelper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
import App from '../pages/app.page';

export async function citizenAdoptionSignInWithNoPartner(
app: App,
userEmail: string,
userPassword: string,
locator: string
): Promise<void> {
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<void> {
await app.signIn.signIn(userEmail, userPassword);
await app.numberOfApplicants.numberOfApplication(locator);
await app.basePage.clickSaveAndContinue();
}

export async function citizenAdoptionDateChildMovedIn(app: App): Promise<void> {
await app.tasklist.dateChildMovedIn.click();
await app.dateChildMoved.dateChildMovedInToday();
await app.basePage.clickSaveAndContinue();
}

export async function citzenAdoptionChildDetailsBeforeAdoption(
app: App,
firstname: string,
lastName: string
): Promise<void> {
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<void> {
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<void> {
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<void> {
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<void> {
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<void> {
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();
}

export async function citizenAdoptionSecondApplicantPersonalDetails(
app: App,
firstname: string,
lastName: string
): Promise<void> {
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<void> {
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();
}

export async function citizenAdoptionSubmitApplication(
app: App,
appOneFullname: string,
appTwoFullname: string,
locator: string
): Promise<void> {
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, '[email protected]', 'BN26 6AL');
}
195 changes: 57 additions & 138 deletions playwright-e2e/tests/submit-application-journey.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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('[email protected]', '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('[email protected]', '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, '[email protected]', 'BN26 6AL');
await runAccessibilityScan(makeAxeBuilder, testInfo);
}
);
Expand All @@ -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('[email protected]', '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('[email protected]', '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, '[email protected]', 'BN26 6AL');
await e2eJourneyHelper.citizenAdoptionSubmitApplication(
app,
appOneFullname,
appTwoFullname,
stringNumberOfApplicationLocator
);

await runAccessibilityScan(makeAxeBuilder, testInfo);
}
);
Expand Down

0 comments on commit bd9d160

Please sign in to comment.