From ea8dc20722d97bbcc84e9f57892bf25641e48f02 Mon Sep 17 00:00:00 2001 From: Daniel Liburd Date: Thu, 9 Jan 2025 15:24:51 +0000 Subject: [PATCH] Update e2e tests --- .../offenceAndLicenceInformationSection.ts | 25 ++++++++++++++++++- e2e-tests/tests/01_apply_as_pom.spec.ts | 2 +- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/e2e-tests/steps/offenceAndLicenceInformationSection.ts b/e2e-tests/steps/offenceAndLicenceInformationSection.ts index 5d24709..f82ae38 100644 --- a/e2e-tests/steps/offenceAndLicenceInformationSection.ts +++ b/e2e-tests/steps/offenceAndLicenceInformationSection.ts @@ -3,15 +3,38 @@ import { ApplyPage, TaskListPage } from '../pages/apply' export const completeCommunitySupervisionAndCurrentOffencesTask = async (page: Page, name: string) => { const taskListPage = new TaskListPage(page) - await taskListPage.clickTask('Community supervision and current offences') + await taskListPage.clickTask('Add alleged offences') + await completeAllegedOffenceDetailsPage(page, name) + await completeAllegedOffencesPage(page, name) await completeCommunitySupervisionPage(page, name) await completeCPPDetailsPage(page, name) await completeCurrentOffenceDetailsPage(page, name) await completeCurrentOffencesPage(page, name) } +async function completeAllegedOffenceDetailsPage(page: Page, name: string) { + const allegedOffenceDetailsPage = await ApplyPage.initialize(page, `Add ${name}'s alleged offence details`) + await allegedOffenceDetailsPage.fillField('Offence title', 'Stalking') + await allegedOffenceDetailsPage.chooseSelectItem('Offence type', 'Stalking or Harassment') + await allegedOffenceDetailsPage.fillDateFieldInGroup('When is it alleged that they committed the offence?', { + year: '2022', + month: '3', + day: '1', + }) + await allegedOffenceDetailsPage.fillField('Provide a summary of the allegations', 'an offence summary') + await allegedOffenceDetailsPage.clickButton('Save and continue') +} + +async function completeAllegedOffencesPage(page: Page, name: string) { + const allegedOffencesPage = await ApplyPage.initialize(page, `Alleged offences for ${name}`) + await allegedOffencesPage.clickButton('Save and continue') +} + async function completeCommunitySupervisionPage(page: Page, name: string) { + const taskListPage = new TaskListPage(page) + await taskListPage.clickTask('Community supervision and current offences') + const communitySupervisionPage = await ApplyPage.initialize(page, `Is ${name} currently supervised by probation?`) await communitySupervisionPage.checkRadio('Yes') await communitySupervisionPage.clickButton('Save and continue') diff --git a/e2e-tests/tests/01_apply_as_pom.spec.ts b/e2e-tests/tests/01_apply_as_pom.spec.ts index fc7c855..a3ada90 100644 --- a/e2e-tests/tests/01_apply_as_pom.spec.ts +++ b/e2e-tests/tests/01_apply_as_pom.spec.ts @@ -32,7 +32,7 @@ test('create a CAS-2 application', async ({ page, person, pomUser }) => { await completeOffenceInformationSection(page, person.name) await completeBailInformationSection(page, person.name) await completeCheckAnswersSection(page, person.name) - await expect(page.getByText('You have completed 18 of 18 tasks')).toBeVisible() + await expect(page.getByText('You have completed 19 of 19 tasks')).toBeVisible() await submitApplication(page) })