Skip to content

Commit

Permalink
Merge pull request #45 from ministryofjustice/CBA-71-remove-oa-sys-im…
Browse files Browse the repository at this point in the history
…port-pages

CBA-71 - remove OASys import pages
  • Loading branch information
patrickjfl authored Jan 7, 2025
2 parents 0806d8d + fb84102 commit 1eea7b1
Show file tree
Hide file tree
Showing 60 changed files with 62 additions and 2,689 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
25 changes: 1 addition & 24 deletions integration_tests/fixtures/applicationData.json
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,6 @@
}
},
"risk-to-self": {
"oasys-import": {
"oasysImportedDate": "2023-09-21T15:47:51.430Z",
"oasysStartedDate": "2023-09-10",
"oasysCompletedDate": "2023-09-11"
},
"current-risk": {
"currentRiskDetail": "[R8.1.1] Review 06.10.21:\r\n\r\n There have been numerous ACCTs opened since 2013 and every subsequent year he has been in custody. In 2021...",
"confirmation": "confirmed"
Expand Down Expand Up @@ -244,27 +239,9 @@
}
},
"risk-of-serious-harm": {
"oasys-import": { "oasysImportedDate": "2023-09-21T15:47:51.430Z" },
"summary-data": {
"oasysImportedDate": "2023-09-21T15:47:51.430Z",
"oasysStartedDate": "2023-09-10",
"oasysCompletedDate": "2023-09-11",
"status": "retrieved",
"value": {
"overallRisk": "High",
"riskToChildren": "High",
"riskToPublic": "Very High",
"riskToKnownAdult": "Medium",
"riskToStaff": "Low"
}
},
"summary": {
"additionalComments": "some rosh comments"
},
"risk-to-others": {
"whoIsAtRisk": "a person",
"natureOfRisk": "a nature",
"confirmation": "confirmed"
"natureOfRisk": "a nature"
},
"risk-management-arrangements": {
"arrangements": ["mappa", "marac", "iom"],
Expand Down
11 changes: 0 additions & 11 deletions server/@types/ui/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import { OASysRiskOfSeriousHarm } from '../shared/models/OASysRiskOfSeriousHarm'
import { OASysRiskToSelf } from '../shared/models/OASysRiskToSelf'
import { RoshRisksEnvelope } from '../shared/models/RoshRisksEnvelope'

export type JourneyType = 'applications'

export type UiTask = {
Expand Down Expand Up @@ -46,9 +42,6 @@ export type FormArtifact = Cas2Application
export type DataServices = Partial<{
personService: {
findByPrisonNumber: (token: string, prisonNumber: string) => Promise<Person>
getOasysRiskToSelf: (token: string, crn: string) => Promise<OASysRiskToSelf>
getOasysRosh: (token: string, crn: string) => Promise<OASysRiskOfSeriousHarm>
getRoshRisks: (token: string, crn: string) => Promise<RoshRisksEnvelope>
}
applicationService: {
findApplication: (token: string, id: string) => Promise<Cas2Application>
Expand Down Expand Up @@ -91,10 +84,6 @@ export type UserDetails = {
roles: Array<UserRole>
}

export type OasysImportArrays = ArrayOfOASysRiskOfSeriousHarmSummaryQuestions

export type RiskLevel = 'Low' | 'Medium' | 'High' | 'Very High'

export type TierNumber = '1' | '2' | '3' | '4'
export type TierLetter = 'A' | 'B' | 'C' | 'D'
export type RiskTierLevel = `${TierLetter}${TierNumber}`
Expand Down
86 changes: 1 addition & 85 deletions server/data/personClient.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import PersonClient from './personClient'
import { oasysRiskToSelfFactory, personFactory, oasysRoshFactory, risksFactory } from '../testutils/factories'
import paths from '../paths/api'
import { personFactory } from '../testutils/factories'

import describeClient from '../testutils/describeClient'

Expand All @@ -13,62 +12,6 @@ describeClient('PersonClient', provider => {
personClient = new PersonClient(token)
})

describe('oasysRiskToSelf', () => {
it('should return the Risk to Self data', async () => {
const crn = 'crn'
const oasysRiskToSelf = oasysRiskToSelfFactory.build()

provider.addInteraction({
state: 'Server is healthy',
uponReceiving: 'A request to get the optional selected sections of OASys for a person',
withRequest: {
method: 'GET',
path: paths.people.oasys.riskToSelf({ crn }),
query: {},
headers: {
authorization: `Bearer ${token}`,
},
},
willRespondWith: {
status: 200,
body: oasysRiskToSelf,
},
})

const result = await personClient.oasysRiskToSelf(crn)

expect(result).toEqual(oasysRiskToSelf)
})
})

describe('oasysRosh', () => {
it('should return the Rosh data', async () => {
const crn = 'crn'
const oasysRosh = oasysRoshFactory.build()

provider.addInteraction({
state: 'Server is healthy',
uponReceiving: 'A request to get the optional selected sections of OASys for a person',
withRequest: {
method: 'GET',
path: paths.people.oasys.rosh({ crn }),
query: {},
headers: {
authorization: `Bearer ${token}`,
},
},
willRespondWith: {
status: 200,
body: oasysRosh,
},
})

const result = await personClient.oasysRosh(crn)

expect(result).toEqual(oasysRosh)
})
})

describe('search', () => {
it('should return a person', async () => {
const person = personFactory.build()
Expand Down Expand Up @@ -97,31 +40,4 @@ describeClient('PersonClient', provider => {
expect(result).toEqual(person)
})
})

describe('risks', () => {
it('should return the risks for a person', async () => {
const crn = 'crn'
const risks = risksFactory.build()

provider.addInteraction({
state: 'Server is healthy',
uponReceiving: 'A request to get the risks for a person',
withRequest: {
method: 'GET',
path: `/cas2/people/${crn}/risks`,
headers: {
authorization: `Bearer ${token}`,
},
},
willRespondWith: {
status: 200,
body: risks,
},
})

const result = await personClient.risks(crn)

expect(result).toEqual(risks)
})
})
})
18 changes: 1 addition & 17 deletions server/data/personClient.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { FullPerson, OASysRiskOfSeriousHarm, OASysRiskToSelf, PersonRisks } from '@approved-premises/api'
import type { FullPerson, PersonRisks } from '@approved-premises/api'

import RestClient from './restClient'
import config, { ApiConfig } from '../config'
Expand All @@ -12,22 +12,6 @@ export default class PersonClient {
this.restClient = new RestClient('personClient', config.apis.approvedPremises as ApiConfig, token)
}

async oasysRiskToSelf(crn: string): Promise<OASysRiskToSelf> {
const path = paths.people.oasys.riskToSelf({ crn })

const response = (await this.restClient.get({ path })) as OASysRiskToSelf

return response
}

async oasysRosh(crn: string): Promise<OASysRiskOfSeriousHarm> {
const path = paths.people.oasys.rosh({ crn })

const response = (await this.restClient.get({ path })) as OASysRiskOfSeriousHarm

return response
}

async search(nomsNumber: string): Promise<FullPerson> {
const query = { nomsNumber } as Record<string, string | boolean>

Expand Down
Loading

0 comments on commit 1eea7b1

Please sign in to comment.