Skip to content

Commit

Permalink
Introduce e2e for applying as a BIO
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Liburd committed Feb 4, 2025
1 parent 3d8723f commit a733da2
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 3 deletions.
5 changes: 5 additions & 0 deletions e2e-tests/pages/apply/applicationOriginPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,9 @@ export class ApplicationOriginPage extends BasePage {
await this.checkRadio('Prison bail')
await this.clickButton('Confirm')
}

async chooseCourtBail() {
await this.checkRadio('Court bail')
await this.clickButton('Confirm')
}
}
8 changes: 8 additions & 0 deletions e2e-tests/pages/apply/findByCrnPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { BasePage } from '../basePage'

export class FindByCrnPage extends BasePage {
async enterCrn(crn: string) {
await this.page.getByLabel("Enter the person's CRN").fill(crn)
}
}

14 changes: 12 additions & 2 deletions e2e-tests/steps/apply.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,13 @@ export const startAnApplication = async (page: Page) => {
await beforeYouStartPage.startNow()
}

export const selectApplicationOrigin = async (page: Page) => {
export const selectApplicationOrigin = async (page: Page, applicationOrigin: 'courtBail' | 'prisonBail') => {
const applicationOriginPage = new ApplicationOriginPage(page)
await applicationOriginPage.choosePrisonBail()
if (applicationOrigin === 'prisonBail') {
await applicationOriginPage.choosePrisonBail()
} else {
await applicationOriginPage.chooseCourtBail()
}
}

export const enterPrisonerNumber = async (page: Page, prisonNumber: string) => {
Expand All @@ -59,6 +63,12 @@ export const enterPrisonerNumber = async (page: Page, prisonNumber: string) => {
await prisonNumberPage.clickButton('Search for applicant')
}

export const enterCrn = async (page: Page, crn: string) => {
const crnPage = new FindByCrnPage(page)
await crnPage.enterCrn(crn)
await crnPage.clickButton('Search for applicant')
}

export const confirmApplicant = async (page: Page) => {
const confirmApplicantPage = new TaskListPage(page)
await confirmApplicantPage.clickButton('Confirm 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 @@ -24,7 +24,7 @@ import { cancelAnApplication, clickCancel } from '../steps/cancelInProgressAppli
test('create a CAS-2 bail application', async ({ page, person, pomUser }) => {
await signIn(page, pomUser)
await startAnApplication(page)
await selectApplicationOrigin(page)
await selectApplicationOrigin(page, 'prisonBail')
await enterPrisonerNumber(page, person.nomsNumber)
await confirmApplicant(page)
await completeBeforeYouStartSection(page, person.name)
Expand Down
59 changes: 59 additions & 0 deletions e2e-tests/tests/02_apply_as_bio.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { expect } from '@playwright/test'
import { test } from '../test'
import {
completeAboutThePersonSection,
completeAreaAndFundingSection,
completeBeforeYouStartSection,
completeCheckAnswersSection,
completeOffenceInformationSection,
completeRisksAndNeedsSection,
completeBailInformationSection,
confirmApplicant,
enterCrn,
selectApplicationOrigin,
startAnApplication,
submitApplication,
viewSubmittedApplication,
addNote,
viewInProgressDashboard,
createAnInProgressApplication,
} from '../steps/apply'
import { signIn } from '../steps/signIn'
import { cancelAnApplication, clickCancel } from '../steps/cancelInProgressApplication'

test('create a CAS-2 bail application', async ({ page, person, bioUser }) => {
await signIn(page, bioUser)
await startAnApplication(page)
await selectApplicationOrigin(page, 'courtBail')
await enterCrn(page, person.crn)
await confirmApplicant(page)
await completeBeforeYouStartSection(page, person.name)
await completeAreaAndFundingSection(page, person.name)
await completeAboutThePersonSection(page, person.name)
await completeRisksAndNeedsSection(page, person.name)
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 submitApplication(page)
})

test('add a note to a submitted application', async ({ page, person, bioUser }) => {
await signIn(page, bioUser)
await viewSubmittedApplication(page, person.name)
await addNote(page)
await expect(page.locator('.moj-timeline__title').first()).toContainText('Note')
})

test('cancel an in progress application from the task list', async ({ page, bioUser, person }) => {
await signIn(page, bioUser)
await createAnInProgressApplication(page, person)
await viewInProgressDashboard(page)
const numberOfApplicationsBeforeCancellation = (await page.locator('tr').all()).length
await clickCancel(page, person.name)
await cancelAnApplication(page, person.name)
const numberOfApplicationsAfterCancellation = (await page.locator('tr').all()).length
await expect(page.getByText('Your CAS-2 applications')).toBeVisible()
expect(numberOfApplicationsBeforeCancellation - numberOfApplicationsAfterCancellation).toEqual(1)
})

0 comments on commit a733da2

Please sign in to comment.