Skip to content

Commit

Permalink
Update e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Liburd committed Jan 9, 2025
1 parent c33289a commit ea8dc20
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
25 changes: 24 additions & 1 deletion e2e-tests/steps/offenceAndLicenceInformationSection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/tests/01_apply_as_pom.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})

Expand Down

0 comments on commit ea8dc20

Please sign in to comment.