Skip to content

Commit

Permalink
Update e2e tests
Browse files Browse the repository at this point in the history
Now that we’ve removed the OASys import from the risk tasks, we need to update the E2E tests.
  • Loading branch information
Patrick Fleming committed Jan 7, 2025
1 parent e70f2c6 commit fb84102
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 93 deletions.
13 changes: 1 addition & 12 deletions e2e-tests/steps/apply.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,7 @@ import {
completeEqualityAndDiversityTask,
completePersonalInformationTask,
} from './aboutThePersonSection'
import {
completeHealthNeedsTask,
completeRiskToSelfTask,
completeRoshTask,
enterOldRiskToSelfOasysDate,
enterOldRoshOasysDate,
} from './risksAndNeedsSection'
import { completeHealthNeedsTask, completeRiskToSelfTask, completeRoshTask } from './risksAndNeedsSection'
import { completeAreaInformationTask, completeFundingInformationTask } from './areaAndFundingSection'
import { completeCurrentOffencesTask, completeOffenceHistoryTask } from './offenceAndLicenceInformationSection'
import { completeCheckAnswersTask } from './checkAnswersSection'
Expand Down Expand Up @@ -80,11 +74,6 @@ export const completeRisksAndNeedsSection = async (page: Page, name: string) =>
await completeRoshTask(page, name)
}

export const enterOldOasysDates = async (page: Page, name: string) => {
await enterOldRiskToSelfOasysDate(page, name)
await enterOldRoshOasysDate(page, name)
}

export const completeOffenceInformationSection = async (page: Page, name: string) => {
await completeCurrentOffencesTask(page, name)
await completeOffenceHistoryTask(page, name)
Expand Down
80 changes: 9 additions & 71 deletions e2e-tests/steps/risksAndNeedsSection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,50 +118,21 @@ export const completeRiskToSelfTask = async (page: Page, name: string) => {
const taskListPage = new TaskListPage(page)
await taskListPage.clickTask('Add risk to self information')

await reviewOasysImportPage(page, name)
await completeVulnerabilityPage(page, name)
await completeCurrentRisksPage(page, name)
await completeHistoricalRisksPage(page, name)
await addAnAcct(page)
await completeAdditionalInformationPage(page, name)
}

export const enterOldRiskToSelfOasysDate = async (page: Page, name: string) => {
const taskListPage = new TaskListPage(page)
await taskListPage.clickTask('Add risk to self information')

await reviewOasysImportPage(page, name)
await completeOldOasysPage(page, name)
await returnToTaskList(page)
}

async function reviewOasysImportPage(page: Page, name: string) {
const guidancePage = await ApplyPage.initialize(page, `Import ${name}'s risk to self data from OASys`)
await guidancePage.clickContinue()
}

async function completeOldOasysPage(page: Page, name: string) {
const oldOasysPage = await ApplyPage.initialize(
page,
`Does ${name} have an older OASys with risk to self information? `,
)
await oldOasysPage.checkRadio('No')
await oldOasysPage.clickContinue()
}

async function confirmAndSave(page: TaskListPage | ApplyPage) {
await page.checkCheckboxes(['I confirm this information is relevant and up to date.'])
await page.clickSave()
}

async function completeVulnerabilityPage(page: Page, name: string) {
const vulnerabilityPage = await ApplyPage.initialize(page, `${name}'s vulnerability`)

await vulnerabilityPage.fillField(
`Describe ${name}'s current circumstances, issues and needs related to vulnerability`,
'some vulnerability',
)
await confirmAndSave(vulnerabilityPage)
await vulnerabilityPage.clickSave()
}

async function completeCurrentRisksPage(page: Page, name: string) {
Expand All @@ -171,7 +142,7 @@ async function completeCurrentRisksPage(page: Page, name: string) {
`Describe ${name}'s current issues and needs related to self harm and suicide`,
'some needs',
)
await confirmAndSave(currentRisksPage)
await currentRisksPage.clickSave()
}

async function completeHistoricalRisksPage(page: Page, name: string) {
Expand All @@ -181,7 +152,7 @@ async function completeHistoricalRisksPage(page: Page, name: string) {
`Describe ${name}'s historical issues and needs related to self harm and suicide`,
'some needs',
)
await confirmAndSave(historicalRisksPage)
await historicalRisksPage.clickSave()
}

async function addAnAcct(page: Page) {
Expand Down Expand Up @@ -213,50 +184,17 @@ export const completeRoshTask = async (page: Page, name: string) => {
const taskListPage = new TaskListPage(page)
await taskListPage.clickTask('Add risk of serious harm (RoSH) information')

await reviewRoshOasysImportPage(page, name)
await completeRoshSummaryPage(page, name)
await completeRiskToOthersPage(page)
await completeRiskToOthersPage(page, name)
await completeRiskManagementArrangementsPage(page, name)
await completeCellShareInformationPage(page, name)
await completeAdditionalRiskPage(page, name)
}

export const enterOldRoshOasysDate = async (page: Page, name: string) => {
const taskListPage = new TaskListPage(page)
await taskListPage.clickTask('Add risk of serious harm (RoSH) information')

await reviewRoshOasysImportPage(page, name)
await completeOldOasysRoshPage(page, name)
await returnToTaskList(page)
}

async function completeOldOasysRoshPage(page: Page, name: string) {
const oldOasysPage = await ApplyPage.initialize(
page,
`Does ${name} have an older OASys with risk of serious harm (RoSH) information? `,
)
await oldOasysPage.checkRadio('No')
await oldOasysPage.clickContinue()
}

async function returnToTaskList(page: Page) {
const applyPage = new TaskListPage(page)
await applyPage.clickLink('Back to task list')
}

async function reviewRoshOasysImportPage(page: Page, name: string) {
const guidancePage = await ApplyPage.initialize(page, `Import ${name}'s risk of serious harm (RoSH) data from OASys`)
await guidancePage.clickContinue()
}

async function completeRoshSummaryPage(page: Page, name: string) {
const summaryPage = await ApplyPage.initialize(page, `Risk of serious harm (RoSH) summary for ${name}`)
await summaryPage.clickSave()
}

async function completeRiskToOthersPage(page: Page) {
const riskToOthersPage = new TaskListPage(page)
await confirmAndSave(riskToOthersPage)
async function completeRiskToOthersPage(page: Page, name: string) {
const riskToOthersPage = await ApplyPage.initialize(page, `Risk to others for ${name}`)
await riskToOthersPage.fillField('Who is at risk?', 'a person')
await riskToOthersPage.fillField('What is the nature of the risk?', 'some details about the risk')
await riskToOthersPage.clickSave()
}

async function completeRiskManagementArrangementsPage(page: Page, name: string) {
Expand Down
10 changes: 0 additions & 10 deletions e2e-tests/tests/01_apply_as_pom.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
submitApplication,
viewSubmittedApplication,
addNote,
enterOldOasysDates,
viewInProgressDashboard,
createAnInProgressApplication,
} from '../steps/apply'
Expand Down Expand Up @@ -44,15 +43,6 @@ test('add a note to a submitted application', async ({ page, person, pomUser })
await expect(page.locator('.moj-timeline__title').first()).toContainText('Note')
})

test('create a CAS-2 application with no OASys', async ({ page, personWithoutOasys, pomUser }) => {
await signIn(page, pomUser)
await startAnApplication(page)
await enterPrisonerNumber(page, personWithoutOasys.nomsNumber)
await confirmApplicant(page)
await completeBeforeYouStartSection(page, personWithoutOasys.name)
await enterOldOasysDates(page, personWithoutOasys.name)
})

test('cancel an in progress application from the task list', async ({ page, pomUser, person }) => {
await signIn(page, pomUser)
await createAnInProgressApplication(page, person)
Expand Down

0 comments on commit fb84102

Please sign in to comment.