From c42a40e60e1b2e6012a15e8bd012ff8671d96c04 Mon Sep 17 00:00:00 2001 From: Daniel Liburd Date: Tue, 25 Feb 2025 13:02:58 +0000 Subject: [PATCH 01/17] Rename risk to self task We are combining risk to self and risk of serious harm (RoSH) tasks into one. This commit, removes the rendering of the RoSH task and renames the risk of self task. --- e2e-tests/steps/apply.ts | 3 +-- e2e-tests/steps/risksAndNeedsSection.ts | 2 +- integration_tests/fixtures/applicationData.json | 2 +- integration_tests/fixtures/applicationDocument.json | 2 +- server/form-pages/apply/risks-and-needs/index.ts | 5 ++--- .../{risk-to-self => risk-information}/acct.test.ts | 6 +++--- .../{risk-to-self => risk-information}/acct.ts | 6 +++--- .../additionalInformation.test.ts | 0 .../additionalInformation.ts | 2 +- .../currentRisk.test.ts | 0 .../{risk-to-self => risk-information}/currentRisk.ts | 2 +- .../custom-forms/acctData.test.ts | 0 .../custom-forms/acctData.ts | 4 ++-- .../historicalRisk.test.ts | 0 .../{risk-to-self => risk-information}/historicalRisk.ts | 2 +- .../{risk-to-self => risk-information}/index.ts | 4 ++-- .../vulnerability.test.ts | 0 .../{risk-to-self => risk-information}/vulnerability.ts | 2 +- server/form-pages/utils/questions.ts | 2 +- server/services/applicationService.test.ts | 2 +- server/utils/checkYourAnswersUtils.test.ts | 6 +++--- .../_risk-to-self-screen.njk | 8 ++++---- .../{risk-to-self => risk-information}/acct-data.njk | 2 +- .../pages/{risk-to-self => risk-information}/acct.njk | 2 +- .../additional-information.njk | 0 .../{risk-to-self => risk-information}/current-risk.njk | 0 .../historical-risk.njk | 0 .../{risk-to-self => risk-information}/vulnerability.njk | 0 28 files changed, 31 insertions(+), 33 deletions(-) rename server/form-pages/apply/risks-and-needs/{risk-to-self => risk-information}/acct.test.ts (95%) rename server/form-pages/apply/risks-and-needs/{risk-to-self => risk-information}/acct.ts (91%) rename server/form-pages/apply/risks-and-needs/{risk-to-self => risk-information}/additionalInformation.test.ts (100%) rename server/form-pages/apply/risks-and-needs/{risk-to-self => risk-information}/additionalInformation.ts (96%) rename server/form-pages/apply/risks-and-needs/{risk-to-self => risk-information}/currentRisk.test.ts (100%) rename server/form-pages/apply/risks-and-needs/{risk-to-self => risk-information}/currentRisk.ts (94%) rename server/form-pages/apply/risks-and-needs/{risk-to-self => risk-information}/custom-forms/acctData.test.ts (100%) rename server/form-pages/apply/risks-and-needs/{risk-to-self => risk-information}/custom-forms/acctData.ts (95%) rename server/form-pages/apply/risks-and-needs/{risk-to-self => risk-information}/historicalRisk.test.ts (100%) rename server/form-pages/apply/risks-and-needs/{risk-to-self => risk-information}/historicalRisk.ts (93%) rename server/form-pages/apply/risks-and-needs/{risk-to-self => risk-information}/index.ts (83%) rename server/form-pages/apply/risks-and-needs/{risk-to-self => risk-information}/vulnerability.test.ts (100%) rename server/form-pages/apply/risks-and-needs/{risk-to-self => risk-information}/vulnerability.ts (94%) rename server/views/applications/pages/{risk-to-self => risk-information}/_risk-to-self-screen.njk (85%) rename server/views/applications/pages/{risk-to-self => risk-information}/acct-data.njk (98%) rename server/views/applications/pages/{risk-to-self => risk-information}/acct.njk (97%) rename server/views/applications/pages/{risk-to-self => risk-information}/additional-information.njk (100%) rename server/views/applications/pages/{risk-to-self => risk-information}/current-risk.njk (100%) rename server/views/applications/pages/{risk-to-self => risk-information}/historical-risk.njk (100%) rename server/views/applications/pages/{risk-to-self => risk-information}/vulnerability.njk (100%) diff --git a/e2e-tests/steps/apply.ts b/e2e-tests/steps/apply.ts index bc632cf8..21c742ce 100644 --- a/e2e-tests/steps/apply.ts +++ b/e2e-tests/steps/apply.ts @@ -19,7 +19,7 @@ import { completeEqualityAndDiversityTask, completePersonalInformationTask, } from './aboutThePersonSection' -import { completeHealthNeedsTask, completeRiskToSelfTask, completeRoshTask } from './risksAndNeedsSection' +import { completeHealthNeedsTask, completeRiskToSelfTask } from './risksAndNeedsSection' import { completeAreaInformationTask, completeFundingInformationTask } from './areaAndFundingSection' import { completeAllegedOffencesTask, @@ -85,7 +85,6 @@ export const completeAboutThePersonSection = async (page: Page, name: string) => export const completeRisksAndNeedsSection = async (page: Page, name: string) => { await completeHealthNeedsTask(page, name) await completeRiskToSelfTask(page, name) - await completeRoshTask(page, name) } export const completeOffenceInformationSection = async (page: Page, name: string) => { diff --git a/e2e-tests/steps/risksAndNeedsSection.ts b/e2e-tests/steps/risksAndNeedsSection.ts index f5b6f924..2213da7f 100644 --- a/e2e-tests/steps/risksAndNeedsSection.ts +++ b/e2e-tests/steps/risksAndNeedsSection.ts @@ -125,7 +125,7 @@ async function completeOtherHealthPage(page: Page, name: string) { export const completeRiskToSelfTask = async (page: Page, name: string) => { const taskListPage = new TaskListPage(page) - await taskListPage.clickTask('Add risk to self information') + await taskListPage.clickTask('Add information about risks to the applicant and others') await completeVulnerabilityPage(page, name) await completeCurrentRisksPage(page, name) diff --git a/integration_tests/fixtures/applicationData.json b/integration_tests/fixtures/applicationData.json index 9333ab11..ffb352fb 100644 --- a/integration_tests/fixtures/applicationData.json +++ b/integration_tests/fixtures/applicationData.json @@ -208,7 +208,7 @@ "beingTreatedForCancer": "no" } }, - "risk-to-self": { + "risk-information": { "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" diff --git a/integration_tests/fixtures/applicationDocument.json b/integration_tests/fixtures/applicationDocument.json index 36cfc176..defe214b 100644 --- a/integration_tests/fixtures/applicationDocument.json +++ b/integration_tests/fixtures/applicationDocument.json @@ -247,7 +247,7 @@ ] }, { - "title": "Add risk to self information", + "title": "Add information about risks to the applicant and others", "questionsAndAnswers": [ { "question": "Describe Aadland Bertrand's current issues and needs related to self harm and suicide", diff --git a/server/form-pages/apply/risks-and-needs/index.ts b/server/form-pages/apply/risks-and-needs/index.ts index 6efacb27..494fc5f4 100644 --- a/server/form-pages/apply/risks-and-needs/index.ts +++ b/server/form-pages/apply/risks-and-needs/index.ts @@ -2,11 +2,10 @@ import { Section } from '../../utils/decorators' import HealthNeeds from './health-needs' -import RiskToSelf from './risk-to-self' -import RiskOfSeriousHarm from './risk-of-serious-harm' +import RiskInformation from './risk-information' @Section({ title: 'Risks and needs', - tasks: [HealthNeeds, RiskToSelf, RiskOfSeriousHarm], + tasks: [HealthNeeds, RiskInformation], }) export default class RisksAndNeeds {} diff --git a/server/form-pages/apply/risks-and-needs/risk-to-self/acct.test.ts b/server/form-pages/apply/risks-and-needs/risk-information/acct.test.ts similarity index 95% rename from server/form-pages/apply/risks-and-needs/risk-to-self/acct.test.ts rename to server/form-pages/apply/risks-and-needs/risk-information/acct.test.ts index b940808d..3203d302 100644 --- a/server/form-pages/apply/risks-and-needs/risk-to-self/acct.test.ts +++ b/server/form-pages/apply/risks-and-needs/risk-information/acct.test.ts @@ -19,7 +19,7 @@ describe('Acct', () => { const applicationWithData = applicationFactory.build({ person: personFactory.build({ name: 'Roger Smith' }), data: { - 'risk-to-self': { + 'risk-information': { 'acct-data': [ { referringInstitution: 'institution', @@ -53,7 +53,7 @@ describe('Acct', () => { acctDetails: 'detail info', closedDate: '10 October 2013', createdDate: '1 February 2012', - removeLink: `/applications/${applicationWithData.id}/tasks/risk-to-self/pages/acct-data/0/removeFromList?redirectPage=acct`, + removeLink: `/applications/${applicationWithData.id}/tasks/risk-information/pages/acct-data/0/removeFromList?redirectPage=acct`, title: '1 February 2012 - 10 October 2013', }, { @@ -61,7 +61,7 @@ describe('Acct', () => { acctDetails: 'detail info 2', closedDate: false, createdDate: '2 March 2012', - removeLink: `/applications/${applicationWithData.id}/tasks/risk-to-self/pages/acct-data/1/removeFromList?redirectPage=acct`, + removeLink: `/applications/${applicationWithData.id}/tasks/risk-information/pages/acct-data/1/removeFromList?redirectPage=acct`, title: '2 March 2012 - Ongoing', }, ]) diff --git a/server/form-pages/apply/risks-and-needs/risk-to-self/acct.ts b/server/form-pages/apply/risks-and-needs/risk-information/acct.ts similarity index 91% rename from server/form-pages/apply/risks-and-needs/risk-to-self/acct.ts rename to server/form-pages/apply/risks-and-needs/risk-information/acct.ts index cab3eeca..8f4beb49 100644 --- a/server/form-pages/apply/risks-and-needs/risk-to-self/acct.ts +++ b/server/form-pages/apply/risks-and-needs/risk-information/acct.ts @@ -34,8 +34,8 @@ export default class Acct implements TaskListPage { body: Partial, private readonly application: Application, ) { - if (application.data['risk-to-self'] && application.data['risk-to-self']['acct-data']) { - const acctData = application.data['risk-to-self']['acct-data'] as [AcctDataBody] + if (application.data['risk-information'] && application.data['risk-information']['acct-data']) { + const acctData = application.data['risk-information']['acct-data'] as [AcctDataBody] this.accts = acctData.map((acct, index) => { const query = { @@ -53,7 +53,7 @@ export default class Acct implements TaskListPage { closedDate, removeLink: `${paths.applications.removeFromList({ id: application.id, - task: 'risk-to-self', + task: 'risk-information', page: 'acct-data', index: index.toString(), })}?${createQueryString(query)}`, diff --git a/server/form-pages/apply/risks-and-needs/risk-to-self/additionalInformation.test.ts b/server/form-pages/apply/risks-and-needs/risk-information/additionalInformation.test.ts similarity index 100% rename from server/form-pages/apply/risks-and-needs/risk-to-self/additionalInformation.test.ts rename to server/form-pages/apply/risks-and-needs/risk-information/additionalInformation.test.ts diff --git a/server/form-pages/apply/risks-and-needs/risk-to-self/additionalInformation.ts b/server/form-pages/apply/risks-and-needs/risk-information/additionalInformation.ts similarity index 96% rename from server/form-pages/apply/risks-and-needs/risk-to-self/additionalInformation.ts rename to server/form-pages/apply/risks-and-needs/risk-information/additionalInformation.ts index 694c770e..fc1f84bb 100644 --- a/server/form-pages/apply/risks-and-needs/risk-to-self/additionalInformation.ts +++ b/server/form-pages/apply/risks-and-needs/risk-information/additionalInformation.ts @@ -16,7 +16,7 @@ export default class AdditionalInformation implements TaskListPage { documentTitle = this.title - questions = getQuestions(nameOrPlaceholderCopy(this.application.person))['risk-to-self']['additional-information'] + questions = getQuestions(nameOrPlaceholderCopy(this.application.person))['risk-information']['additional-information'] body: AdditionalInformationBody diff --git a/server/form-pages/apply/risks-and-needs/risk-to-self/currentRisk.test.ts b/server/form-pages/apply/risks-and-needs/risk-information/currentRisk.test.ts similarity index 100% rename from server/form-pages/apply/risks-and-needs/risk-to-self/currentRisk.test.ts rename to server/form-pages/apply/risks-and-needs/risk-information/currentRisk.test.ts diff --git a/server/form-pages/apply/risks-and-needs/risk-to-self/currentRisk.ts b/server/form-pages/apply/risks-and-needs/risk-information/currentRisk.ts similarity index 94% rename from server/form-pages/apply/risks-and-needs/risk-to-self/currentRisk.ts rename to server/form-pages/apply/risks-and-needs/risk-information/currentRisk.ts index c628b7ff..a47de932 100644 --- a/server/form-pages/apply/risks-and-needs/risk-to-self/currentRisk.ts +++ b/server/form-pages/apply/risks-and-needs/risk-information/currentRisk.ts @@ -18,7 +18,7 @@ export default class CurrentRisk implements TaskListPage { title = `${this.personName}'s current risks` - questions = getQuestions(this.personName)['risk-to-self']['current-risk'] + questions = getQuestions(this.personName)['risk-information']['current-risk'] body: CurrentRiskBody diff --git a/server/form-pages/apply/risks-and-needs/risk-to-self/custom-forms/acctData.test.ts b/server/form-pages/apply/risks-and-needs/risk-information/custom-forms/acctData.test.ts similarity index 100% rename from server/form-pages/apply/risks-and-needs/risk-to-self/custom-forms/acctData.test.ts rename to server/form-pages/apply/risks-and-needs/risk-information/custom-forms/acctData.test.ts diff --git a/server/form-pages/apply/risks-and-needs/risk-to-self/custom-forms/acctData.ts b/server/form-pages/apply/risks-and-needs/risk-information/custom-forms/acctData.ts similarity index 95% rename from server/form-pages/apply/risks-and-needs/risk-to-self/custom-forms/acctData.ts rename to server/form-pages/apply/risks-and-needs/risk-information/custom-forms/acctData.ts index 0d8b1bed..abadb2e0 100644 --- a/server/form-pages/apply/risks-and-needs/risk-to-self/custom-forms/acctData.ts +++ b/server/form-pages/apply/risks-and-needs/risk-information/custom-forms/acctData.ts @@ -40,9 +40,9 @@ export default class AcctData implements TaskListPage { body: AcctDataBody - questions = getQuestions('')['risk-to-self']['acct-data'] + questions = getQuestions('')['risk-information']['acct-data'] - taskName = 'risk-to-self' + taskName = 'risk-information' pageName = 'acct-data' diff --git a/server/form-pages/apply/risks-and-needs/risk-to-self/historicalRisk.test.ts b/server/form-pages/apply/risks-and-needs/risk-information/historicalRisk.test.ts similarity index 100% rename from server/form-pages/apply/risks-and-needs/risk-to-self/historicalRisk.test.ts rename to server/form-pages/apply/risks-and-needs/risk-information/historicalRisk.test.ts diff --git a/server/form-pages/apply/risks-and-needs/risk-to-self/historicalRisk.ts b/server/form-pages/apply/risks-and-needs/risk-information/historicalRisk.ts similarity index 93% rename from server/form-pages/apply/risks-and-needs/risk-to-self/historicalRisk.ts rename to server/form-pages/apply/risks-and-needs/risk-information/historicalRisk.ts index b6ff3faf..23277cff 100644 --- a/server/form-pages/apply/risks-and-needs/risk-to-self/historicalRisk.ts +++ b/server/form-pages/apply/risks-and-needs/risk-information/historicalRisk.ts @@ -18,7 +18,7 @@ export default class HistoricalRisk implements TaskListPage { title = `${this.personName}'s historical risks` - questions = getQuestions(this.personName)['risk-to-self']['historical-risk'] + questions = getQuestions(this.personName)['risk-information']['historical-risk'] body: HistoricalRiskBody diff --git a/server/form-pages/apply/risks-and-needs/risk-to-self/index.ts b/server/form-pages/apply/risks-and-needs/risk-information/index.ts similarity index 83% rename from server/form-pages/apply/risks-and-needs/risk-to-self/index.ts rename to server/form-pages/apply/risks-and-needs/risk-information/index.ts index f43cfa6c..d3292fae 100644 --- a/server/form-pages/apply/risks-and-needs/risk-to-self/index.ts +++ b/server/form-pages/apply/risks-and-needs/risk-information/index.ts @@ -9,8 +9,8 @@ import HistoricalRisk from './historicalRisk' import Vulnerability from './vulnerability' @Task({ - name: 'Add risk to self information', - slug: 'risk-to-self', + name: 'Add information about risks to the applicant and others', + slug: 'risk-information', pages: [Vulnerability, CurrentRisk, HistoricalRisk, AcctData, Acct, AdditionalInformation], }) export default class RiskToSelf {} diff --git a/server/form-pages/apply/risks-and-needs/risk-to-self/vulnerability.test.ts b/server/form-pages/apply/risks-and-needs/risk-information/vulnerability.test.ts similarity index 100% rename from server/form-pages/apply/risks-and-needs/risk-to-self/vulnerability.test.ts rename to server/form-pages/apply/risks-and-needs/risk-information/vulnerability.test.ts diff --git a/server/form-pages/apply/risks-and-needs/risk-to-self/vulnerability.ts b/server/form-pages/apply/risks-and-needs/risk-information/vulnerability.ts similarity index 94% rename from server/form-pages/apply/risks-and-needs/risk-to-self/vulnerability.ts rename to server/form-pages/apply/risks-and-needs/risk-information/vulnerability.ts index 32d74788..7296b444 100644 --- a/server/form-pages/apply/risks-and-needs/risk-to-self/vulnerability.ts +++ b/server/form-pages/apply/risks-and-needs/risk-information/vulnerability.ts @@ -18,7 +18,7 @@ export default class Vulnerability implements TaskListPage { title = `${this.personName}'s vulnerability` - questions = getQuestions(this.personName)['risk-to-self'].vulnerability + questions = getQuestions(this.personName)['risk-information'].vulnerability body: VulnerabilityBody diff --git a/server/form-pages/utils/questions.ts b/server/form-pages/utils/questions.ts index fb962fc6..5dc1b3b0 100644 --- a/server/form-pages/utils/questions.ts +++ b/server/form-pages/utils/questions.ts @@ -661,7 +661,7 @@ export const getQuestions = (name: string) => { }, }, }, - 'risk-to-self': { + 'risk-information': { vulnerability: { vulnerabilityDetail: { question: `Describe ${name}'s current circumstances, issues and needs related to vulnerability`, diff --git a/server/services/applicationService.test.ts b/server/services/applicationService.test.ts index e84bffae..ce1e7e53 100644 --- a/server/services/applicationService.test.ts +++ b/server/services/applicationService.test.ts @@ -714,7 +714,7 @@ describe('ApplicationService', () => { const applicationData = createMock() ;(getApplicationUpdateData as jest.Mock).mockReturnValue(applicationData) - const newApplicationData = { 'risk-to-self': { vulnerability: { vulnerabilityDetail: 'example' } } } + const newApplicationData = { 'risk-information': { vulnerability: { vulnerabilityDetail: 'example' } } } await service.saveData(newApplicationData, request) diff --git a/server/utils/checkYourAnswersUtils.test.ts b/server/utils/checkYourAnswersUtils.test.ts index 9ca9aa5f..fd6fb402 100644 --- a/server/utils/checkYourAnswersUtils.test.ts +++ b/server/utils/checkYourAnswersUtils.test.ts @@ -464,7 +464,7 @@ describe('checkYourAnswersUtils', () => { acctDetails: 'ACCT details\nsome more details on another line', } - expect(getAnswer(application, questions, 'risk-to-self', 'acct-data', '0')).toEqual(expected) + expect(getAnswer(application, questions, 'risk-information', 'acct-data', '0')).toEqual(expected) }) it('returns the answer string by default', () => { @@ -519,8 +519,8 @@ describe('checkYourAnswersUtils', () => { }) describe('getKeysForPages', () => { - it('returns an array of page keys for risk to self', () => { - expect(getKeysForPages(application, 'risk-to-self')).toEqual([ + it('returns an array of page keys for risk information', () => { + expect(getKeysForPages(application, 'risk-information')).toEqual([ 'current-risk', 'vulnerability', 'historical-risk', diff --git a/server/views/applications/pages/risk-to-self/_risk-to-self-screen.njk b/server/views/applications/pages/risk-information/_risk-to-self-screen.njk similarity index 85% rename from server/views/applications/pages/risk-to-self/_risk-to-self-screen.njk rename to server/views/applications/pages/risk-information/_risk-to-self-screen.njk index 92c50e66..45b4daef 100644 --- a/server/views/applications/pages/risk-to-self/_risk-to-self-screen.njk +++ b/server/views/applications/pages/risk-information/_risk-to-self-screen.njk @@ -16,19 +16,19 @@ {{ mojSideNavigation({ items: [{ text: 'Vulnerability', - href: paths.applications.pages.show({ id: applicationId, task: 'risk-to-self', page: 'vulnerability' }), + href: paths.applications.pages.show({ id: applicationId, task: 'risk-information', page: 'vulnerability' }), active: (pageName === 'vulnerability') }, { text: 'Current risk', - href: paths.applications.pages.show({ id: applicationId, task: 'risk-to-self', page: 'current-risk' }), + href: paths.applications.pages.show({ id: applicationId, task: 'risk-information', page: 'current-risk' }), active: (pageName === 'current-risk') }, { text: 'Historical risk', - href: paths.applications.pages.show({ id: applicationId, task: 'risk-to-self', page: 'historical-risk' }), + href: paths.applications.pages.show({ id: applicationId, task: 'risk-information', page: 'historical-risk' }), active: (pageName === 'historical-risk') }, { text: 'ACCT', - href: paths.applications.pages.show({ id: applicationId, task: 'risk-to-self', page: 'acct' }), + href: paths.applications.pages.show({ id: applicationId, task: 'risk-information', page: 'acct' }), active: (pageName === 'acct') }] }) }} diff --git a/server/views/applications/pages/risk-to-self/acct-data.njk b/server/views/applications/pages/risk-information/acct-data.njk similarity index 98% rename from server/views/applications/pages/risk-to-self/acct-data.njk rename to server/views/applications/pages/risk-information/acct-data.njk index a37bab68..3c07ede2 100644 --- a/server/views/applications/pages/risk-to-self/acct-data.njk +++ b/server/views/applications/pages/risk-information/acct-data.njk @@ -133,7 +133,7 @@ text: "Save and add ACCT" }) }} - + Cancel diff --git a/server/views/applications/pages/risk-to-self/acct.njk b/server/views/applications/pages/risk-information/acct.njk similarity index 97% rename from server/views/applications/pages/risk-to-self/acct.njk rename to server/views/applications/pages/risk-information/acct.njk index 436a41c5..9b1aa5d9 100644 --- a/server/views/applications/pages/risk-to-self/acct.njk +++ b/server/views/applications/pages/risk-information/acct.njk @@ -57,7 +57,7 @@ {{ govukButton({ text: "Add an ACCT note", classes: "govuk-button--secondary", - href: paths.applications.pages.show({ id: applicationId, task: 'risk-to-self', page: 'acct-data' }) + href: paths.applications.pages.show({ id: applicationId, task: 'risk-information', page: 'acct-data' }) }) }} diff --git a/server/views/applications/pages/risk-to-self/additional-information.njk b/server/views/applications/pages/risk-information/additional-information.njk similarity index 100% rename from server/views/applications/pages/risk-to-self/additional-information.njk rename to server/views/applications/pages/risk-information/additional-information.njk diff --git a/server/views/applications/pages/risk-to-self/current-risk.njk b/server/views/applications/pages/risk-information/current-risk.njk similarity index 100% rename from server/views/applications/pages/risk-to-self/current-risk.njk rename to server/views/applications/pages/risk-information/current-risk.njk diff --git a/server/views/applications/pages/risk-to-self/historical-risk.njk b/server/views/applications/pages/risk-information/historical-risk.njk similarity index 100% rename from server/views/applications/pages/risk-to-self/historical-risk.njk rename to server/views/applications/pages/risk-information/historical-risk.njk diff --git a/server/views/applications/pages/risk-to-self/vulnerability.njk b/server/views/applications/pages/risk-information/vulnerability.njk similarity index 100% rename from server/views/applications/pages/risk-to-self/vulnerability.njk rename to server/views/applications/pages/risk-information/vulnerability.njk From 8427d666d93ff247aa413c3fb78995814db7e649 Mon Sep 17 00:00:00 2001 From: Daniel Liburd Date: Wed, 26 Feb 2025 16:49:22 +0000 Subject: [PATCH 02/17] Rename risk to self screen This template renders the side nav for risk information page --- .../{_risk-to-self-screen.njk => _risk-information-screen.njk} | 0 server/views/applications/pages/risk-information/acct.njk | 2 +- .../views/applications/pages/risk-information/current-risk.njk | 2 +- .../applications/pages/risk-information/historical-risk.njk | 2 +- .../views/applications/pages/risk-information/vulnerability.njk | 2 +- 5 files changed, 4 insertions(+), 4 deletions(-) rename server/views/applications/pages/risk-information/{_risk-to-self-screen.njk => _risk-information-screen.njk} (100%) diff --git a/server/views/applications/pages/risk-information/_risk-to-self-screen.njk b/server/views/applications/pages/risk-information/_risk-information-screen.njk similarity index 100% rename from server/views/applications/pages/risk-information/_risk-to-self-screen.njk rename to server/views/applications/pages/risk-information/_risk-information-screen.njk diff --git a/server/views/applications/pages/risk-information/acct.njk b/server/views/applications/pages/risk-information/acct.njk index 9b1aa5d9..8ac50401 100644 --- a/server/views/applications/pages/risk-information/acct.njk +++ b/server/views/applications/pages/risk-information/acct.njk @@ -1,5 +1,5 @@ {% from "govuk/components/summary-list/macro.njk" import govukSummaryList %} -{% extends "./_risk-to-self-screen.njk" %} +{% extends "./_risk-information-screen.njk" %} {% set pageName = "acct" %} {% block questions %} diff --git a/server/views/applications/pages/risk-information/current-risk.njk b/server/views/applications/pages/risk-information/current-risk.njk index 2db2784f..520e37b1 100644 --- a/server/views/applications/pages/risk-information/current-risk.njk +++ b/server/views/applications/pages/risk-information/current-risk.njk @@ -1,6 +1,6 @@ {% from "govuk/components/inset-text/macro.njk" import govukInsetText %} -{% extends "./_risk-to-self-screen.njk" %} +{% extends "./_risk-information-screen.njk" %} {% set pageName = "current-risk" %} diff --git a/server/views/applications/pages/risk-information/historical-risk.njk b/server/views/applications/pages/risk-information/historical-risk.njk index c88817c5..f6ba2483 100644 --- a/server/views/applications/pages/risk-information/historical-risk.njk +++ b/server/views/applications/pages/risk-information/historical-risk.njk @@ -1,6 +1,6 @@ {% from "govuk/components/inset-text/macro.njk" import govukInsetText %} -{% extends "./_risk-to-self-screen.njk" %} +{% extends "./_risk-information-screen.njk" %} {% set pageName = "historical-risk" %} diff --git a/server/views/applications/pages/risk-information/vulnerability.njk b/server/views/applications/pages/risk-information/vulnerability.njk index 6c138e6e..1709bf65 100644 --- a/server/views/applications/pages/risk-information/vulnerability.njk +++ b/server/views/applications/pages/risk-information/vulnerability.njk @@ -1,5 +1,5 @@ {% from "govuk/components/inset-text/macro.njk" import govukInsetText %} -{% extends "./_risk-to-self-screen.njk" %} +{% extends "./_risk-information-screen.njk" %} {% set pageName = "vulnerability" %} From a2e66d9986895ddcb112fba80932b5823cbeb1e8 Mon Sep 17 00:00:00 2001 From: Daniel Liburd Date: Wed, 26 Feb 2025 17:03:55 +0000 Subject: [PATCH 03/17] Remove existing risk pages We'll be adding new pages to this task, so remove existing pages in preparation. The Acct page is kept for 2 reasons: 1. Each task requires at least one page to present for the task list to render 2. We will be reusing the Acct page in the new design. --- .../apply/risks-and-needs/risk-information/index.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/server/form-pages/apply/risks-and-needs/risk-information/index.ts b/server/form-pages/apply/risks-and-needs/risk-information/index.ts index d3292fae..4ca66d07 100644 --- a/server/form-pages/apply/risks-and-needs/risk-information/index.ts +++ b/server/form-pages/apply/risks-and-needs/risk-information/index.ts @@ -1,16 +1,11 @@ /* istanbul ignore file */ +import Acct from './acct' import { Task } from '../../../utils/decorators' -import Acct from './acct' -import AcctData from './custom-forms/acctData' -import AdditionalInformation from './additionalInformation' -import CurrentRisk from './currentRisk' -import HistoricalRisk from './historicalRisk' -import Vulnerability from './vulnerability' @Task({ name: 'Add information about risks to the applicant and others', slug: 'risk-information', - pages: [Vulnerability, CurrentRisk, HistoricalRisk, AcctData, Acct, AdditionalInformation], + pages: [Acct], }) export default class RiskToSelf {} From 078673e1553496fac4a033b86549db47e9de7c6f Mon Sep 17 00:00:00 2001 From: Daniel Liburd Date: Tue, 25 Feb 2025 13:48:28 +0000 Subject: [PATCH 04/17] Add page names to side navigation These are the names of the pages we'll be adding in following commits. --- .../_risk-information-screen.njk | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/server/views/applications/pages/risk-information/_risk-information-screen.njk b/server/views/applications/pages/risk-information/_risk-information-screen.njk index 45b4daef..4492f7e4 100644 --- a/server/views/applications/pages/risk-information/_risk-information-screen.njk +++ b/server/views/applications/pages/risk-information/_risk-information-screen.njk @@ -15,21 +15,29 @@
{{ mojSideNavigation({ items: [{ - text: 'Vulnerability', - href: paths.applications.pages.show({ id: applicationId, task: 'risk-information', page: 'vulnerability' }), - active: (pageName === 'vulnerability') + text: 'Add information about concerns', + href: paths.applications.pages.show({ id: applicationId, task: 'risk-information', page: 'concerns' }), + active: (pageName === 'concerns') }, { - text: 'Current risk', - href: paths.applications.pages.show({ id: applicationId, task: 'risk-information', page: 'current-risk' }), - active: (pageName === 'current-risk') - }, { - text: 'Historical risk', - href: paths.applications.pages.show({ id: applicationId, task: 'risk-information', page: 'historical-risk' }), - active: (pageName === 'historical-risk') + text: 'Self-harm and suicide', + href: paths.applications.pages.show({ id: applicationId, task: 'risk-information', page: 'self-harm' }), + active: (pageName === 'self-harm') }, { text: 'ACCT', href: paths.applications.pages.show({ id: applicationId, task: 'risk-information', page: 'acct' }), active: (pageName === 'acct') + }, { + text: 'Violence and arson', + href: paths.applications.pages.show({ id: applicationId, task: 'risk-information', page: 'violence-and-arson' }), + active: (pageName === 'violence-and-arson') + }, { + text: 'Risks to staff', + href: paths.applications.pages.show({ id: applicationId, task: 'risk-information', page: 'risks-to-staff' }), + active: (pageName === 'risks-to-staff') + }, { + text: 'Additional concerns', + href: paths.applications.pages.show({ id: applicationId, task: 'risk-information', page: 'additional-concerns' }), + active: (pageName === 'additional-concerns') }] }) }}
From 5d3db72afe6b4e3f91c3d67c4de7415bcccde267 Mon Sep 17 00:00:00 2001 From: Daniel Liburd Date: Thu, 27 Feb 2025 11:20:50 +0000 Subject: [PATCH 05/17] Update application data integration test fixture Update with the new page structure. --- .../fixtures/applicationData.json | 23 +++++-------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/integration_tests/fixtures/applicationData.json b/integration_tests/fixtures/applicationData.json index ffb352fb..e8870ab5 100644 --- a/integration_tests/fixtures/applicationData.json +++ b/integration_tests/fixtures/applicationData.json @@ -209,18 +209,11 @@ } }, "risk-information": { - "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" - }, - "vulnerability": { - "vulnerabilityDetail": "example answer vulnerability", - "confirmation": "confirmed" - }, - "historical-risk": { - "historicalRiskDetail": "example answer historical risk", - "confirmation": "confirmed" - }, + "concerns": {}, + "self-harm": {}, + "violence-and-arson": {}, + "risks-to-staff": {}, + "additional-concerns": {}, "acct": {}, "acct-data": [ { @@ -242,11 +235,7 @@ "referringInstitution": "HMPPS prison 2", "acctDetails": "ACCT details 2" } - ], - "additional-information": { - "hasAdditionalInformation": "yes", - "additionalInformationDetail": "some information" - } + ] }, "risk-of-serious-harm": { "risk-to-others": { From 435218aba9205eb3a7bc2e0ac5c407816a7e35d5 Mon Sep 17 00:00:00 2001 From: Daniel Liburd Date: Tue, 25 Feb 2025 13:07:05 +0000 Subject: [PATCH 06/17] Introduce concerns form page --- .../risk-information/concernsPage.ts | 8 ++++ .../complete_concerns_page.cy.ts | 46 +++++++++++++++++++ .../risk-information/concerns.test.ts | 18 ++++++++ .../risk-information/concerns.ts | 46 +++++++++++++++++++ .../risks-and-needs/risk-information/index.ts | 3 +- server/form-pages/utils/questions.ts | 1 + .../pages/risk-information/concerns.njk | 5 ++ 7 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 integration_tests/pages/apply/risks-and-needs/risk-information/concernsPage.ts create mode 100644 integration_tests/tests/apply/risks-and-needs/risk-information/complete_concerns_page.cy.ts create mode 100644 server/form-pages/apply/risks-and-needs/risk-information/concerns.test.ts create mode 100644 server/form-pages/apply/risks-and-needs/risk-information/concerns.ts create mode 100644 server/views/applications/pages/risk-information/concerns.njk diff --git a/integration_tests/pages/apply/risks-and-needs/risk-information/concernsPage.ts b/integration_tests/pages/apply/risks-and-needs/risk-information/concernsPage.ts new file mode 100644 index 00000000..682ade14 --- /dev/null +++ b/integration_tests/pages/apply/risks-and-needs/risk-information/concernsPage.ts @@ -0,0 +1,8 @@ +import { Cas2v2Application as Application } from '@approved-premises/api' +import ApplyPage from '../../applyPage' + +export default class ConcernsPage extends ApplyPage { + constructor(private readonly application: Application) { + super('Concerns', application, 'risk-information', 'concerns') + } +} diff --git a/integration_tests/tests/apply/risks-and-needs/risk-information/complete_concerns_page.cy.ts b/integration_tests/tests/apply/risks-and-needs/risk-information/complete_concerns_page.cy.ts new file mode 100644 index 00000000..4850e345 --- /dev/null +++ b/integration_tests/tests/apply/risks-and-needs/risk-information/complete_concerns_page.cy.ts @@ -0,0 +1,46 @@ +// Feature: complete concerns information page +// + +import ConcernsPage from '../../../../pages/apply/risks-and-needs/risk-information/concernsPage' +import Page from '../../../../pages/page' +import { personFactory, applicationFactory } from '../../../../../server/testutils/factories/index' + +context('Complete "Concerns" page', () => { + const person = personFactory.build({ name: 'Roger Smith' }) + + beforeEach(function test() { + cy.task('reset') + cy.task('stubSignIn') + cy.task('stubAuthUser') + + cy.fixture('applicationData.json').then(applicationData => { + applicationData['risk-information'] = {} + const application = applicationFactory.build({ + id: 'abc123', + person, + }) + application.data = applicationData + cy.wrap(application).as('application') + cy.wrap(application.data).as('applicationData') + }) + }) + + beforeEach(function test() { + // And an application exists + cy.task('stubApplicationGet', { application: this.application }) + cy.task('stubApplicationUpdate', { application: this.application }) + + // Given I am logged in + //--------------------- + cy.signIn() + + // And I visit the Concerns page + // -------------------------------- + cy.visit('applications/abc123/tasks/risk-information/pages/concerns') + }) + + it('exists', function test() { + // Given I am on the Concerns page + Page.verifyOnPage(ConcernsPage, this.application) + }) +}) diff --git a/server/form-pages/apply/risks-and-needs/risk-information/concerns.test.ts b/server/form-pages/apply/risks-and-needs/risk-information/concerns.test.ts new file mode 100644 index 00000000..ea4d8c26 --- /dev/null +++ b/server/form-pages/apply/risks-and-needs/risk-information/concerns.test.ts @@ -0,0 +1,18 @@ +import { itShouldHaveNextValue, itShouldHavePreviousValue } from '../../../shared-examples' +import { personFactory, applicationFactory } from '../../../../testutils/factories/index' +import Concerns from './concerns' + +describe('Concerns', () => { + const application = applicationFactory.build({ person: personFactory.build({ name: 'Roger Smith' }) }) + + describe('title', () => { + it('adds the page title', () => { + const page = new Concerns({}, application) + + expect(page.title).toEqual('Concerns') + }) + }) + + itShouldHaveNextValue(new Concerns({}, application), 'self-harm') + itShouldHavePreviousValue(new Concerns({}, application), '') +}) diff --git a/server/form-pages/apply/risks-and-needs/risk-information/concerns.ts b/server/form-pages/apply/risks-and-needs/risk-information/concerns.ts new file mode 100644 index 00000000..2289bb10 --- /dev/null +++ b/server/form-pages/apply/risks-and-needs/risk-information/concerns.ts @@ -0,0 +1,46 @@ +import type { TaskListErrors } from '@approved-premises/ui' +import { Cas2v2Application as Application } from '@approved-premises/api' +import { nameOrPlaceholderCopy } from '../../../../utils/utils' +import { Page } from '../../../utils/decorators' +import TaskListPage from '../../../taskListPage' +import { getQuestions } from '../../../utils/questions' + +// eslint-disable-next-line @typescript-eslint/no-empty-object-type +type ConcernsBody = {} + +@Page({ + name: 'concerns', + bodyProperties: [], +}) +export default class Concerns implements TaskListPage { + documentTitle = 'Concerns' + + personName = nameOrPlaceholderCopy(this.application.person) + + title = 'Concerns' + + questions = getQuestions(this.personName)['risk-information'].concerns + + body: ConcernsBody + + constructor( + body: Partial, + private readonly application: Application, + ) { + this.body = body as ConcernsBody + } + + previous() { + return '' + } + + next() { + return 'self-harm' + } + + errors() { + const errors: TaskListErrors = {} + + return errors + } +} diff --git a/server/form-pages/apply/risks-and-needs/risk-information/index.ts b/server/form-pages/apply/risks-and-needs/risk-information/index.ts index 4ca66d07..97e7deb2 100644 --- a/server/form-pages/apply/risks-and-needs/risk-information/index.ts +++ b/server/form-pages/apply/risks-and-needs/risk-information/index.ts @@ -1,4 +1,5 @@ /* istanbul ignore file */ +import Concerns from './concerns' import Acct from './acct' import { Task } from '../../../utils/decorators' @@ -6,6 +7,6 @@ import { Task } from '../../../utils/decorators' @Task({ name: 'Add information about risks to the applicant and others', slug: 'risk-information', - pages: [Acct], + pages: [Concerns, Acct], }) export default class RiskToSelf {} diff --git a/server/form-pages/utils/questions.ts b/server/form-pages/utils/questions.ts index 5dc1b3b0..1a2d2f24 100644 --- a/server/form-pages/utils/questions.ts +++ b/server/form-pages/utils/questions.ts @@ -662,6 +662,7 @@ export const getQuestions = (name: string) => { }, }, 'risk-information': { + concerns: {}, vulnerability: { vulnerabilityDetail: { question: `Describe ${name}'s current circumstances, issues and needs related to vulnerability`, diff --git a/server/views/applications/pages/risk-information/concerns.njk b/server/views/applications/pages/risk-information/concerns.njk new file mode 100644 index 00000000..abe3f950 --- /dev/null +++ b/server/views/applications/pages/risk-information/concerns.njk @@ -0,0 +1,5 @@ +{% extends "./_risk-information-screen.njk" %} +{% set pageName = "concerns" %} + +{% block questions %} +{% endblock %} From 8b29e78a66b715497c3a4a92de475838c73f5cec Mon Sep 17 00:00:00 2001 From: Daniel Liburd Date: Tue, 25 Feb 2025 14:41:59 +0000 Subject: [PATCH 07/17] Introduce self harm form page --- .../risk-information/selfHarmPage.ts | 8 ++++ .../complete_self_harm_page.cy.ts | 46 +++++++++++++++++++ .../risks-and-needs/risk-information/index.ts | 3 +- .../risk-information/selfHarm.test.ts | 18 ++++++++ .../risk-information/selfHarm.ts | 46 +++++++++++++++++++ server/form-pages/utils/questions.ts | 1 + .../pages/risk-information/self-harm.njk | 5 ++ 7 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 integration_tests/pages/apply/risks-and-needs/risk-information/selfHarmPage.ts create mode 100644 integration_tests/tests/apply/risks-and-needs/risk-information/complete_self_harm_page.cy.ts create mode 100644 server/form-pages/apply/risks-and-needs/risk-information/selfHarm.test.ts create mode 100644 server/form-pages/apply/risks-and-needs/risk-information/selfHarm.ts create mode 100644 server/views/applications/pages/risk-information/self-harm.njk diff --git a/integration_tests/pages/apply/risks-and-needs/risk-information/selfHarmPage.ts b/integration_tests/pages/apply/risks-and-needs/risk-information/selfHarmPage.ts new file mode 100644 index 00000000..2623ffe9 --- /dev/null +++ b/integration_tests/pages/apply/risks-and-needs/risk-information/selfHarmPage.ts @@ -0,0 +1,8 @@ +import { Cas2v2Application as Application } from '@approved-premises/api' +import ApplyPage from '../../applyPage' + +export default class SelfHarmPage extends ApplyPage { + constructor(private readonly application: Application) { + super('Self harm', application, 'risk-information', 'self-harm') + } +} diff --git a/integration_tests/tests/apply/risks-and-needs/risk-information/complete_self_harm_page.cy.ts b/integration_tests/tests/apply/risks-and-needs/risk-information/complete_self_harm_page.cy.ts new file mode 100644 index 00000000..30d492c8 --- /dev/null +++ b/integration_tests/tests/apply/risks-and-needs/risk-information/complete_self_harm_page.cy.ts @@ -0,0 +1,46 @@ +// Feature: complete self harm page +// + +import SelfHarmPage from '../../../../pages/apply/risks-and-needs/risk-information/selfHarmPage' +import Page from '../../../../pages/page' +import { personFactory, applicationFactory } from '../../../../../server/testutils/factories/index' + +context('Complete "Self harm" page', () => { + const person = personFactory.build({ name: 'Roger Smith' }) + + beforeEach(function test() { + cy.task('reset') + cy.task('stubSignIn') + cy.task('stubAuthUser') + + cy.fixture('applicationData.json').then(applicationData => { + applicationData['risk-information'] = {} + const application = applicationFactory.build({ + id: 'abc123', + person, + }) + application.data = applicationData + cy.wrap(application).as('application') + cy.wrap(application.data).as('applicationData') + }) + }) + + beforeEach(function test() { + // And an application exists + cy.task('stubApplicationGet', { application: this.application }) + cy.task('stubApplicationUpdate', { application: this.application }) + + // Given I am logged in + //--------------------- + cy.signIn() + + // And I visit the Self harm page + // -------------------------------- + cy.visit('applications/abc123/tasks/risk-information/pages/self-harm') + }) + + it('exists', function test() { + // Given I am on the Self harm page + Page.verifyOnPage(SelfHarmPage, this.application) + }) +}) diff --git a/server/form-pages/apply/risks-and-needs/risk-information/index.ts b/server/form-pages/apply/risks-and-needs/risk-information/index.ts index 97e7deb2..f6c7483a 100644 --- a/server/form-pages/apply/risks-and-needs/risk-information/index.ts +++ b/server/form-pages/apply/risks-and-needs/risk-information/index.ts @@ -1,5 +1,6 @@ /* istanbul ignore file */ import Concerns from './concerns' +import SelfHarm from './selfHarm' import Acct from './acct' import { Task } from '../../../utils/decorators' @@ -7,6 +8,6 @@ import { Task } from '../../../utils/decorators' @Task({ name: 'Add information about risks to the applicant and others', slug: 'risk-information', - pages: [Concerns, Acct], + pages: [Concerns, SelfHarm, Acct], }) export default class RiskToSelf {} diff --git a/server/form-pages/apply/risks-and-needs/risk-information/selfHarm.test.ts b/server/form-pages/apply/risks-and-needs/risk-information/selfHarm.test.ts new file mode 100644 index 00000000..746c7f2d --- /dev/null +++ b/server/form-pages/apply/risks-and-needs/risk-information/selfHarm.test.ts @@ -0,0 +1,18 @@ +import { itShouldHaveNextValue, itShouldHavePreviousValue } from '../../../shared-examples' +import { personFactory, applicationFactory } from '../../../../testutils/factories/index' +import SelfHarm from './selfHarm' + +describe('SelfHarm', () => { + const application = applicationFactory.build({ person: personFactory.build({ name: 'Roger Smith' }) }) + + describe('title', () => { + it('adds the page title', () => { + const page = new SelfHarm({}, application) + + expect(page.title).toEqual('Self harm') + }) + }) + + itShouldHaveNextValue(new SelfHarm({}, application), 'acct') + itShouldHavePreviousValue(new SelfHarm({}, application), 'concerns') +}) diff --git a/server/form-pages/apply/risks-and-needs/risk-information/selfHarm.ts b/server/form-pages/apply/risks-and-needs/risk-information/selfHarm.ts new file mode 100644 index 00000000..6a292ba4 --- /dev/null +++ b/server/form-pages/apply/risks-and-needs/risk-information/selfHarm.ts @@ -0,0 +1,46 @@ +import type { TaskListErrors } from '@approved-premises/ui' +import { Cas2v2Application as Application } from '@approved-premises/api' +import { nameOrPlaceholderCopy } from '../../../../utils/utils' +import { Page } from '../../../utils/decorators' +import TaskListPage from '../../../taskListPage' +import { getQuestions } from '../../../utils/questions' + +// eslint-disable-next-line @typescript-eslint/no-empty-object-type +type SelfHarmBody = {} + +@Page({ + name: 'self-harm', + bodyProperties: [], +}) +export default class SelfHarm implements TaskListPage { + documentTitle = 'Self harm' + + personName = nameOrPlaceholderCopy(this.application.person) + + title = 'Self harm' + + questions = getQuestions(this.personName)['risk-information']['self-harm'] + + body: SelfHarmBody + + constructor( + body: Partial, + private readonly application: Application, + ) { + this.body = body as SelfHarmBody + } + + previous() { + return 'concerns' + } + + next() { + return 'acct' + } + + errors() { + const errors: TaskListErrors = {} + + return errors + } +} diff --git a/server/form-pages/utils/questions.ts b/server/form-pages/utils/questions.ts index 1a2d2f24..2a56f388 100644 --- a/server/form-pages/utils/questions.ts +++ b/server/form-pages/utils/questions.ts @@ -663,6 +663,7 @@ export const getQuestions = (name: string) => { }, 'risk-information': { concerns: {}, + 'self-harm': {}, vulnerability: { vulnerabilityDetail: { question: `Describe ${name}'s current circumstances, issues and needs related to vulnerability`, diff --git a/server/views/applications/pages/risk-information/self-harm.njk b/server/views/applications/pages/risk-information/self-harm.njk new file mode 100644 index 00000000..a9517794 --- /dev/null +++ b/server/views/applications/pages/risk-information/self-harm.njk @@ -0,0 +1,5 @@ +{% extends "./_risk-information-screen.njk" %} +{% set pageName = "self-harm" %} + +{% block questions %} +{% endblock %} From df854f85ed9377b206f5141b24c64b3e249821e2 Mon Sep 17 00:00:00 2001 From: Daniel Liburd Date: Tue, 25 Feb 2025 16:52:39 +0000 Subject: [PATCH 08/17] Introduce violence and arson page --- .../risk-information/violenceAndArsonPage.ts | 8 ++++ .../complete_violence_and_arson_page.cy.ts | 46 +++++++++++++++++++ .../risks-and-needs/risk-information/index.ts | 3 +- .../risk-information/violenceAndArson.test.ts | 18 ++++++++ .../risk-information/violenceAndArson.ts | 46 +++++++++++++++++++ server/form-pages/utils/questions.ts | 1 + .../risk-information/violence-and-arson.njk | 5 ++ 7 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 integration_tests/pages/apply/risks-and-needs/risk-information/violenceAndArsonPage.ts create mode 100644 integration_tests/tests/apply/risks-and-needs/risk-information/complete_violence_and_arson_page.cy.ts create mode 100644 server/form-pages/apply/risks-and-needs/risk-information/violenceAndArson.test.ts create mode 100644 server/form-pages/apply/risks-and-needs/risk-information/violenceAndArson.ts create mode 100644 server/views/applications/pages/risk-information/violence-and-arson.njk diff --git a/integration_tests/pages/apply/risks-and-needs/risk-information/violenceAndArsonPage.ts b/integration_tests/pages/apply/risks-and-needs/risk-information/violenceAndArsonPage.ts new file mode 100644 index 00000000..06cd4c31 --- /dev/null +++ b/integration_tests/pages/apply/risks-and-needs/risk-information/violenceAndArsonPage.ts @@ -0,0 +1,8 @@ +import { Cas2v2Application as Application } from '@approved-premises/api' +import ApplyPage from '../../applyPage' + +export default class ViolenceAndArsonPage extends ApplyPage { + constructor(private readonly application: Application) { + super('Violence and arson', application, 'risk-information', 'violence-and-arson') + } +} diff --git a/integration_tests/tests/apply/risks-and-needs/risk-information/complete_violence_and_arson_page.cy.ts b/integration_tests/tests/apply/risks-and-needs/risk-information/complete_violence_and_arson_page.cy.ts new file mode 100644 index 00000000..38c955ea --- /dev/null +++ b/integration_tests/tests/apply/risks-and-needs/risk-information/complete_violence_and_arson_page.cy.ts @@ -0,0 +1,46 @@ +// Feature: complete violence and arson page +// + +import ViolenceAndArsonPage from '../../../../pages/apply/risks-and-needs/risk-information/violenceAndArsonPage' +import Page from '../../../../pages/page' +import { personFactory, applicationFactory } from '../../../../../server/testutils/factories/index' + +context('Complete "Violence and arson" page', () => { + const person = personFactory.build({ name: 'Roger Smith' }) + + beforeEach(function test() { + cy.task('reset') + cy.task('stubSignIn') + cy.task('stubAuthUser') + + cy.fixture('applicationData.json').then(applicationData => { + applicationData['risk-information'] = {} + const application = applicationFactory.build({ + id: 'abc123', + person, + }) + application.data = applicationData + cy.wrap(application).as('application') + cy.wrap(application.data).as('applicationData') + }) + }) + + beforeEach(function test() { + // And an application exists + cy.task('stubApplicationGet', { application: this.application }) + cy.task('stubApplicationUpdate', { application: this.application }) + + // Given I am logged in + //--------------------- + cy.signIn() + + // And I visit the Violence and arson page + // -------------------------------- + cy.visit('applications/abc123/tasks/risk-information/pages/violence-and-arson') + }) + + it('exists', function test() { + // Given I am on the Violence and arson page + Page.verifyOnPage(ViolenceAndArsonPage, this.application) + }) +}) diff --git a/server/form-pages/apply/risks-and-needs/risk-information/index.ts b/server/form-pages/apply/risks-and-needs/risk-information/index.ts index f6c7483a..b7cae87b 100644 --- a/server/form-pages/apply/risks-and-needs/risk-information/index.ts +++ b/server/form-pages/apply/risks-and-needs/risk-information/index.ts @@ -2,12 +2,13 @@ import Concerns from './concerns' import SelfHarm from './selfHarm' import Acct from './acct' +import ViolenceAndArson from './violenceAndArson' import { Task } from '../../../utils/decorators' @Task({ name: 'Add information about risks to the applicant and others', slug: 'risk-information', - pages: [Concerns, SelfHarm, Acct], + pages: [Concerns, SelfHarm, Acct, ViolenceAndArson], }) export default class RiskToSelf {} diff --git a/server/form-pages/apply/risks-and-needs/risk-information/violenceAndArson.test.ts b/server/form-pages/apply/risks-and-needs/risk-information/violenceAndArson.test.ts new file mode 100644 index 00000000..d9f130f6 --- /dev/null +++ b/server/form-pages/apply/risks-and-needs/risk-information/violenceAndArson.test.ts @@ -0,0 +1,18 @@ +import { itShouldHaveNextValue, itShouldHavePreviousValue } from '../../../shared-examples' +import { personFactory, applicationFactory } from '../../../../testutils/factories/index' +import ViolenceAndArson from './violenceAndArson' + +describe('ViolenceAndArson', () => { + const application = applicationFactory.build({ person: personFactory.build({ name: 'Roger Smith' }) }) + + describe('title', () => { + it('adds the page title', () => { + const page = new ViolenceAndArson({}, application) + + expect(page.title).toEqual('Violence and arson') + }) + }) + + itShouldHaveNextValue(new ViolenceAndArson({}, application), 'risks-to-staff') + itShouldHavePreviousValue(new ViolenceAndArson({}, application), 'acct') +}) diff --git a/server/form-pages/apply/risks-and-needs/risk-information/violenceAndArson.ts b/server/form-pages/apply/risks-and-needs/risk-information/violenceAndArson.ts new file mode 100644 index 00000000..20c51478 --- /dev/null +++ b/server/form-pages/apply/risks-and-needs/risk-information/violenceAndArson.ts @@ -0,0 +1,46 @@ +import type { TaskListErrors } from '@approved-premises/ui' +import { Cas2v2Application as Application } from '@approved-premises/api' +import { nameOrPlaceholderCopy } from '../../../../utils/utils' +import { Page } from '../../../utils/decorators' +import TaskListPage from '../../../taskListPage' +import { getQuestions } from '../../../utils/questions' + +// eslint-disable-next-line @typescript-eslint/no-empty-object-type +type ViolenceAndArsonBody = {} + +@Page({ + name: 'violence-and-arson', + bodyProperties: [], +}) +export default class ViolenceAndArson implements TaskListPage { + documentTitle = 'Violence and arson' + + personName = nameOrPlaceholderCopy(this.application.person) + + title = 'Violence and arson' + + questions = getQuestions(this.personName)['risk-information']['violence-and-arson'] + + body: ViolenceAndArsonBody + + constructor( + body: Partial, + private readonly application: Application, + ) { + this.body = body as ViolenceAndArsonBody + } + + previous() { + return 'acct' + } + + next() { + return 'risks-to-staff' + } + + errors() { + const errors: TaskListErrors = {} + + return errors + } +} diff --git a/server/form-pages/utils/questions.ts b/server/form-pages/utils/questions.ts index 2a56f388..2c051087 100644 --- a/server/form-pages/utils/questions.ts +++ b/server/form-pages/utils/questions.ts @@ -664,6 +664,7 @@ export const getQuestions = (name: string) => { 'risk-information': { concerns: {}, 'self-harm': {}, + 'violence-and-arson': {}, vulnerability: { vulnerabilityDetail: { question: `Describe ${name}'s current circumstances, issues and needs related to vulnerability`, diff --git a/server/views/applications/pages/risk-information/violence-and-arson.njk b/server/views/applications/pages/risk-information/violence-and-arson.njk new file mode 100644 index 00000000..94f82bbb --- /dev/null +++ b/server/views/applications/pages/risk-information/violence-and-arson.njk @@ -0,0 +1,5 @@ +{% extends "./_risk-information-screen.njk" %} +{% set pageName = "violence-and-arson" %} + +{% block questions %} +{% endblock %} From 03429f8d4b66f382dfa2a24f0ff2219f6c1f79fd Mon Sep 17 00:00:00 2001 From: Daniel Liburd Date: Wed, 26 Feb 2025 12:38:00 +0000 Subject: [PATCH 09/17] Introduce risks to staff page --- .../risk-information/risksToStaffPage.ts | 8 ++++ .../complete_risks_to_staff_page.cy.ts | 46 +++++++++++++++++++ .../risks-and-needs/risk-information/index.ts | 3 +- .../risk-information/risksToStaff.test.ts | 18 ++++++++ .../risk-information/risksToStaff.ts | 46 +++++++++++++++++++ server/form-pages/utils/questions.ts | 1 + .../pages/risk-information/risks-to-staff.njk | 5 ++ 7 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 integration_tests/pages/apply/risks-and-needs/risk-information/risksToStaffPage.ts create mode 100644 integration_tests/tests/apply/risks-and-needs/risk-information/complete_risks_to_staff_page.cy.ts create mode 100644 server/form-pages/apply/risks-and-needs/risk-information/risksToStaff.test.ts create mode 100644 server/form-pages/apply/risks-and-needs/risk-information/risksToStaff.ts create mode 100644 server/views/applications/pages/risk-information/risks-to-staff.njk diff --git a/integration_tests/pages/apply/risks-and-needs/risk-information/risksToStaffPage.ts b/integration_tests/pages/apply/risks-and-needs/risk-information/risksToStaffPage.ts new file mode 100644 index 00000000..08b0c575 --- /dev/null +++ b/integration_tests/pages/apply/risks-and-needs/risk-information/risksToStaffPage.ts @@ -0,0 +1,8 @@ +import { Cas2v2Application as Application } from '@approved-premises/api' +import ApplyPage from '../../applyPage' + +export default class RisksToStaffPage extends ApplyPage { + constructor(private readonly application: Application) { + super('Risks to staff', application, 'risk-information', 'risks-to-staff') + } +} diff --git a/integration_tests/tests/apply/risks-and-needs/risk-information/complete_risks_to_staff_page.cy.ts b/integration_tests/tests/apply/risks-and-needs/risk-information/complete_risks_to_staff_page.cy.ts new file mode 100644 index 00000000..4af4c8e2 --- /dev/null +++ b/integration_tests/tests/apply/risks-and-needs/risk-information/complete_risks_to_staff_page.cy.ts @@ -0,0 +1,46 @@ +// Feature: complete risks to staff page +// + +import RisksToStaffPage from '../../../../pages/apply/risks-and-needs/risk-information/risksToStaffPage' +import Page from '../../../../pages/page' +import { personFactory, applicationFactory } from '../../../../../server/testutils/factories/index' + +context('Complete "Risks to staff" page', () => { + const person = personFactory.build({ name: 'Roger Smith' }) + + beforeEach(function test() { + cy.task('reset') + cy.task('stubSignIn') + cy.task('stubAuthUser') + + cy.fixture('applicationData.json').then(applicationData => { + applicationData['risk-information'] = {} + const application = applicationFactory.build({ + id: 'abc123', + person, + }) + application.data = applicationData + cy.wrap(application).as('application') + cy.wrap(application.data).as('applicationData') + }) + }) + + beforeEach(function test() { + // And an application exists + cy.task('stubApplicationGet', { application: this.application }) + cy.task('stubApplicationUpdate', { application: this.application }) + + // Given I am logged in + //--------------------- + cy.signIn() + + // And I visit the Risks to staff page + // -------------------------------- + cy.visit('applications/abc123/tasks/risk-information/pages/risks-to-staff') + }) + + it('exists', function test() { + // Given I am on the Risks to staff page + Page.verifyOnPage(RisksToStaffPage, this.application) + }) +}) diff --git a/server/form-pages/apply/risks-and-needs/risk-information/index.ts b/server/form-pages/apply/risks-and-needs/risk-information/index.ts index b7cae87b..70851986 100644 --- a/server/form-pages/apply/risks-and-needs/risk-information/index.ts +++ b/server/form-pages/apply/risks-and-needs/risk-information/index.ts @@ -3,12 +3,13 @@ import Concerns from './concerns' import SelfHarm from './selfHarm' import Acct from './acct' import ViolenceAndArson from './violenceAndArson' +import RisksToStaff from './risksToStaff' import { Task } from '../../../utils/decorators' @Task({ name: 'Add information about risks to the applicant and others', slug: 'risk-information', - pages: [Concerns, SelfHarm, Acct, ViolenceAndArson], + pages: [Concerns, SelfHarm, Acct, ViolenceAndArson, RisksToStaff], }) export default class RiskToSelf {} diff --git a/server/form-pages/apply/risks-and-needs/risk-information/risksToStaff.test.ts b/server/form-pages/apply/risks-and-needs/risk-information/risksToStaff.test.ts new file mode 100644 index 00000000..c748259b --- /dev/null +++ b/server/form-pages/apply/risks-and-needs/risk-information/risksToStaff.test.ts @@ -0,0 +1,18 @@ +import { itShouldHaveNextValue, itShouldHavePreviousValue } from '../../../shared-examples' +import { personFactory, applicationFactory } from '../../../../testutils/factories/index' +import RisksToStaff from './risksToStaff' + +describe('RisksToStaff', () => { + const application = applicationFactory.build({ person: personFactory.build({ name: 'Roger Smith' }) }) + + describe('title', () => { + it('adds the page title', () => { + const page = new RisksToStaff({}, application) + + expect(page.title).toEqual('Risks to staff') + }) + }) + + itShouldHaveNextValue(new RisksToStaff({}, application), 'additional-concerns') + itShouldHavePreviousValue(new RisksToStaff({}, application), 'violence-and-arson') +}) diff --git a/server/form-pages/apply/risks-and-needs/risk-information/risksToStaff.ts b/server/form-pages/apply/risks-and-needs/risk-information/risksToStaff.ts new file mode 100644 index 00000000..8d416a38 --- /dev/null +++ b/server/form-pages/apply/risks-and-needs/risk-information/risksToStaff.ts @@ -0,0 +1,46 @@ +import type { TaskListErrors } from '@approved-premises/ui' +import { Cas2v2Application as Application } from '@approved-premises/api' +import { nameOrPlaceholderCopy } from '../../../../utils/utils' +import { Page } from '../../../utils/decorators' +import TaskListPage from '../../../taskListPage' +import { getQuestions } from '../../../utils/questions' + +// eslint-disable-next-line @typescript-eslint/no-empty-object-type +type RisksToStaffBody = {} + +@Page({ + name: 'risks-to-staff', + bodyProperties: [], +}) +export default class RisksToStaff implements TaskListPage { + documentTitle = 'Risks to staff' + + personName = nameOrPlaceholderCopy(this.application.person) + + title = 'Risks to staff' + + questions = getQuestions(this.personName)['risk-information']['risks-to-staff'] + + body: RisksToStaffBody + + constructor( + body: Partial, + private readonly application: Application, + ) { + this.body = body as RisksToStaffBody + } + + previous() { + return 'violence-and-arson' + } + + next() { + return 'additional-concerns' + } + + errors() { + const errors: TaskListErrors = {} + + return errors + } +} diff --git a/server/form-pages/utils/questions.ts b/server/form-pages/utils/questions.ts index 2c051087..41e5e3d5 100644 --- a/server/form-pages/utils/questions.ts +++ b/server/form-pages/utils/questions.ts @@ -665,6 +665,7 @@ export const getQuestions = (name: string) => { concerns: {}, 'self-harm': {}, 'violence-and-arson': {}, + 'risks-to-staff': {}, vulnerability: { vulnerabilityDetail: { question: `Describe ${name}'s current circumstances, issues and needs related to vulnerability`, diff --git a/server/views/applications/pages/risk-information/risks-to-staff.njk b/server/views/applications/pages/risk-information/risks-to-staff.njk new file mode 100644 index 00000000..8469874c --- /dev/null +++ b/server/views/applications/pages/risk-information/risks-to-staff.njk @@ -0,0 +1,5 @@ +{% extends "./_risk-information-screen.njk" %} +{% set pageName = "risks-to-staff" %} + +{% block questions %} +{% endblock %} From 97b1403afc9b3bae877648abf99c45b34537c299 Mon Sep 17 00:00:00 2001 From: Daniel Liburd Date: Wed, 26 Feb 2025 13:24:57 +0000 Subject: [PATCH 10/17] Introduce additional concerns page --- .../additionalConcernsPage.ts | 8 ++++ .../complete_additional_concerns_page.cy.ts | 46 +++++++++++++++++++ .../additionalConcerns.test.ts | 18 ++++++++ .../risk-information/additionalConcerns.ts | 46 +++++++++++++++++++ .../risks-and-needs/risk-information/index.ts | 3 +- server/form-pages/utils/questions.ts | 1 + .../risk-information/additional-concerns.njk | 5 ++ 7 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 integration_tests/pages/apply/risks-and-needs/risk-information/additionalConcernsPage.ts create mode 100644 integration_tests/tests/apply/risks-and-needs/risk-information/complete_additional_concerns_page.cy.ts create mode 100644 server/form-pages/apply/risks-and-needs/risk-information/additionalConcerns.test.ts create mode 100644 server/form-pages/apply/risks-and-needs/risk-information/additionalConcerns.ts create mode 100644 server/views/applications/pages/risk-information/additional-concerns.njk diff --git a/integration_tests/pages/apply/risks-and-needs/risk-information/additionalConcernsPage.ts b/integration_tests/pages/apply/risks-and-needs/risk-information/additionalConcernsPage.ts new file mode 100644 index 00000000..d1ef1369 --- /dev/null +++ b/integration_tests/pages/apply/risks-and-needs/risk-information/additionalConcernsPage.ts @@ -0,0 +1,8 @@ +import { Cas2v2Application as Application } from '@approved-premises/api' +import ApplyPage from '../../applyPage' + +export default class AdditionalConcernsPage extends ApplyPage { + constructor(private readonly application: Application) { + super('Additional concerns', application, 'risk-information', 'additional-concerns') + } +} diff --git a/integration_tests/tests/apply/risks-and-needs/risk-information/complete_additional_concerns_page.cy.ts b/integration_tests/tests/apply/risks-and-needs/risk-information/complete_additional_concerns_page.cy.ts new file mode 100644 index 00000000..efbf86c8 --- /dev/null +++ b/integration_tests/tests/apply/risks-and-needs/risk-information/complete_additional_concerns_page.cy.ts @@ -0,0 +1,46 @@ +// Feature: complete additional concerns page +// + +import AdditionalConcernsPage from '../../../../pages/apply/risks-and-needs/risk-information/additionalConcernsPage' +import Page from '../../../../pages/page' +import { personFactory, applicationFactory } from '../../../../../server/testutils/factories/index' + +context('Complete "Additional concerns" page', () => { + const person = personFactory.build({ name: 'Roger Smith' }) + + beforeEach(function test() { + cy.task('reset') + cy.task('stubSignIn') + cy.task('stubAuthUser') + + cy.fixture('applicationData.json').then(applicationData => { + applicationData['risk-information'] = {} + const application = applicationFactory.build({ + id: 'abc123', + person, + }) + application.data = applicationData + cy.wrap(application).as('application') + cy.wrap(application.data).as('applicationData') + }) + }) + + beforeEach(function test() { + // And an application exists + cy.task('stubApplicationGet', { application: this.application }) + cy.task('stubApplicationUpdate', { application: this.application }) + + // Given I am logged in + //--------------------- + cy.signIn() + + // And I visit the Additional concerns page + // -------------------------------- + cy.visit('applications/abc123/tasks/risk-information/pages/additional-concerns') + }) + + it('exists', function test() { + // Given I am on the Additional concerns page + Page.verifyOnPage(AdditionalConcernsPage, this.application) + }) +}) diff --git a/server/form-pages/apply/risks-and-needs/risk-information/additionalConcerns.test.ts b/server/form-pages/apply/risks-and-needs/risk-information/additionalConcerns.test.ts new file mode 100644 index 00000000..7daa79f0 --- /dev/null +++ b/server/form-pages/apply/risks-and-needs/risk-information/additionalConcerns.test.ts @@ -0,0 +1,18 @@ +import { itShouldHaveNextValue, itShouldHavePreviousValue } from '../../../shared-examples' +import { personFactory, applicationFactory } from '../../../../testutils/factories/index' +import AdditionalConcerns from './additionalConcerns' + +describe('AdditionalConcerns', () => { + const application = applicationFactory.build({ person: personFactory.build({ name: 'Roger Smith' }) }) + + describe('title', () => { + it('adds the page title', () => { + const page = new AdditionalConcerns({}, application) + + expect(page.title).toEqual('Additional concerns') + }) + }) + + itShouldHaveNextValue(new AdditionalConcerns({}, application), '') + itShouldHavePreviousValue(new AdditionalConcerns({}, application), 'risks-to-staff') +}) diff --git a/server/form-pages/apply/risks-and-needs/risk-information/additionalConcerns.ts b/server/form-pages/apply/risks-and-needs/risk-information/additionalConcerns.ts new file mode 100644 index 00000000..bd097606 --- /dev/null +++ b/server/form-pages/apply/risks-and-needs/risk-information/additionalConcerns.ts @@ -0,0 +1,46 @@ +import type { TaskListErrors } from '@approved-premises/ui' +import { Cas2v2Application as Application } from '@approved-premises/api' +import { nameOrPlaceholderCopy } from '../../../../utils/utils' +import { Page } from '../../../utils/decorators' +import TaskListPage from '../../../taskListPage' +import { getQuestions } from '../../../utils/questions' + +// eslint-disable-next-line @typescript-eslint/no-empty-object-type +type AdditionalConcernsBody = {} + +@Page({ + name: 'additional-concerns', + bodyProperties: [], +}) +export default class AdditionalConcerns implements TaskListPage { + documentTitle = 'Additional concerns' + + personName = nameOrPlaceholderCopy(this.application.person) + + title = 'Additional concerns' + + questions = getQuestions(this.personName)['risk-information']['additional-concerns'] + + body: AdditionalConcernsBody + + constructor( + body: Partial, + private readonly application: Application, + ) { + this.body = body as AdditionalConcernsBody + } + + previous() { + return 'risks-to-staff' + } + + next() { + return '' + } + + errors() { + const errors: TaskListErrors = {} + + return errors + } +} diff --git a/server/form-pages/apply/risks-and-needs/risk-information/index.ts b/server/form-pages/apply/risks-and-needs/risk-information/index.ts index 70851986..5569e5ef 100644 --- a/server/form-pages/apply/risks-and-needs/risk-information/index.ts +++ b/server/form-pages/apply/risks-and-needs/risk-information/index.ts @@ -4,12 +4,13 @@ import SelfHarm from './selfHarm' import Acct from './acct' import ViolenceAndArson from './violenceAndArson' import RisksToStaff from './risksToStaff' +import AdditionalConcerns from './additionalConcerns' import { Task } from '../../../utils/decorators' @Task({ name: 'Add information about risks to the applicant and others', slug: 'risk-information', - pages: [Concerns, SelfHarm, Acct, ViolenceAndArson, RisksToStaff], + pages: [Concerns, SelfHarm, Acct, ViolenceAndArson, RisksToStaff, AdditionalConcerns], }) export default class RiskToSelf {} diff --git a/server/form-pages/utils/questions.ts b/server/form-pages/utils/questions.ts index 41e5e3d5..a945b3c1 100644 --- a/server/form-pages/utils/questions.ts +++ b/server/form-pages/utils/questions.ts @@ -666,6 +666,7 @@ export const getQuestions = (name: string) => { 'self-harm': {}, 'violence-and-arson': {}, 'risks-to-staff': {}, + 'additional-concerns': {}, vulnerability: { vulnerabilityDetail: { question: `Describe ${name}'s current circumstances, issues and needs related to vulnerability`, diff --git a/server/views/applications/pages/risk-information/additional-concerns.njk b/server/views/applications/pages/risk-information/additional-concerns.njk new file mode 100644 index 00000000..92771559 --- /dev/null +++ b/server/views/applications/pages/risk-information/additional-concerns.njk @@ -0,0 +1,5 @@ +{% extends "./_risk-information-screen.njk" %} +{% set pageName = "additional-concerns" %} + +{% block questions %} +{% endblock %} From f375af02f3a34d7e9e0489b09b8c629e5dc44790 Mon Sep 17 00:00:00 2001 From: Daniel Liburd Date: Thu, 27 Feb 2025 12:27:54 +0000 Subject: [PATCH 11/17] Update check your answers test with new page names --- server/utils/checkYourAnswersUtils.test.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/server/utils/checkYourAnswersUtils.test.ts b/server/utils/checkYourAnswersUtils.test.ts index fd6fb402..69359eed 100644 --- a/server/utils/checkYourAnswersUtils.test.ts +++ b/server/utils/checkYourAnswersUtils.test.ts @@ -521,12 +521,13 @@ describe('checkYourAnswersUtils', () => { describe('getKeysForPages', () => { it('returns an array of page keys for risk information', () => { expect(getKeysForPages(application, 'risk-information')).toEqual([ - 'current-risk', - 'vulnerability', - 'historical-risk', + 'concerns', + 'self-harm', + 'violence-and-arson', + 'risks-to-staff', + 'additional-concerns', 'acct', 'acct-data', - 'additional-information', ]) }) }) From e05a187cf09e11e8c32703109156cda49f80e15f Mon Sep 17 00:00:00 2001 From: Daniel Liburd Date: Thu, 27 Feb 2025 13:35:07 +0000 Subject: [PATCH 12/17] Update ACCT page Now the ACCT page sits within the new page structure, update the next and previous pages. --- .../apply/risks-and-needs/risk-information/acct.test.ts | 4 ++-- .../form-pages/apply/risks-and-needs/risk-information/acct.ts | 4 ++-- .../apply/risks-and-needs/risk-information/index.ts | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/server/form-pages/apply/risks-and-needs/risk-information/acct.test.ts b/server/form-pages/apply/risks-and-needs/risk-information/acct.test.ts index 3203d302..52165dcf 100644 --- a/server/form-pages/apply/risks-and-needs/risk-information/acct.test.ts +++ b/server/form-pages/apply/risks-and-needs/risk-information/acct.test.ts @@ -69,8 +69,8 @@ describe('Acct', () => { }) }) - itShouldHaveNextValue(new Acct({}, application), 'additional-information') - itShouldHavePreviousValue(new Acct({}, application), 'historical-risk') + itShouldHaveNextValue(new Acct({}, application), 'violence-and-arson') + itShouldHavePreviousValue(new Acct({}, application), 'self-harm') describe('response', () => { it('returns formatted ACCTs', () => { diff --git a/server/form-pages/apply/risks-and-needs/risk-information/acct.ts b/server/form-pages/apply/risks-and-needs/risk-information/acct.ts index 8f4beb49..492878e3 100644 --- a/server/form-pages/apply/risks-and-needs/risk-information/acct.ts +++ b/server/form-pages/apply/risks-and-needs/risk-information/acct.ts @@ -64,11 +64,11 @@ export default class Acct implements TaskListPage { } previous() { - return 'historical-risk' + return 'self-harm' } next() { - return 'additional-information' + return 'violence-and-arson' } errors() { diff --git a/server/form-pages/apply/risks-and-needs/risk-information/index.ts b/server/form-pages/apply/risks-and-needs/risk-information/index.ts index 5569e5ef..fb858837 100644 --- a/server/form-pages/apply/risks-and-needs/risk-information/index.ts +++ b/server/form-pages/apply/risks-and-needs/risk-information/index.ts @@ -2,6 +2,7 @@ import Concerns from './concerns' import SelfHarm from './selfHarm' import Acct from './acct' +import AcctData from './custom-forms/acctData' import ViolenceAndArson from './violenceAndArson' import RisksToStaff from './risksToStaff' import AdditionalConcerns from './additionalConcerns' @@ -11,6 +12,6 @@ import { Task } from '../../../utils/decorators' @Task({ name: 'Add information about risks to the applicant and others', slug: 'risk-information', - pages: [Concerns, SelfHarm, Acct, ViolenceAndArson, RisksToStaff, AdditionalConcerns], + pages: [Concerns, SelfHarm, Acct, AcctData, ViolenceAndArson, RisksToStaff, AdditionalConcerns], }) export default class RiskToSelf {} From 913b063336c7215f5e35e0303503c7ccd48ff8d1 Mon Sep 17 00:00:00 2001 From: Daniel Liburd Date: Thu, 27 Feb 2025 13:35:50 +0000 Subject: [PATCH 13/17] Update e2e tests to match new page structure --- e2e-tests/steps/apply.ts | 4 +- e2e-tests/steps/risksAndNeedsSection.ts | 97 +++++++------------------ e2e-tests/tests/01_apply_as_pom.spec.ts | 2 +- 3 files changed, 30 insertions(+), 73 deletions(-) diff --git a/e2e-tests/steps/apply.ts b/e2e-tests/steps/apply.ts index 21c742ce..2f83dfdc 100644 --- a/e2e-tests/steps/apply.ts +++ b/e2e-tests/steps/apply.ts @@ -19,7 +19,7 @@ import { completeEqualityAndDiversityTask, completePersonalInformationTask, } from './aboutThePersonSection' -import { completeHealthNeedsTask, completeRiskToSelfTask } from './risksAndNeedsSection' +import { completeHealthNeedsTask, completeRiskInformationTask } from './risksAndNeedsSection' import { completeAreaInformationTask, completeFundingInformationTask } from './areaAndFundingSection' import { completeAllegedOffencesTask, @@ -84,7 +84,7 @@ export const completeAboutThePersonSection = async (page: Page, name: string) => export const completeRisksAndNeedsSection = async (page: Page, name: string) => { await completeHealthNeedsTask(page, name) - await completeRiskToSelfTask(page, name) + await completeRiskInformationTask(page) } export const completeOffenceInformationSection = async (page: Page, name: string) => { diff --git a/e2e-tests/steps/risksAndNeedsSection.ts b/e2e-tests/steps/risksAndNeedsSection.ts index 2213da7f..f53cdc85 100644 --- a/e2e-tests/steps/risksAndNeedsSection.ts +++ b/e2e-tests/steps/risksAndNeedsSection.ts @@ -123,45 +123,46 @@ async function completeOtherHealthPage(page: Page, name: string) { await otherHealthPage.clickSave() } -export const completeRiskToSelfTask = async (page: Page, name: string) => { +export const completeRiskInformationTask = async (page: Page) => { const taskListPage = new TaskListPage(page) await taskListPage.clickTask('Add information about risks to the applicant and others') - await completeVulnerabilityPage(page, name) - await completeCurrentRisksPage(page, name) - await completeHistoricalRisksPage(page, name) + await completeConcernsPage(page) + await completeSelfHarmPage(page) await addAnAcct(page) - await completeAdditionalInformationPage(page, name) + await completeViolenceAndArsonPage(page) + await completeRisksToStaffPage(page) + await completeAdditionalConcernsPage(page) } -async function completeVulnerabilityPage(page: Page, name: string) { - const vulnerabilityPage = await ApplyPage.initialize(page, `${name}'s vulnerability`) +async function completeConcernsPage(page: Page) { + const concernsPage = await ApplyPage.initialize(page, 'Concerns') - await vulnerabilityPage.fillField( - `Describe ${name}'s current circumstances, issues and needs related to vulnerability`, - 'some vulnerability', - ) - await vulnerabilityPage.clickSave() + concernsPage.clickSave() } -async function completeCurrentRisksPage(page: Page, name: string) { - const currentRisksPage = await ApplyPage.initialize(page, `${name}'s current risks`) +async function completeSelfHarmPage(page: Page) { + const selfHarmPage = await ApplyPage.initialize(page, 'Self harm') - await currentRisksPage.fillField( - `Describe ${name}'s current issues and needs related to self harm and suicide`, - 'some needs', - ) - await currentRisksPage.clickSave() + selfHarmPage.clickSave() } -async function completeHistoricalRisksPage(page: Page, name: string) { - const historicalRisksPage = await ApplyPage.initialize(page, `${name}'s historical risks`) +async function completeViolenceAndArsonPage(page: Page) { + const violenceAndArsonPage = await ApplyPage.initialize(page, 'Violence and arson') - await historicalRisksPage.fillField( - `Describe ${name}'s historical issues and needs related to self harm and suicide`, - 'some needs', - ) - await historicalRisksPage.clickSave() + violenceAndArsonPage.clickSave() +} + +async function completeRisksToStaffPage(page: Page) { + const risksToStaffPage = await ApplyPage.initialize(page, 'Risks to staff') + + risksToStaffPage.clickSave() +} + +async function completeAdditionalConcernsPage(page: Page) { + const additionalConcernsPage = await ApplyPage.initialize(page, 'Additional concerns') + + additionalConcernsPage.clickSave() } async function addAnAcct(page: Page) { @@ -179,47 +180,3 @@ async function completeAcctDataPage(page: Page) { await acctDataPage.fillField('Details about the ACCT', 'some details') await acctDataPage.clickButton('Save and add ACCT') } - -async function completeAdditionalInformationPage(page: Page, name: string) { - const additionalInformationPage = await ApplyPage.initialize( - page, - `Is there anything else to include about ${name}'s risk to self?`, - ) - await additionalInformationPage.checkRadio('No') - await additionalInformationPage.clickSave() -} - -export const completeRoshTask = async (page: Page, name: string) => { - const taskListPage = new TaskListPage(page) - await taskListPage.clickTask('Add risk of serious harm (RoSH) information') - - await completeRiskToOthersPage(page, name) - await completeRiskManagementArrangementsPage(page, name) - await completeCellShareInformationPage(page, name) - await completeAdditionalRiskPage(page, name) -} - -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) { - const riskManagementPage = await ApplyPage.initialize(page, `Risk management arrangements for ${name}`) - await riskManagementPage.checkCheckboxes(['No, this person does not have risk management arrangements']) - await riskManagementPage.clickSave() -} - -async function completeCellShareInformationPage(page: Page, name: string) { - const riskManagementPage = await ApplyPage.initialize(page, `Cell share information for ${name}`) - await riskManagementPage.checkRadio('No') - await riskManagementPage.clickSave() -} - -async function completeAdditionalRiskPage(page: Page, name: string) { - const riskManagementPage = await ApplyPage.initialize(page, `Additional risk information for ${name}`) - await riskManagementPage.checkRadio('No') - await riskManagementPage.clickSave() -} diff --git a/e2e-tests/tests/01_apply_as_pom.spec.ts b/e2e-tests/tests/01_apply_as_pom.spec.ts index 3e412e04..d0ba1c19 100644 --- a/e2e-tests/tests/01_apply_as_pom.spec.ts +++ b/e2e-tests/tests/01_apply_as_pom.spec.ts @@ -34,7 +34,7 @@ test('create a CAS-2 bail 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 17 of 17 tasks')).toBeVisible() await submitApplication(page) }) From 88bfe9f0d29a564a870943d18afa7f3180593034 Mon Sep 17 00:00:00 2001 From: Daniel Liburd Date: Thu, 27 Feb 2025 14:21:30 +0000 Subject: [PATCH 14/17] Remove previous risk data As we have the new pages in place, we can safely remove the RoSH task data and Risk to self task data. --- .../fixtures/applicationData.json | 20 -- .../additionalInformation.test.ts | 70 ------- .../risk-information/additionalInformation.ts | 56 ------ .../risk-information/currentRisk.test.ts | 38 ---- .../risk-information/currentRisk.ts | 49 ----- .../risk-information/historicalRisk.test.ts | 37 ---- .../risk-information/historicalRisk.ts | 49 ----- .../risk-information/vulnerability.test.ts | 37 ---- .../risk-information/vulnerability.ts | 49 ----- .../additionalRiskInformation.test.ts | 62 ------ .../additionalRiskInformation.ts | 60 ------ .../cellShareInformation.test.ts | 62 ------ .../cellShareInformation.ts | 58 ------ .../risk-of-serious-harm/index.ts | 12 -- .../riskManagementArrangements.test.ts | 178 ------------------ .../riskManagementArrangements.ts | 109 ----------- .../risk-of-serious-harm/riskToOthers.test.ts | 28 --- .../risk-of-serious-harm/riskToOthers.ts | 53 ------ server/form-pages/utils/questions.ts | 78 -------- .../additional-information.njk | 51 ----- .../pages/risk-information/current-risk.njk | 56 ------ .../risk-information/historical-risk.njk | 57 ------ .../pages/risk-information/vulnerability.njk | 47 ----- .../_risk-of-serious-harm-screen.njk | 42 ----- .../additional-risk-information.njk | 50 ----- .../cell-share-information.njk | 51 ----- .../risk-management-arrangements.njk | 125 ------------ .../risk-of-serious-harm/risk-to-others.njk | 68 ------- 28 files changed, 1652 deletions(-) delete mode 100644 server/form-pages/apply/risks-and-needs/risk-information/additionalInformation.test.ts delete mode 100644 server/form-pages/apply/risks-and-needs/risk-information/additionalInformation.ts delete mode 100644 server/form-pages/apply/risks-and-needs/risk-information/currentRisk.test.ts delete mode 100644 server/form-pages/apply/risks-and-needs/risk-information/currentRisk.ts delete mode 100644 server/form-pages/apply/risks-and-needs/risk-information/historicalRisk.test.ts delete mode 100644 server/form-pages/apply/risks-and-needs/risk-information/historicalRisk.ts delete mode 100644 server/form-pages/apply/risks-and-needs/risk-information/vulnerability.test.ts delete mode 100644 server/form-pages/apply/risks-and-needs/risk-information/vulnerability.ts delete mode 100644 server/form-pages/apply/risks-and-needs/risk-of-serious-harm/additionalRiskInformation.test.ts delete mode 100644 server/form-pages/apply/risks-and-needs/risk-of-serious-harm/additionalRiskInformation.ts delete mode 100644 server/form-pages/apply/risks-and-needs/risk-of-serious-harm/cellShareInformation.test.ts delete mode 100644 server/form-pages/apply/risks-and-needs/risk-of-serious-harm/cellShareInformation.ts delete mode 100644 server/form-pages/apply/risks-and-needs/risk-of-serious-harm/index.ts delete mode 100644 server/form-pages/apply/risks-and-needs/risk-of-serious-harm/riskManagementArrangements.test.ts delete mode 100644 server/form-pages/apply/risks-and-needs/risk-of-serious-harm/riskManagementArrangements.ts delete mode 100644 server/form-pages/apply/risks-and-needs/risk-of-serious-harm/riskToOthers.test.ts delete mode 100644 server/form-pages/apply/risks-and-needs/risk-of-serious-harm/riskToOthers.ts delete mode 100644 server/views/applications/pages/risk-information/additional-information.njk delete mode 100644 server/views/applications/pages/risk-information/current-risk.njk delete mode 100644 server/views/applications/pages/risk-information/historical-risk.njk delete mode 100644 server/views/applications/pages/risk-information/vulnerability.njk delete mode 100644 server/views/applications/pages/risk-of-serious-harm/_risk-of-serious-harm-screen.njk delete mode 100644 server/views/applications/pages/risk-of-serious-harm/additional-risk-information.njk delete mode 100644 server/views/applications/pages/risk-of-serious-harm/cell-share-information.njk delete mode 100644 server/views/applications/pages/risk-of-serious-harm/risk-management-arrangements.njk delete mode 100644 server/views/applications/pages/risk-of-serious-harm/risk-to-others.njk diff --git a/integration_tests/fixtures/applicationData.json b/integration_tests/fixtures/applicationData.json index e8870ab5..db26406e 100644 --- a/integration_tests/fixtures/applicationData.json +++ b/integration_tests/fixtures/applicationData.json @@ -237,26 +237,6 @@ } ] }, - "risk-of-serious-harm": { - "risk-to-others": { - "whoIsAtRisk": "a person", - "natureOfRisk": "a nature" - }, - "risk-management-arrangements": { - "arrangements": ["mappa", "marac", "iom"], - "mappaDetails": "mappa details", - "maracDetails": "marac details", - "iomDetails": "iom details" - }, - "cell-share-information": { - "hasCellShareComments": "yes", - "cellShareInformationDetail": "some information" - }, - "additional-risk-information": { - "hasAdditionalInformation": "yes", - "additionalInformationDetail": "some information" - } - }, "community-supervision-and-current-offences": { "community-supervision": { "probationSupervision": "yes" diff --git a/server/form-pages/apply/risks-and-needs/risk-information/additionalInformation.test.ts b/server/form-pages/apply/risks-and-needs/risk-information/additionalInformation.test.ts deleted file mode 100644 index 0e908270..00000000 --- a/server/form-pages/apply/risks-and-needs/risk-information/additionalInformation.test.ts +++ /dev/null @@ -1,70 +0,0 @@ -import { itShouldHaveNextValue, itShouldHavePreviousValue } from '../../../shared-examples' -import { personFactory, applicationFactory } from '../../../../testutils/factories/index' -import AdditionalInformation, { AdditionalInformationBody } from './additionalInformation' - -describe('AdditionalInformation', () => { - const application = applicationFactory.build({ person: personFactory.build({ name: 'Roger Smith' }) }) - - describe('title', () => { - it('personalises the page title', () => { - const page = new AdditionalInformation({}, application) - - expect(page.title).toEqual('Additional Information') - }) - }) - - describe('Questions', () => { - const page = new AdditionalInformation({}, application) - - describe('additionalInformationDetail', () => { - it('has a question', () => { - expect(page.questions.additionalInformationDetail.question).toBeDefined() - }) - }) - }) - - itShouldHaveNextValue(new AdditionalInformation({}, application), '') - itShouldHavePreviousValue(new AdditionalInformation({}, application), 'acct') - - describe('errors', () => { - describe('when they have not provided any answer', () => { - it('returns an error', () => { - const page = new AdditionalInformation({}, application) - expect(page.errors()).toEqual({ hasAdditionalInformation: 'Confirm whether you have additional information' }) - }) - }) - - describe('when there is no additional data', () => { - it('does not return errors', () => { - const page = new AdditionalInformation({ hasAdditionalInformation: 'no' }, application) - expect(page.errors()).toEqual({}) - }) - }) - - describe('when they have answered Yes there is additional information but not provided any', () => { - it('returns additional information error', () => { - const page = new AdditionalInformation({ hasAdditionalInformation: 'yes' }, application) - expect(page.errors()).toEqual({ - additionalInformationDetail: 'Provide additional information about their risk to self', - }) - }) - }) - }) - - describe('onSave', () => { - it('removes additional information data if question is set to "no"', () => { - const body: AdditionalInformationBody = { - hasAdditionalInformation: 'no', - additionalInformationDetail: 'Additional information detail', - } - - const page = new AdditionalInformation(body, application) - - page.onSave() - - expect(page.body).toEqual({ - hasAdditionalInformation: 'no', - }) - }) - }) -}) diff --git a/server/form-pages/apply/risks-and-needs/risk-information/additionalInformation.ts b/server/form-pages/apply/risks-and-needs/risk-information/additionalInformation.ts deleted file mode 100644 index fc1f84bb..00000000 --- a/server/form-pages/apply/risks-and-needs/risk-information/additionalInformation.ts +++ /dev/null @@ -1,56 +0,0 @@ -import type { TaskListErrors, YesOrNo } from '@approved-premises/ui' -import { Cas2v2Application as Application } from '@approved-premises/api' -import { nameOrPlaceholderCopy } from '../../../../utils/utils' -import { Page } from '../../../utils/decorators' -import TaskListPage from '../../../taskListPage' -import { getQuestions } from '../../../utils/questions' - -export type AdditionalInformationBody = { hasAdditionalInformation: YesOrNo; additionalInformationDetail: string } - -@Page({ - name: 'additional-information', - bodyProperties: ['hasAdditionalInformation', 'additionalInformationDetail'], -}) -export default class AdditionalInformation implements TaskListPage { - title = 'Additional Information' - - documentTitle = this.title - - questions = getQuestions(nameOrPlaceholderCopy(this.application.person))['risk-information']['additional-information'] - - body: AdditionalInformationBody - - constructor( - body: Partial, - private readonly application: Application, - ) { - this.body = body as AdditionalInformationBody - } - - previous() { - return 'acct' - } - - next() { - return '' - } - - errors() { - const errors: TaskListErrors = {} - - if (!this.body.hasAdditionalInformation) { - errors.hasAdditionalInformation = 'Confirm whether you have additional information' - } - if (this.body.hasAdditionalInformation === 'yes' && !this.body.additionalInformationDetail) { - errors.additionalInformationDetail = 'Provide additional information about their risk to self' - } - - return errors - } - - onSave(): void { - if (this.body.hasAdditionalInformation !== 'yes') { - delete this.body.additionalInformationDetail - } - } -} diff --git a/server/form-pages/apply/risks-and-needs/risk-information/currentRisk.test.ts b/server/form-pages/apply/risks-and-needs/risk-information/currentRisk.test.ts deleted file mode 100644 index 85a28f00..00000000 --- a/server/form-pages/apply/risks-and-needs/risk-information/currentRisk.test.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { itShouldHaveNextValue, itShouldHavePreviousValue } from '../../../shared-examples' -import { personFactory, applicationFactory } from '../../../../testutils/factories/index' -import CurrentRisk from './currentRisk' - -describe('CurrentRisk', () => { - const person = personFactory.build({ name: 'Roger Smith' }) - const application = applicationFactory.build({ person }) - - describe('title', () => { - it('personalises the page title', () => { - const page = new CurrentRisk({}, application) - - expect(page.title).toEqual("Roger Smith's current risks") - }) - }) - - describe('Questions', () => { - const page = new CurrentRisk({}, application) - - describe('currentRiskDetail', () => { - it('has a question', () => { - expect(page.questions.currentRiskDetail.question).toBeDefined() - }) - }) - }) - - itShouldHaveNextValue(new CurrentRisk({}, application), 'historical-risk') - itShouldHavePreviousValue(new CurrentRisk({}, application), 'vulnerability') - - describe('errors', () => { - it('returns an error when currentRiskDetail is blank', () => { - const page = new CurrentRisk({}, application) - expect(page.errors()).toEqual({ - currentRiskDetail: "Describe Roger Smith's current issues and needs related to self harm and suicide", - }) - }) - }) -}) diff --git a/server/form-pages/apply/risks-and-needs/risk-information/currentRisk.ts b/server/form-pages/apply/risks-and-needs/risk-information/currentRisk.ts deleted file mode 100644 index a47de932..00000000 --- a/server/form-pages/apply/risks-and-needs/risk-information/currentRisk.ts +++ /dev/null @@ -1,49 +0,0 @@ -import type { TaskListErrors } from '@approved-premises/ui' -import { Cas2v2Application as Application } from '@approved-premises/api' -import { nameOrPlaceholderCopy } from '../../../../utils/utils' -import { Page } from '../../../utils/decorators' -import TaskListPage from '../../../taskListPage' -import { getQuestions } from '../../../utils/questions' - -type CurrentRiskBody = { currentRiskDetail: string; confirmation: string } - -@Page({ - name: 'current-risk', - bodyProperties: ['currentRiskDetail', 'confirmation'], -}) -export default class CurrentRisk implements TaskListPage { - documentTitle = "The person's current risks" - - personName = nameOrPlaceholderCopy(this.application.person) - - title = `${this.personName}'s current risks` - - questions = getQuestions(this.personName)['risk-information']['current-risk'] - - body: CurrentRiskBody - - constructor( - body: Partial, - private readonly application: Application, - ) { - this.body = body as CurrentRiskBody - } - - previous() { - return 'vulnerability' - } - - next() { - return 'historical-risk' - } - - errors() { - const errors: TaskListErrors = {} - - if (!this.body.currentRiskDetail) { - errors.currentRiskDetail = `Describe ${this.personName}'s current issues and needs related to self harm and suicide` - } - - return errors - } -} diff --git a/server/form-pages/apply/risks-and-needs/risk-information/historicalRisk.test.ts b/server/form-pages/apply/risks-and-needs/risk-information/historicalRisk.test.ts deleted file mode 100644 index 2c7aca0a..00000000 --- a/server/form-pages/apply/risks-and-needs/risk-information/historicalRisk.test.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { itShouldHaveNextValue, itShouldHavePreviousValue } from '../../../shared-examples' -import { personFactory, applicationFactory } from '../../../../testutils/factories/index' -import HistoricalRisk from './historicalRisk' - -describe('HistoricalRisk', () => { - const application = applicationFactory.build({ person: personFactory.build({ name: 'Roger Smith' }) }) - - describe('title', () => { - it('personalises the page title', () => { - const page = new HistoricalRisk({}, application) - - expect(page.title).toEqual("Roger Smith's historical risks") - }) - }) - - describe('Questions', () => { - const page = new HistoricalRisk({}, application) - - describe('historicalRiskDetail', () => { - it('has a question', () => { - expect(page.questions.historicalRiskDetail.question).toBeDefined() - }) - }) - }) - - itShouldHaveNextValue(new HistoricalRisk({}, application), 'acct') - itShouldHavePreviousValue(new HistoricalRisk({}, application), 'current-risk') - - describe('errors', () => { - it('returns an error when historicalRiskDetail is blank', () => { - const page = new HistoricalRisk({}, application) - expect(page.errors()).toEqual({ - historicalRiskDetail: "Describe Roger Smith's historical issues and needs related to self harm and suicide", - }) - }) - }) -}) diff --git a/server/form-pages/apply/risks-and-needs/risk-information/historicalRisk.ts b/server/form-pages/apply/risks-and-needs/risk-information/historicalRisk.ts deleted file mode 100644 index 23277cff..00000000 --- a/server/form-pages/apply/risks-and-needs/risk-information/historicalRisk.ts +++ /dev/null @@ -1,49 +0,0 @@ -import type { TaskListErrors } from '@approved-premises/ui' -import { Cas2v2Application as Application } from '@approved-premises/api' -import { nameOrPlaceholderCopy } from '../../../../utils/utils' -import { Page } from '../../../utils/decorators' -import TaskListPage from '../../../taskListPage' -import { getQuestions } from '../../../utils/questions' - -type HistoricalRiskBody = { historicalRiskDetail: string; confirmation: string } - -@Page({ - name: 'historical-risk', - bodyProperties: ['historicalRiskDetail', 'confirmation'], -}) -export default class HistoricalRisk implements TaskListPage { - documentTitle = "The person's historical risks" - - personName = nameOrPlaceholderCopy(this.application.person) - - title = `${this.personName}'s historical risks` - - questions = getQuestions(this.personName)['risk-information']['historical-risk'] - - body: HistoricalRiskBody - - constructor( - body: Partial, - private readonly application: Application, - ) { - this.body = body as HistoricalRiskBody - } - - previous() { - return 'current-risk' - } - - next() { - return 'acct' - } - - errors() { - const errors: TaskListErrors = {} - - if (!this.body.historicalRiskDetail) { - errors.historicalRiskDetail = `Describe ${this.personName}'s historical issues and needs related to self harm and suicide` - } - - return errors - } -} diff --git a/server/form-pages/apply/risks-and-needs/risk-information/vulnerability.test.ts b/server/form-pages/apply/risks-and-needs/risk-information/vulnerability.test.ts deleted file mode 100644 index a24383d9..00000000 --- a/server/form-pages/apply/risks-and-needs/risk-information/vulnerability.test.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { itShouldHaveNextValue, itShouldHavePreviousValue } from '../../../shared-examples' -import { personFactory, applicationFactory } from '../../../../testutils/factories/index' -import Vulnerability from './vulnerability' - -describe('Vulnerability', () => { - const application = applicationFactory.build({ person: personFactory.build({ name: 'Roger Smith' }) }) - - describe('title', () => { - it('personalises the page title', () => { - const page = new Vulnerability({}, application) - - expect(page.title).toEqual("Roger Smith's vulnerability") - }) - }) - - describe('Questions', () => { - const page = new Vulnerability({}, application) - - describe('vulnerabilityDetail', () => { - it('has a question', () => { - expect(page.questions.vulnerabilityDetail.question).toBeDefined() - }) - }) - }) - - itShouldHaveNextValue(new Vulnerability({}, application), 'current-risk') - itShouldHavePreviousValue(new Vulnerability({}, application), 'taskList') - - describe('errors', () => { - it('returns an error when vulnerabilityDetail is blank', () => { - const page = new Vulnerability({}, application) - expect(page.errors()).toEqual({ - vulnerabilityDetail: "Describe Roger Smith's current circumstances, issues and needs related to vulnerability", - }) - }) - }) -}) diff --git a/server/form-pages/apply/risks-and-needs/risk-information/vulnerability.ts b/server/form-pages/apply/risks-and-needs/risk-information/vulnerability.ts deleted file mode 100644 index 7296b444..00000000 --- a/server/form-pages/apply/risks-and-needs/risk-information/vulnerability.ts +++ /dev/null @@ -1,49 +0,0 @@ -import type { TaskListErrors } from '@approved-premises/ui' -import { Cas2v2Application as Application } from '@approved-premises/api' -import { nameOrPlaceholderCopy } from '../../../../utils/utils' -import { Page } from '../../../utils/decorators' -import TaskListPage from '../../../taskListPage' -import { getQuestions } from '../../../utils/questions' - -type VulnerabilityBody = { vulnerabilityDetail: string; confirmation: string } - -@Page({ - name: 'vulnerability', - bodyProperties: ['vulnerabilityDetail', 'confirmation'], -}) -export default class Vulnerability implements TaskListPage { - documentTitle = "The person's vulnerability" - - personName = nameOrPlaceholderCopy(this.application.person) - - title = `${this.personName}'s vulnerability` - - questions = getQuestions(this.personName)['risk-information'].vulnerability - - body: VulnerabilityBody - - constructor( - body: Partial, - private readonly application: Application, - ) { - this.body = body as VulnerabilityBody - } - - previous() { - return 'taskList' - } - - next() { - return 'current-risk' - } - - errors() { - const errors: TaskListErrors = {} - - if (!this.body.vulnerabilityDetail) { - errors.vulnerabilityDetail = `Describe ${this.personName}'s current circumstances, issues and needs related to vulnerability` - } - - return errors - } -} diff --git a/server/form-pages/apply/risks-and-needs/risk-of-serious-harm/additionalRiskInformation.test.ts b/server/form-pages/apply/risks-and-needs/risk-of-serious-harm/additionalRiskInformation.test.ts deleted file mode 100644 index 0151fa32..00000000 --- a/server/form-pages/apply/risks-and-needs/risk-of-serious-harm/additionalRiskInformation.test.ts +++ /dev/null @@ -1,62 +0,0 @@ -import { itShouldHaveNextValue, itShouldHavePreviousValue } from '../../../shared-examples' -import { personFactory, applicationFactory } from '../../../../testutils/factories/index' -import AdditionalRiskInformation, { AdditionalRiskInformationBody } from './additionalRiskInformation' - -describe('AdditionalRiskInformation', () => { - const application = applicationFactory.build({ person: personFactory.build({ name: 'Roger Smith' }) }) - - describe('title', () => { - it('personalises the page title', () => { - const page = new AdditionalRiskInformation({}, application) - - expect(page.title).toEqual(`Additional risk information for Roger Smith`) - }) - }) - - itShouldHaveNextValue(new AdditionalRiskInformation({}, application), '') - itShouldHavePreviousValue(new AdditionalRiskInformation({}, application), 'cell-share-information') - - describe('errors', () => { - describe('when answer data is valid', () => { - it('returns empty object if valid data', () => { - const page = new AdditionalRiskInformation({ hasAdditionalInformation: 'no' }, application) - expect(page.errors()).toEqual({}) - }) - }) - - describe('when they have not answered the has additional information question', () => { - it('returns an error', () => { - const page = new AdditionalRiskInformation({}, application) - expect(page.errors()).toEqual({ - hasAdditionalInformation: 'Select whether there is any additional risk information', - }) - }) - }) - - describe('when they have answered Yes there is additional information but not provided any', () => { - it('returns an error', () => { - const page = new AdditionalRiskInformation({ hasAdditionalInformation: 'yes' }, application) - expect(page.errors()).toEqual({ - additionalInformationDetail: 'Enter additional information for risk to others', - }) - }) - }) - }) - - describe('onSave', () => { - it('removes additional information data when the question is set to "no"', () => { - const body: AdditionalRiskInformationBody = { - hasAdditionalInformation: 'no', - additionalInformationDetail: 'Additional information', - } - - const page = new AdditionalRiskInformation(body, application) - - page.onSave() - - expect(page.body).toEqual({ - hasAdditionalInformation: 'no', - }) - }) - }) -}) diff --git a/server/form-pages/apply/risks-and-needs/risk-of-serious-harm/additionalRiskInformation.ts b/server/form-pages/apply/risks-and-needs/risk-of-serious-harm/additionalRiskInformation.ts deleted file mode 100644 index 81a1e581..00000000 --- a/server/form-pages/apply/risks-and-needs/risk-of-serious-harm/additionalRiskInformation.ts +++ /dev/null @@ -1,60 +0,0 @@ -import type { TaskListErrors, YesOrNo } from '@approved-premises/ui' -import { Cas2v2Application as Application } from '@approved-premises/api' -import { Page } from '../../../utils/decorators' -import TaskListPage from '../../../taskListPage' -import { nameOrPlaceholderCopy } from '../../../../utils/utils' -import { getQuestions } from '../../../utils/questions' - -export type AdditionalRiskInformationBody = { hasAdditionalInformation: YesOrNo; additionalInformationDetail: string } - -@Page({ - name: 'additional-risk-information', - bodyProperties: ['hasAdditionalInformation', 'additionalInformationDetail'], -}) -export default class AdditionalRiskInformation implements TaskListPage { - documentTitle = 'Additional risk information for the person' - - personName = nameOrPlaceholderCopy(this.application.person) - - title = `Additional risk information for ${this.personName}` - - body: AdditionalRiskInformationBody - - exampleField = 'something' - - questions = getQuestions(this.personName)['risk-of-serious-harm']['additional-risk-information'] - - constructor( - body: Partial, - private readonly application: Application, - ) { - this.body = body as AdditionalRiskInformationBody - } - - previous() { - return 'cell-share-information' - } - - next() { - return '' - } - - errors() { - const errors: TaskListErrors = {} - - if (!this.body.hasAdditionalInformation) { - errors.hasAdditionalInformation = 'Select whether there is any additional risk information' - } - if (this.body.hasAdditionalInformation === 'yes' && !this.body.additionalInformationDetail) { - errors.additionalInformationDetail = 'Enter additional information for risk to others' - } - - return errors - } - - onSave(): void { - if (this.body.hasAdditionalInformation !== 'yes') { - delete this.body.additionalInformationDetail - } - } -} diff --git a/server/form-pages/apply/risks-and-needs/risk-of-serious-harm/cellShareInformation.test.ts b/server/form-pages/apply/risks-and-needs/risk-of-serious-harm/cellShareInformation.test.ts deleted file mode 100644 index 786cf0c2..00000000 --- a/server/form-pages/apply/risks-and-needs/risk-of-serious-harm/cellShareInformation.test.ts +++ /dev/null @@ -1,62 +0,0 @@ -import { itShouldHaveNextValue, itShouldHavePreviousValue } from '../../../shared-examples' -import { personFactory, applicationFactory } from '../../../../testutils/factories/index' -import CellShareInformation, { CellShareInformationBody } from './cellShareInformation' - -describe('CellShareInformation', () => { - const application = applicationFactory.build({ person: personFactory.build({ name: 'Roger Smith' }) }) - - describe('title', () => { - it('personalises the page title', () => { - const page = new CellShareInformation({}, application) - - expect(page.title).toEqual(`Cell share information for Roger Smith`) - }) - }) - - itShouldHaveNextValue(new CellShareInformation({}, application), 'additional-risk-information') - itShouldHavePreviousValue(new CellShareInformation({}, application), 'risk-management-arrangements') - - describe('errors', () => { - describe('when answer data is valid', () => { - it('returns empty object if valid data', () => { - const page = new CellShareInformation({ hasCellShareComments: 'no' }, application) - expect(page.errors()).toEqual({}) - }) - }) - - describe('when they have not answered the has cell share comments question', () => { - it('returns an error', () => { - const page = new CellShareInformation({}, application) - expect(page.errors()).toEqual({ - hasCellShareComments: 'Select whether there are any comments about cell sharing', - }) - }) - }) - - describe('when they have answered Yes there is cell share comments but not provided any', () => { - it('returns an error', () => { - const page = new CellShareInformation({ hasCellShareComments: 'yes' }, application) - expect(page.errors()).toEqual({ - cellShareInformationDetail: 'Enter cell sharing information', - }) - }) - }) - }) - - describe('onSave', () => { - it('removes cell share data when the question is set to "no"', () => { - const body: CellShareInformationBody = { - hasCellShareComments: 'no', - cellShareInformationDetail: 'Cell share information', - } - - const page = new CellShareInformation(body, application) - - page.onSave() - - expect(page.body).toEqual({ - hasCellShareComments: 'no', - }) - }) - }) -}) diff --git a/server/form-pages/apply/risks-and-needs/risk-of-serious-harm/cellShareInformation.ts b/server/form-pages/apply/risks-and-needs/risk-of-serious-harm/cellShareInformation.ts deleted file mode 100644 index cc091e5a..00000000 --- a/server/form-pages/apply/risks-and-needs/risk-of-serious-harm/cellShareInformation.ts +++ /dev/null @@ -1,58 +0,0 @@ -import type { TaskListErrors, YesOrNo } from '@approved-premises/ui' -import { Cas2v2Application as Application } from '@approved-premises/api' -import { Page } from '../../../utils/decorators' -import TaskListPage from '../../../taskListPage' -import { nameOrPlaceholderCopy } from '../../../../utils/utils' -import { getQuestions } from '../../../utils/questions' - -export type CellShareInformationBody = { hasCellShareComments: YesOrNo; cellShareInformationDetail: string } - -@Page({ - name: 'cell-share-information', - bodyProperties: ['hasCellShareComments', 'cellShareInformationDetail'], -}) -export default class CellShareInformation implements TaskListPage { - documentTitle = 'Cell share information for the person' - - personName = nameOrPlaceholderCopy(this.application.person) - - title = `Cell share information for ${this.personName}` - - body: CellShareInformationBody - - questions = getQuestions(this.personName)['risk-of-serious-harm']['cell-share-information'] - - constructor( - body: Partial, - private readonly application: Application, - ) { - this.body = body as CellShareInformationBody - } - - previous() { - return 'risk-management-arrangements' - } - - next() { - return 'additional-risk-information' - } - - errors() { - const errors: TaskListErrors = {} - - if (!this.body.hasCellShareComments) { - errors.hasCellShareComments = 'Select whether there are any comments about cell sharing' - } - if (this.body.hasCellShareComments === 'yes' && !this.body.cellShareInformationDetail) { - errors.cellShareInformationDetail = 'Enter cell sharing information' - } - - return errors - } - - onSave(): void { - if (this.body.hasCellShareComments !== 'yes') { - delete this.body.cellShareInformationDetail - } - } -} diff --git a/server/form-pages/apply/risks-and-needs/risk-of-serious-harm/index.ts b/server/form-pages/apply/risks-and-needs/risk-of-serious-harm/index.ts deleted file mode 100644 index 20d5d87d..00000000 --- a/server/form-pages/apply/risks-and-needs/risk-of-serious-harm/index.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { Task } from '../../../utils/decorators' -import RiskToOthers from './riskToOthers' -import RiskManagementArrangements from './riskManagementArrangements' -import CellShareInformation from './cellShareInformation' -import AdditionalRiskInformation from './additionalRiskInformation' - -@Task({ - name: 'Add risk of serious harm (RoSH) information', - slug: 'risk-of-serious-harm', - pages: [RiskToOthers, RiskManagementArrangements, CellShareInformation, AdditionalRiskInformation], -}) -export default class RiskOfSeriousHarm {} diff --git a/server/form-pages/apply/risks-and-needs/risk-of-serious-harm/riskManagementArrangements.test.ts b/server/form-pages/apply/risks-and-needs/risk-of-serious-harm/riskManagementArrangements.test.ts deleted file mode 100644 index 70be942e..00000000 --- a/server/form-pages/apply/risks-and-needs/risk-of-serious-harm/riskManagementArrangements.test.ts +++ /dev/null @@ -1,178 +0,0 @@ -import { itShouldHaveNextValue, itShouldHavePreviousValue } from '../../../shared-examples' -import { personFactory, applicationFactory } from '../../../../testutils/factories/index' -import RiskManagementArrangements, { RiskManagementArrangementsBody } from './riskManagementArrangements' - -describe('RiskManagementArrangements', () => { - const application = applicationFactory.build({ person: personFactory.build({ name: 'Roger Smith' }) }) - - describe('title', () => { - it('personalises the page title', () => { - const page = new RiskManagementArrangements({}, application) - - expect(page.title).toEqual(`Risk management arrangements for Roger Smith`) - }) - }) - - itShouldHaveNextValue(new RiskManagementArrangements({}, application), 'cell-share-information') - itShouldHavePreviousValue(new RiskManagementArrangements({}, application), 'risk-to-others') - - describe('items', () => { - it('returns the radio with the expected label text', () => { - const page = new RiskManagementArrangements( - { - arrangements: ['mappa', 'marac', 'iom'], - mappaDetails: 'mappa details', - maracDetails: 'marac details', - iomDetails: 'iom details', - }, - application, - ) - - expect(page.items('mappaHtml', 'maracHtml', 'iomHtml')).toEqual([ - { - value: 'mappa', - text: 'Multi-Agency Public Protection Arrangements (MAPPA)', - checked: true, - conditional: { - html: 'mappaHtml', - }, - attributes: { - 'data-selector': 'arrangements', - }, - }, - { - value: 'marac', - text: 'Multi-Agency Risk Assessment Conference (MARAC)', - checked: true, - conditional: { - html: 'maracHtml', - }, - attributes: { - 'data-selector': 'arrangements', - }, - }, - { - value: 'iom', - text: 'Integrated Offender Management (IOM)', - checked: true, - conditional: { - html: 'iomHtml', - }, - attributes: { - 'data-selector': 'arrangements', - }, - }, - { - divider: 'or', - }, - { - value: 'no', - text: 'No, this person does not have risk management arrangements', - checked: false, - }, - ]) - }) - }) - - describe('errors', () => { - const validAnswers = [ - { - arrangements: ['no'], - }, - { - arrangements: ['mappa', 'marac', 'iom'], - mappaDetails: 'mappa details', - maracDetails: 'marac details', - iomDetails: 'iom details', - }, - ] - it.each(validAnswers)('it does not return an error for valid answers', validAnswer => { - const page = new RiskManagementArrangements(validAnswer as RiskManagementArrangementsBody, application) - - expect(page.errors()).toEqual({}) - }) - - it('returns an error is nothing selected', () => { - const page = new RiskManagementArrangements({}, application) - - expect(page.errors()).toEqual({ - arrangements: - "Select risk management arrangements or 'No, this person does not have risk management arrangements'", - }) - }) - - it('returns an error if a MAPPA arrangement has been selected but no details given', () => { - const page = new RiskManagementArrangements( - { arrangements: ['mappa'] } as RiskManagementArrangementsBody, - application, - ) - - expect(page.errors()).toEqual({ mappaDetails: 'Provide MAPPA details' }) - }) - - it('returns an error if a MARAC arrangement has been selected but no details given', () => { - const page = new RiskManagementArrangements( - { arrangements: ['marac'] } as RiskManagementArrangementsBody, - application, - ) - - expect(page.errors()).toEqual({ maracDetails: 'Provide MARAC details' }) - }) - - it('returns an error if an IOM arrangement has been selected but no details given', () => { - const page = new RiskManagementArrangements( - { arrangements: ['iom'] } as RiskManagementArrangementsBody, - application, - ) - - expect(page.errors()).toEqual({ iomDetails: 'Provide IOM details' }) - }) - }) - - describe('onSave', () => { - it('removes MAPPA data if option is not selected', () => { - const body: RiskManagementArrangementsBody = { - arrangements: ['no'], - mappaDetails: 'MAPPA details', - } - - const page = new RiskManagementArrangements(body, application) - - page.onSave() - - expect(page.body).toEqual({ - arrangements: ['no'], - }) - }) - - it('removes IOM data if option is not selected', () => { - const body: RiskManagementArrangementsBody = { - arrangements: ['no'], - iomDetails: 'IOM details', - } - - const page = new RiskManagementArrangements(body, application) - - page.onSave() - - expect(page.body).toEqual({ - arrangements: ['no'], - }) - }) - - it('removes MARAC data if option is not selected', () => { - const body: RiskManagementArrangementsBody = { - arrangements: ['no'], - maracDetails: 'MARAC details', - } - - const page = new RiskManagementArrangements(body, application) - - page.onSave() - - expect(page.body).toEqual({ - arrangements: ['no'], - }) - }) - }) -}) diff --git a/server/form-pages/apply/risks-and-needs/risk-of-serious-harm/riskManagementArrangements.ts b/server/form-pages/apply/risks-and-needs/risk-of-serious-harm/riskManagementArrangements.ts deleted file mode 100644 index 35425b58..00000000 --- a/server/form-pages/apply/risks-and-needs/risk-of-serious-harm/riskManagementArrangements.ts +++ /dev/null @@ -1,109 +0,0 @@ -import type { Radio, TaskListErrors } from '@approved-premises/ui' -import { Cas2v2Application as Application } from '@approved-premises/api' -import { Page } from '../../../utils/decorators' -import TaskListPage from '../../../taskListPage' -import { nameOrPlaceholderCopy } from '../../../../utils/utils' -import { convertKeyValuePairToCheckboxItems } from '../../../../utils/formUtils' -import { getQuestions } from '../../../utils/questions' - -const arrangementOptions = { - mappa: 'Multi-Agency Public Protection Arrangements (MAPPA)', - marac: 'Multi-Agency Risk Assessment Conference (MARAC)', - iom: 'Integrated Offender Management (IOM)', - no: 'No, this person does not have risk management arrangements', -} - -export type RiskManagementArrangementsOptions = keyof typeof arrangementOptions - -export type RiskManagementArrangementsBody = { - arrangements: Array - mappaDetails?: string - maracDetails?: string - iomDetails?: string -} - -@Page({ - name: 'risk-management-arrangements', - bodyProperties: ['arrangements', 'mappaDetails', 'maracDetails', 'iomDetails'], -}) -export default class RiskManagementArrangements implements TaskListPage { - documentTitle = 'Risk management arrangements' - - personName = nameOrPlaceholderCopy(this.application.person) - - title = `Risk management arrangements for ${this.personName}` - - body: RiskManagementArrangementsBody - - questions = getQuestions(this.personName)['risk-of-serious-harm']['risk-management-arrangements'] - - constructor( - body: Partial, - private readonly application: Application, - ) { - this.body = body as RiskManagementArrangementsBody - } - - previous() { - return 'risk-to-others' - } - - next() { - return 'cell-share-information' - } - - errors() { - const errors: TaskListErrors = {} - - if (!this.body.arrangements) { - errors.arrangements = - "Select risk management arrangements or 'No, this person does not have risk management arrangements'" - } else { - if (this.body.arrangements.includes('mappa') && !this.body.mappaDetails) { - errors.mappaDetails = 'Provide MAPPA details' - } - if (this.body.arrangements.includes('marac') && !this.body.maracDetails) { - errors.maracDetails = 'Provide MARAC details' - } - if (this.body.arrangements.includes('iom') && !this.body.iomDetails) { - errors.iomDetails = 'Provide IOM details' - } - } - - return errors - } - - items(mappaDetailsHtml: string, maracDetailsHtml: string, iomDetailsHtml: string) { - const items = convertKeyValuePairToCheckboxItems(arrangementOptions, this.body.arrangements) as [Radio] - - items.forEach(item => { - if (item.value === 'mappa') { - item.attributes = { 'data-selector': 'arrangements' } - item.conditional = { html: mappaDetailsHtml } - } else if (item.value === 'marac') { - item.attributes = { 'data-selector': 'arrangements' } - item.conditional = { html: maracDetailsHtml } - } else if (item.value === 'iom') { - item.attributes = { 'data-selector': 'arrangements' } - item.conditional = { html: iomDetailsHtml } - } - }) - const noCheckbox = items.pop() - - return [...items, { divider: 'or' }, { ...noCheckbox }] - } - - onSave(): void { - if (!this.body.arrangements.includes('mappa')) { - delete this.body.mappaDetails - } - - if (!this.body.arrangements.includes('iom')) { - delete this.body.iomDetails - } - - if (!this.body.arrangements.includes('marac')) { - delete this.body.maracDetails - } - } -} diff --git a/server/form-pages/apply/risks-and-needs/risk-of-serious-harm/riskToOthers.test.ts b/server/form-pages/apply/risks-and-needs/risk-of-serious-harm/riskToOthers.test.ts deleted file mode 100644 index 0e9ede9c..00000000 --- a/server/form-pages/apply/risks-and-needs/risk-of-serious-harm/riskToOthers.test.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { itShouldHaveNextValue, itShouldHavePreviousValue } from '../../../shared-examples' -import { personFactory, applicationFactory } from '../../../../testutils/factories/index' -import RiskToOthers from './riskToOthers' - -describe('RiskToOthers', () => { - const application = applicationFactory.build({ person: personFactory.build({ name: 'Roger Smith' }) }) - - describe('title', () => { - it('personalises the page title', () => { - const page = new RiskToOthers({}, application) - - expect(page.title).toEqual(`Risk to others for Roger Smith`) - }) - }) - - itShouldHaveNextValue(new RiskToOthers({}, application), 'risk-management-arrangements') - itShouldHavePreviousValue(new RiskToOthers({}, application), 'taskList') - - describe('errors', () => { - it('returns an error when required fields are blank', () => { - const page = new RiskToOthers({}, application) - expect(page.errors()).toEqual({ - whoIsAtRisk: 'Enter who is at risk', - natureOfRisk: 'Enter the nature of the risk', - }) - }) - }) -}) diff --git a/server/form-pages/apply/risks-and-needs/risk-of-serious-harm/riskToOthers.ts b/server/form-pages/apply/risks-and-needs/risk-of-serious-harm/riskToOthers.ts deleted file mode 100644 index 74e519aa..00000000 --- a/server/form-pages/apply/risks-and-needs/risk-of-serious-harm/riskToOthers.ts +++ /dev/null @@ -1,53 +0,0 @@ -import type { TaskListErrors } from '@approved-premises/ui' -import { Cas2v2Application as Application } from '@approved-premises/api' -import { Page } from '../../../utils/decorators' -import TaskListPage from '../../../taskListPage' -import { nameOrPlaceholderCopy } from '../../../../utils/utils' -import errorLookups from '../../../../i18n/en/errors.json' -import { getQuestions } from '../../../utils/questions' - -type RiskToOthersBody = { whoIsAtRisk: string; natureOfRisk: string; confirmation: string } - -@Page({ - name: 'risk-to-others', - bodyProperties: ['whoIsAtRisk', 'natureOfRisk', 'confirmation'], -}) -export default class RiskToOthers implements TaskListPage { - documentTitle = 'Risk to others for the person' - - personName = nameOrPlaceholderCopy(this.application.person) - - title = `Risk to others for ${this.personName}` - - body: RiskToOthersBody - - questions = getQuestions(this.personName)['risk-of-serious-harm']['risk-to-others'] - - constructor( - body: Partial, - private readonly application: Application, - ) { - this.body = body as RiskToOthersBody - } - - previous() { - return 'taskList' - } - - next() { - return 'risk-management-arrangements' - } - - errors() { - const errors: TaskListErrors = {} - - if (!this.body.whoIsAtRisk) { - errors.whoIsAtRisk = errorLookups.whoIsAtRisk.empty - } - if (!this.body.natureOfRisk) { - errors.natureOfRisk = errorLookups.natureOfRisk.empty - } - - return errors - } -} diff --git a/server/form-pages/utils/questions.ts b/server/form-pages/utils/questions.ts index a945b3c1..f9c59674 100644 --- a/server/form-pages/utils/questions.ts +++ b/server/form-pages/utils/questions.ts @@ -667,24 +667,6 @@ export const getQuestions = (name: string) => { 'violence-and-arson': {}, 'risks-to-staff': {}, 'additional-concerns': {}, - vulnerability: { - vulnerabilityDetail: { - question: `Describe ${name}'s current circumstances, issues and needs related to vulnerability`, - hint: 'Include all current risk information and remove sensitive information, such as names and addresses.', - }, - }, - 'current-risk': { - currentRiskDetail: { - question: `Describe ${name}'s current issues and needs related to self harm and suicide`, - hint: 'Include all current risk information and remove sensitive information, such as names and addresses.', - }, - }, - 'historical-risk': { - historicalRiskDetail: { - question: `Describe ${name}'s historical issues and needs related to self harm and suicide`, - hint: 'Remove sensitive information, such as names and addresses.', - }, - }, 'acct-data': { createdDate: { question: 'When was the ACCT created?', @@ -705,66 +687,6 @@ export const getQuestions = (name: string) => { question: 'Details about the ACCT', }, }, - 'additional-information': { - hasAdditionalInformation: { - question: `Is there anything else to include about ${name}'s risk to self?`, - hint: 'Record any additional information about their risk to self.', - answers: yesOrNo, - }, - additionalInformationDetail: { question: 'Additional information' }, - }, - }, - 'risk-of-serious-harm': { - 'risk-to-others': { - whoIsAtRisk: { - question: 'Who is at risk?', - }, - natureOfRisk: { - question: 'What is the nature of the risk?', - }, - confirmation: { - question: 'I confirm this information is relevant and up to date.', - answers: { confirmed: 'Confirmed' }, - }, - }, - 'risk-management-arrangements': { - arrangements: { - question: `Is ${name} subject to any of these multi-agency risk management arrangements upon release?`, - hint: 'Select all that apply', - answers: { - mappa: 'MAPPA', - marac: 'MARAC', - iom: 'IOM', - }, - }, - mappaDetails: { - question: 'Provide MAPPA details', - hint: 'Specify whether the MAPPA is Category 2 or Category 3. Include lead contact details where possible.', - }, - maracDetails: { - question: 'Provide MARAC details', - hint: 'Include lead contact details where possible.', - }, - iomDetails: { - question: 'Provide IOM details', - hint: 'Include lead contact details where possible.', - }, - }, - 'cell-share-information': { - hasCellShareComments: { - question: 'Are there any comments to add about cell sharing?', - answers: yesOrNo, - }, - cellShareInformationDetail: { question: 'Cell sharing information' }, - }, - 'additional-risk-information': { - hasAdditionalInformation: { - question: `Is there any other risk information for ${name}?`, - hint: 'If known, state their incentive level, also known as Incentive and Enhanced Privileges (IEP), and any other information about their risk to others.', - answers: yesOrNo, - }, - additionalInformationDetail: { question: 'Additional information' }, - }, }, 'community-supervision-and-current-offences': { 'community-supervision': { diff --git a/server/views/applications/pages/risk-information/additional-information.njk b/server/views/applications/pages/risk-information/additional-information.njk deleted file mode 100644 index 338582d7..00000000 --- a/server/views/applications/pages/risk-information/additional-information.njk +++ /dev/null @@ -1,51 +0,0 @@ -{% extends "../layout.njk" %} -{% set pageName = "additional-information" %} - -{% block questions %} - {% set additionalInformationDetail %} - {{ - formPageTextArea( - { - fieldName: 'additionalInformationDetail', - label: { - text: page.questions.additionalInformationDetail.question, - classes: "govuk-label--s" - } - }, - fetchContext() - ) - }} - {% endset %} - - {{ - formPageRadios( - { - fieldName: "hasAdditionalInformation", - fieldset: { - legend: { - text: page.questions.hasAdditionalInformation.question, - classes: "govuk-fieldset__legend--l", - isPageHeading: true - } - }, - hint: { - text: page.questions.hasAdditionalInformation.hint - }, - items: [ - { - value: "yes", - text: "Yes", - conditional: { - html: additionalInformationDetail - } - }, - { - value: "no", - text: "No" - } - ] - }, - fetchContext() - ) - }} -{% endblock %} diff --git a/server/views/applications/pages/risk-information/current-risk.njk b/server/views/applications/pages/risk-information/current-risk.njk deleted file mode 100644 index 520e37b1..00000000 --- a/server/views/applications/pages/risk-information/current-risk.njk +++ /dev/null @@ -1,56 +0,0 @@ -{% from "govuk/components/inset-text/macro.njk" import govukInsetText %} - -{% extends "./_risk-information-screen.njk" %} - -{% set pageName = "current-risk" %} - -{% block questions %} - {% set currentRiskDetailHintHtml %} -

If known, provide details including:

- -
    -
  • - whether they are assessed as being at imminent risk of self harm or suicide and require ongoing monitoring to reduce the risk -
  • -
  • - methods of self harm -
  • -
  • - methods of attempted suicide -
  • -
  • - the last recent incident of self harm or suicide  -
  • -
  • - how often self harming or suicide attempts happens -
  • -
  • - how severe their self harming or suicide attempts are. For example, if an incident required an emergency response -
  • -
  • - triggers for self harm or suicide attempts -
  • -
  • - signs of increased risk for self harm or suicide attempts -
  • -
- -

Remove sensitive information, such as names and addresses.

- {% endset %} - - {{ - formPageTextArea( - { - fieldName: 'currentRiskDetail', - label: { - text: page.questions.currentRiskDetail.question, - classes: "govuk-label--m" - }, - hint: { - html: currentRiskDetailHintHtml - } - }, - fetchContext() - ) - }} -{% endblock %} diff --git a/server/views/applications/pages/risk-information/historical-risk.njk b/server/views/applications/pages/risk-information/historical-risk.njk deleted file mode 100644 index f6ba2483..00000000 --- a/server/views/applications/pages/risk-information/historical-risk.njk +++ /dev/null @@ -1,57 +0,0 @@ -{% from "govuk/components/inset-text/macro.njk" import govukInsetText %} - -{% extends "./_risk-information-screen.njk" %} - -{% set pageName = "historical-risk" %} - -{% block questions %} - {% set historicalRiskDetailHintHtml %} -

If known, provide details including:

- -
    -
  • - whether they have been assessed as being at imminent risk of self harm or suicide and required ongoing monitoring to reduce the risk -
  • -
  • - methods of self harm -
  • -
  • - methods of attempted suicide -
  • -
  • - the last recent incident of self harm or suicide  -
  • -
  • - how often self harming or suicide attempts happened -
  • -
  • - how severe their self harming or suicide attempts were. For example, if an incident required an emergency response -
  • -
  • - triggers for self harm or suicide attempts -
  • -
  • - signs of increased risk for self harm or suicide attempts -
  • -
- -

Remove sensitive information, such as names and addresses.

- {% endset %} - - {{ - formPageTextArea( - { - fieldName: 'historicalRiskDetail', - label: { - text: page.questions.historicalRiskDetail.question, - classes: "govuk-label--m" - }, - hint: { - html: historicalRiskDetailHintHtml - } - }, - fetchContext() - ) - }} - -{% endblock %} diff --git a/server/views/applications/pages/risk-information/vulnerability.njk b/server/views/applications/pages/risk-information/vulnerability.njk deleted file mode 100644 index 1709bf65..00000000 --- a/server/views/applications/pages/risk-information/vulnerability.njk +++ /dev/null @@ -1,47 +0,0 @@ -{% from "govuk/components/inset-text/macro.njk" import govukInsetText %} -{% extends "./_risk-information-screen.njk" %} - -{% set pageName = "vulnerability" %} - -{% block questions %} - -

- A person is vulnerable if there is a risk of other people harming them. Someone may be vulnerable in prison, in the community, or both. -

- -

- Being vulnerable in prison includes being victimised, bullied or assaulted by others. -

- -

- Being vulnerable in the community includes experiencing or being at risk of: -

    -
  • domestic abuse
  • -
  • physical, financial or psychological abuse
  • -
  • sex work
  • -
  • bullying
  • -
  • gang affiliated risks
  • -
  • cuckooing (their home being taken over and used for criminal activity)
  • -
  • modern day slavery, such as forced labour and sexual or criminal exploitation
  • -
-

- -
- - {{ - formPageTextArea( - { - fieldName: 'vulnerabilityDetail', - label: { - text: page.questions.vulnerabilityDetail.question, - classes: "govuk-label--m" - }, - hint: { - text: 'Include all current risk information and remove sensitive information, such as names and addresses.' - } - }, - fetchContext() - ) - }} - -{% endblock %} diff --git a/server/views/applications/pages/risk-of-serious-harm/_risk-of-serious-harm-screen.njk b/server/views/applications/pages/risk-of-serious-harm/_risk-of-serious-harm-screen.njk deleted file mode 100644 index a33acecb..00000000 --- a/server/views/applications/pages/risk-of-serious-harm/_risk-of-serious-harm-screen.njk +++ /dev/null @@ -1,42 +0,0 @@ -{%- from "moj/components/side-navigation/macro.njk" import mojSideNavigation -%} - -{% extends "../layout.njk" %} - -{% set columnClasses = "govuk-grid-column-full" %} - -{% block content %} -
-
-

{{ page.title }}

-
-
- -
-
- {{ mojSideNavigation({ - items: [{ - text: 'Risk to others', - href: paths.applications.pages.show({ id: applicationId, task: 'risk-of-serious-harm', page: 'risk-to-others' }), - active: (pageName === 'risk-to-others') - }, { - text: 'Risk management arrangements', - href: paths.applications.pages.show({ id: applicationId, task: 'risk-of-serious-harm', page: 'risk-management-arrangements' }), - active: (pageName === 'risk-management-arrangements') - }, { - text: 'Cell share information', - href: paths.applications.pages.show({ id: applicationId, task: 'risk-of-serious-harm', page: 'cell-share-information' }), - active: (pageName === 'cell-share-information') - }, { - text: 'Additional risk information', - href: paths.applications.pages.show({ id: applicationId, task: 'risk-of-serious-harm', page: 'additional-risk-information' }), - active: (pageName === 'additional-risk-information') - }] - }) }} -
- -
- {{ super() }} -
- -
-{% endblock %} diff --git a/server/views/applications/pages/risk-of-serious-harm/additional-risk-information.njk b/server/views/applications/pages/risk-of-serious-harm/additional-risk-information.njk deleted file mode 100644 index 8a31e692..00000000 --- a/server/views/applications/pages/risk-of-serious-harm/additional-risk-information.njk +++ /dev/null @@ -1,50 +0,0 @@ -{% extends "./_risk-of-serious-harm-screen.njk" %} -{% set pageName = "additional-risk-information" %} - -{% block questions %} - {% set additionalInformationDetail %} - {{ - formPageTextArea( - { - fieldName: 'additionalInformationDetail', - label: { - text: page.questions.additionalInformationDetail.question, - classes: "govuk-label--s" - } - }, - fetchContext() - ) - }} - {% endset %} - - {{ - formPageRadios( - { - fieldName: "hasAdditionalInformation", - fieldset: { - legend: { - text: page.questions.hasAdditionalInformation.question, - classes: "govuk-fieldset__legend--m" - } - }, - hint: { - text: page.questions.hasAdditionalInformation.hint - }, - items: [ - { - value: "yes", - text: "Yes", - conditional: { - html: additionalInformationDetail - } - }, - { - value: "no", - text: "No" - } - ] - }, - fetchContext() - ) - }} -{% endblock %} \ No newline at end of file diff --git a/server/views/applications/pages/risk-of-serious-harm/cell-share-information.njk b/server/views/applications/pages/risk-of-serious-harm/cell-share-information.njk deleted file mode 100644 index 196da19a..00000000 --- a/server/views/applications/pages/risk-of-serious-harm/cell-share-information.njk +++ /dev/null @@ -1,51 +0,0 @@ -{% extends "./_risk-of-serious-harm-screen.njk" %} -{% set pageName = "cell-share-information" %} - -{% block questions %} - {% set cellShareInformationDetail %} - {{ - formPageTextArea( - { - fieldName: 'cellShareInformationDetail', - label: { - text: page.questions.cellShareInformationDetail.question, - classes: "govuk-label--s" - } - }, - fetchContext() - ) - }} - {% endset %} - - {{ - formPageRadios( - { - fieldName: "hasCellShareComments", - fieldset: { - legend: { - text: page.questions.hasCellShareComments.question, - classes: "govuk-fieldset__legend--m" - } - }, - hint: { - text: "This includes anything that could affect others if sharing accommodation. For example, racial alerts and history of drug supply." - }, - items: [ - { - value: "yes", - text: "Yes", - conditional: { - html: cellShareInformationDetail - } - }, - { - value: "no", - text: "No" - } - ] - }, - fetchContext() - ) - }} - - {% endblock %} \ No newline at end of file diff --git a/server/views/applications/pages/risk-of-serious-harm/risk-management-arrangements.njk b/server/views/applications/pages/risk-of-serious-harm/risk-management-arrangements.njk deleted file mode 100644 index 4eaac206..00000000 --- a/server/views/applications/pages/risk-of-serious-harm/risk-management-arrangements.njk +++ /dev/null @@ -1,125 +0,0 @@ -{% extends "./_risk-of-serious-harm-screen.njk" %} -{% set pageName = "risk-management-arrangements" %} - -{% block questions %} - - {% set mappaDetails %} - {{ - formPageTextArea( - { - label: { - text: page.questions.mappaDetails.question, - classes: "govuk-label--s" - }, - fieldName: "mappaDetails", - hint: { - text: page.questions.mappaDetails.hint - } - }, - fetchContext() - ) - }} - {% endset -%} - - {% set maracDetails %} - {{ - formPageTextArea( - { - label: { - text: page.questions.maracDetails.question, - classes: "govuk-label--s" - }, - fieldName: "maracDetails", - hint: { - text: page.questions.maracDetails.hint - } - }, - fetchContext() - ) - }} - {% endset -%} - - {% set iomDetails %} - {{ - formPageTextArea( - { - label: { - text: page.questions.iomDetails.question, - classes: "govuk-label--s" - }, - fieldName: "iomDetails", - hint: { - text: page.questions.iomDetails.hint - } - }, - fetchContext() - ) - }} - {% endset -%} - -

- You should check with {{ page.personName }}'s Community Probation Practitioner (CPP), - also known as Community Offender Manager (COM), for up-to-date risk management arrangements. -

-

- You can also check the 'Risk Management Plan' section in OASys. -

- -
- - {{ - formPageCheckboxes( - { - fieldName: "arrangements", - hint: { - text: page.questions.arrangements.hint - }, - fieldset: { - legend: { - text: page.questions.arrangements.question, - classes: "govuk-fieldset__legend--m" - } - }, - items: page.items(mappaDetails, maracDetails, iomDetails) - }, - fetchContext() - ) - }} - -{% endblock %} - -{% block extraScripts %} - -{% endblock %} \ No newline at end of file diff --git a/server/views/applications/pages/risk-of-serious-harm/risk-to-others.njk b/server/views/applications/pages/risk-of-serious-harm/risk-to-others.njk deleted file mode 100644 index f430a8c8..00000000 --- a/server/views/applications/pages/risk-of-serious-harm/risk-to-others.njk +++ /dev/null @@ -1,68 +0,0 @@ -{% from "govuk/components/inset-text/macro.njk" import govukInsetText %} -{% extends "./_risk-of-serious-harm-screen.njk" %} - -{% set pageName = "risk-to-others" %} - -{% set whoIsAtRiskHintHTML %} -

The risk to children, the public, known adults or staff.

-

You should include:

- -
    -
  • full names of anyone at risk, if known and currently at risk
  • -
  • their relationship to the applicant where appropriate, their location, or state if this is not known
  • -
- -

For example: “The applicant's ex-partner, Tina Hopkins, is considered at risk. They live with their mother in Lewes.”

-{% endset %} - -{% set natureOfRiskHintHTML %} -

The property supplier needs to know

- -
    -
  • what the type of risk is for children, the public, known adults or staff, for example physical or psychological abuse
  • -
  • details of the last incident, if known
  • -
  • factors that could increase the risk
  • -
  • if social services or domestic abuse agencies have been involved
  • -
  • if there are any safeguarding measures in place
  • -
- -

- For example: “Current or ex-partners: psychological and physical abuse when the applicant has been drinking alcohol. - Domestic abuse services have never been involved. The applicant has been abstinent and will continue to engage with - drug and alcohol services.” -

-{% endset %} - -{% block questions %} - {{ - formPageTextArea( - { - fieldName: 'whoIsAtRisk', - label: { - text: page.questions.whoIsAtRisk.question, - classes: "govuk-label--m" - }, - hint: { - html: whoIsAtRiskHintHTML - } - }, - fetchContext() - ) - }} - - {{ - formPageTextArea( - { - fieldName: 'natureOfRisk', - label: { - text: page.questions.natureOfRisk.question, - classes: "govuk-label--m" - }, - hint: { - html: natureOfRiskHintHTML - } - }, - fetchContext() - ) - }} -{% endblock %} From ddf1ccab05b7e9977a291d8e0cb35808637f4cc7 Mon Sep 17 00:00:00 2001 From: Daniel Liburd Date: Thu, 27 Feb 2025 15:01:31 +0000 Subject: [PATCH 15/17] Replace RoSH tests We were testing that checkYourAnswers correctly handled answers in the form of lists, as the RoSH questions have been removed, we need to use another page to test this functionality. This highlighted a bug in the application data for funding ID documents. --- integration_tests/fixtures/applicationData.json | 2 +- server/utils/checkYourAnswersUtils.test.ts | 14 +++++--------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/integration_tests/fixtures/applicationData.json b/integration_tests/fixtures/applicationData.json index db26406e..8192f48a 100644 --- a/integration_tests/fixtures/applicationData.json +++ b/integration_tests/fixtures/applicationData.json @@ -52,7 +52,7 @@ "inEducationOrTraining": "no" }, "applicant-id": { - "idDocuments": "passport" + "idDocuments": ["passport", "travelPass", "birthCertificate", "bankOrDebitCard", "bankStatements", "drivingLicence", "wageSlip", "none"] } }, "solicitor-details": { diff --git a/server/utils/checkYourAnswersUtils.test.ts b/server/utils/checkYourAnswersUtils.test.ts index 69359eed..f4983bb8 100644 --- a/server/utils/checkYourAnswersUtils.test.ts +++ b/server/utils/checkYourAnswersUtils.test.ts @@ -446,7 +446,7 @@ describe('checkYourAnswersUtils', () => { it('returns array answers as string given an array of defined answers', () => { const arrayAnswersAsStringSpy = jest.spyOn(checkYourAnswersUtils, 'arrayAnswersAsString') - getAnswer(application, questions, 'risk-of-serious-harm', 'risk-management-arrangements', 'arrangements') + getAnswer(application, questions, 'funding-information', 'applicant-id', 'idDocuments') expect(arrayAnswersAsStringSpy).toHaveBeenCalledTimes(1) }) @@ -477,14 +477,10 @@ describe('checkYourAnswersUtils', () => { describe('arrayAnswersAsString', () => { it('returns an array of string answers as a comma separated string', () => { expect( - arrayAnswersAsString( - application, - questions, - 'risk-of-serious-harm', - 'risk-management-arrangements', - 'arrangements', - ), - ).toEqual('MAPPA,MARAC,IOM') + arrayAnswersAsString(application, questions, 'funding-information', 'applicant-id', 'idDocuments'), + ).toEqual( + 'Passport,Travel pass with photograph,Birth certificate,Bank account or debit card,Bank, building society or Post Office card account statements,UK photo driving licence (full or provisional),Recent wage slip (with payee name and NI number),None of these options', + ) }) }) From 57f1bd2094ce9512f2923ee190af68739c0cb0ea Mon Sep 17 00:00:00 2001 From: Daniel Liburd Date: Thu, 27 Feb 2025 16:37:05 +0000 Subject: [PATCH 16/17] Add missing ACCT integration tests --- .../risk-information/acctDataPage.ts | 42 ++++++ .../risk-information/acctPage.ts | 35 +++++ integration_tests/pages/page.ts | 12 ++ .../complete_acct_data_page.cy.ts | 98 ++++++++++++++ .../risk-information/complete_acct_page.cy.ts | 122 ++++++++++++++++++ 5 files changed, 309 insertions(+) create mode 100644 integration_tests/pages/apply/risks-and-needs/risk-information/acctDataPage.ts create mode 100644 integration_tests/pages/apply/risks-and-needs/risk-information/acctPage.ts create mode 100644 integration_tests/tests/apply/risks-and-needs/risk-information/complete_acct_data_page.cy.ts create mode 100644 integration_tests/tests/apply/risks-and-needs/risk-information/complete_acct_page.cy.ts diff --git a/integration_tests/pages/apply/risks-and-needs/risk-information/acctDataPage.ts b/integration_tests/pages/apply/risks-and-needs/risk-information/acctDataPage.ts new file mode 100644 index 00000000..813d1d85 --- /dev/null +++ b/integration_tests/pages/apply/risks-and-needs/risk-information/acctDataPage.ts @@ -0,0 +1,42 @@ +import { Cas2v2Application as Application } from '../../../../../server/@types/shared/models/Cas2v2Application' +import ApplyPage from '../../applyPage' +import paths from '../../../../../server/paths/apply' + +export default class AcctDataPage extends ApplyPage { + constructor(private readonly application: Application) { + super('Add an ACCT entry', application, 'risk-information', 'acct-data') + } + + static visit(application: Application): void { + cy.visit( + paths.applications.pages.show({ + id: application.id, + task: 'risk-information', + page: 'acct-data', + }), + ) + } + + addACCTInformation(): void { + this.completeDateInputs('createdDate', '2022-07-15') + this.checkRadioByNameAndValue('isOngoing', 'no') + this.completeDateInputs('closedDate', '2023-07-15') + this.getTextInputByIdAndEnterDetails('referringInstitution', 'HMPPS prison') + this.getTextInputByIdAndEnterDetails('acctDetails', 'some detail') + } + + clickSubmit(): void { + cy.get('button').contains('Save and add ACCT').click() + } + + clickAddAnother(): void { + cy.get('button').contains('Save and add another').click() + } + + assertFormisEmpty(): void { + cy.get('#createdDate-day').should('have.value', '') + cy.get('#isOngoing').should('not.be.checked') + cy.get('#referringInstitution').should('have.value', '') + cy.get('#acctDetails').should('have.value', '') + } +} diff --git a/integration_tests/pages/apply/risks-and-needs/risk-information/acctPage.ts b/integration_tests/pages/apply/risks-and-needs/risk-information/acctPage.ts new file mode 100644 index 00000000..94f1dde5 --- /dev/null +++ b/integration_tests/pages/apply/risks-and-needs/risk-information/acctPage.ts @@ -0,0 +1,35 @@ +import { Cas2v2Application as Application } from '../../../../../server/@types/shared/models/Cas2v2Application' +import ApplyPage from '../../applyPage' +import paths from '../../../../../server/paths/apply' +import { nameOrPlaceholderCopy } from '../../../../../server/utils/utils' + +export default class AcctPage extends ApplyPage { + constructor(private readonly application: Application) { + super( + `${nameOrPlaceholderCopy(application.person, 'The person')}'s ACCT notes`, + application, + 'risk-information', + 'acct', + ) + } + + static visit(application: Application): void { + cy.visit( + paths.applications.pages.show({ + id: application.id, + task: 'risk-information', + page: 'acct', + }), + ) + } + + hasListOfAccts(): void { + cy.get('.govuk-summary-card__title').contains('1 February 2012 - 10 October 2013') + cy.get('.govuk-summary-list').contains('HMPPS prison') + cy.get('.govuk-summary-list').should('contain.html', 'ACCT details
some more details on another line') + } + + hasNoAccts(): void { + cy.get('.govuk-body').contains('No ACCT notes have been added.') + } +} diff --git a/integration_tests/pages/page.ts b/integration_tests/pages/page.ts index 1ccc5483..2f8b4ccf 100644 --- a/integration_tests/pages/page.ts +++ b/integration_tests/pages/page.ts @@ -1,6 +1,7 @@ import 'cypress-axe' import { Result } from 'axe-core' import errorLookups from '../../server/i18n/en/errors.json' +import { DateFormats } from '../../server/utils/dateUtils' export type PageElement = Cypress.Chainable @@ -89,4 +90,15 @@ export default abstract class Page { clickLink(label: string): void { cy.get('a:visible').contains(label).click() } + + clickRemove(): void { + cy.get('a').contains('Remove').click() + } + + completeDateInputs(prefix: string, date: string): void { + const parsedDate = DateFormats.isoToDateObj(date) + cy.get(`#${prefix}-day`).type(parsedDate.getDate().toString()) + cy.get(`#${prefix}-month`).type(`${parsedDate.getMonth() + 1}`) + cy.get(`#${prefix}-year`).type(parsedDate.getFullYear().toString()) + } } diff --git a/integration_tests/tests/apply/risks-and-needs/risk-information/complete_acct_data_page.cy.ts b/integration_tests/tests/apply/risks-and-needs/risk-information/complete_acct_data_page.cy.ts new file mode 100644 index 00000000..522f77c5 --- /dev/null +++ b/integration_tests/tests/apply/risks-and-needs/risk-information/complete_acct_data_page.cy.ts @@ -0,0 +1,98 @@ +// Feature: Referrer completes 'Add an ACCT' page +// So that I can complete the "Risk information" task +// As a referrer +// I want to complete the 'Add an ACCT' page +// +// Background: +// Given an application exists +// And I am logged in +// And I am on the "Add an ACCT" page +// +// Scenario: I fill in required information for an ACCT +// And I save and contnue +// Then I am taken back to the ACCT page +// +// Scenario: Add another ACCT +// Given I have filled in required information for an ACCT +// When I save and add another +// Then I am taken to a blank "Add an ACCT" page +// And I see a success message + +import AcctPage from '../../../../pages/apply/risks-and-needs/risk-information/acctPage' +import AcctDataPage from '../../../../pages/apply/risks-and-needs/risk-information/acctDataPage' +import Page from '../../../../pages/page' +import { personFactory, applicationFactory } from '../../../../../server/testutils/factories/index' + +context('Visit "Risks and needs" section', () => { + const person = personFactory.build({ name: 'Roger Smith' }) + + beforeEach(function test() { + cy.task('reset') + cy.task('stubSignIn') + cy.task('stubAuthUser') + + cy.fixture('applicationData.json').then(applicationData => { + delete applicationData['risk-information'] + const application = applicationFactory.build({ + id: 'abc123', + person, + data: applicationData, + }) + cy.wrap(application).as('application') + }) + + cy.fixture('applicationData.json').then(applicationData => { + const applicationWithData = { + ...this.application, + data: applicationData, + } + cy.wrap(applicationWithData).as('applicationWithData') + }) + }) + + beforeEach(function test() { + // And an application exists + // ------------------------- + cy.task('stubApplicationGet', { application: this.application }) + cy.task('stubApplicationUpdate', { application: this.application }) + + // Given I am logged in + //--------------------- + cy.signIn() + + // And I am on the "Add an ACCT" page + // -------------------------------- + AcctDataPage.visit(this.application) + }) + + // Scenario: I fill in required information for an ACCT + // When I continue to the next task / page + // Then I see the "ACCT" page + it('navigates to the next page (ACCT page)', function test() { + const page = new AcctDataPage(this.application) + + page.addACCTInformation() + + page.clickSubmit() + + Page.verifyOnPage(AcctPage, this.application) + }) + + // Scenario: Add another ACCT + it('returns to form when adding another', function test() { + const page = new AcctDataPage(this.application) + + // Given I have filled in required information for an ACCT + page.addACCTInformation() + + // When I save and add another + page.clickAddAnother() + + // Then I am taken to a blank "Add an ACCT" page + Page.verifyOnPage(AcctDataPage, this.application) + page.assertFormisEmpty() + + // And I see a success message + page.shouldShowSuccessMessage('The ACCT has been saved') + }) +}) diff --git a/integration_tests/tests/apply/risks-and-needs/risk-information/complete_acct_page.cy.ts b/integration_tests/tests/apply/risks-and-needs/risk-information/complete_acct_page.cy.ts new file mode 100644 index 00000000..4c041343 --- /dev/null +++ b/integration_tests/tests/apply/risks-and-needs/risk-information/complete_acct_page.cy.ts @@ -0,0 +1,122 @@ +// Feature: Referrer completes 'Risk information: ACCT' page +// So that I can complete the "Risk information" task +// As a referrer +// I want to complete the 'ACCT' page +// +// Background: +// Given an application exists +// And I am logged in +// And I am on the "ACCT" page +// +// Scenario: there are existing ACCTs in the application +// Then I see a list of the existing ACCTs on the "ACCT" page +// +// Scenario: remove an ACCT +// When I remove an ACCT +// Then the ACCT is no longer in the list of ACCTs +// +// Scenario: there are no existing ACCTs in the application +// Then I see the "ACCT" page +// +// Scenario: when I go to select another ACCT +// Then I see the "ACCT data" page +// +// Scenario: When I continue to the next task / page +// Then I see the "Violence and arson" page + +import AcctPage from '../../../../pages/apply/risks-and-needs/risk-information/acctPage' +import ViolenceAndArsonPage from '../../../../pages/apply/risks-and-needs/risk-information/violenceAndArsonPage' +import Page from '../../../../pages/page' +import { personFactory, applicationFactory } from '../../../../../server/testutils/factories/index' + +context('Visit "Risks and needs" section', () => { + const person = personFactory.build({ name: 'Roger Smith' }) + + beforeEach(function test() { + cy.task('reset') + cy.task('stubSignIn') + cy.task('stubAuthUser') + + cy.fixture('applicationData.json').then(applicationData => { + delete applicationData['risk-information'] + const application = applicationFactory.build({ + id: 'abc123', + person, + data: applicationData, + }) + cy.wrap(application).as('application') + }) + + cy.fixture('applicationData.json').then(applicationData => { + const applicationWithData = { + ...this.application, + data: applicationData, + } + cy.wrap(applicationWithData).as('applicationWithData') + }) + }) + + beforeEach(function test() { + // And an application exists + // ------------------------- + cy.task('stubApplicationGet', { application: this.application }) + cy.task('stubApplicationUpdate', { application: this.application }) + + // Given I am logged in + //--------------------- + cy.signIn() + + // And I am on the ACCT page + // -------------------------------- + AcctPage.visit(this.application) + }) + + // Scenario: there are no existing ACCTs in the application + // Then I see the "ACCT" page + it('presents ACCT page', function test() { + Page.verifyOnPage(AcctPage, this.application) + }) + + // Scenario: there are existing ACCTs in the application + // Then I see a list of existing ACCTs on the "ACCT" page + it('presents ACCT page with existing ACCTs', function test() { + // When there is already imported data + cy.task('stubApplicationGet', { application: this.applicationWithData }) + + AcctPage.visit(this.applicationWithData) + + const page = new AcctPage(this.applicationWithData) + page.hasListOfAccts() + }) + + // Scenario: remove an ACCT + + it('removes an ACCT', function test() { + // When there is already imported data + cy.task('stubApplicationGet', { application: this.applicationWithData }) + + AcctPage.visit(this.applicationWithData) + + const page = new AcctPage(this.applicationWithData) + page.hasListOfAccts() + + // When I remove an ACCT + // reset the application to have no data + cy.task('stubApplicationGet', { application: this.application }) + page.clickRemove() + // Then the ACCT is no longer in the list of ACCTs + page.hasNoAccts() + }) + + // Scenario: complete page and navigate to next page in health needs task + // When I continue to the next task / page + // Then I see the "violence and arson" page + it('navigates to the next page (violence and arson)', function test() { + AcctPage.visit(this.application) + const page = new AcctPage(this.application) + + page.clickSubmit() + + Page.verifyOnPage(ViolenceAndArsonPage, this.application) + }) +}) From 508750ec06265e5568dd0953900129e0fd1c54b1 Mon Sep 17 00:00:00 2001 From: Daniel Liburd Date: Mon, 3 Mar 2025 12:46:08 +0000 Subject: [PATCH 17/17] Introduce Living in the community page --- e2e-tests/steps/risksAndNeedsSection.ts | 7 +++ .../fixtures/applicationData.json | 1 + .../livingInTheCommunityPage.ts | 8 ++++ ...omplete_living_in_the_community_page.cy.ts | 46 +++++++++++++++++++ .../risks-and-needs/risk-information/index.ts | 3 +- .../livingInTheCommunity.test.ts | 18 ++++++++ .../risk-information/livingInTheCommunity.ts | 46 +++++++++++++++++++ .../risk-information/risksToStaff.test.ts | 2 +- .../risk-information/risksToStaff.ts | 2 +- .../risk-information/violenceAndArson.test.ts | 2 +- .../risk-information/violenceAndArson.ts | 2 +- server/form-pages/utils/questions.ts | 1 + server/utils/checkYourAnswersUtils.test.ts | 1 + .../_risk-information-screen.njk | 4 ++ .../living-in-the-community.njk | 5 ++ 15 files changed, 143 insertions(+), 5 deletions(-) create mode 100644 integration_tests/pages/apply/risks-and-needs/risk-information/livingInTheCommunityPage.ts create mode 100644 integration_tests/tests/apply/risks-and-needs/risk-information/complete_living_in_the_community_page.cy.ts create mode 100644 server/form-pages/apply/risks-and-needs/risk-information/livingInTheCommunity.test.ts create mode 100644 server/form-pages/apply/risks-and-needs/risk-information/livingInTheCommunity.ts create mode 100644 server/views/applications/pages/risk-information/living-in-the-community.njk diff --git a/e2e-tests/steps/risksAndNeedsSection.ts b/e2e-tests/steps/risksAndNeedsSection.ts index f53cdc85..be83c557 100644 --- a/e2e-tests/steps/risksAndNeedsSection.ts +++ b/e2e-tests/steps/risksAndNeedsSection.ts @@ -131,6 +131,7 @@ export const completeRiskInformationTask = async (page: Page) => { await completeSelfHarmPage(page) await addAnAcct(page) await completeViolenceAndArsonPage(page) + await completeLivingInTheCommunityPage(page) await completeRisksToStaffPage(page) await completeAdditionalConcernsPage(page) } @@ -153,6 +154,12 @@ async function completeViolenceAndArsonPage(page: Page) { violenceAndArsonPage.clickSave() } +async function completeLivingInTheCommunityPage(page: Page) { + const livingInTheCommunityPage = await ApplyPage.initialize(page, 'Living in the community') + + livingInTheCommunityPage.clickSave() +} + async function completeRisksToStaffPage(page: Page) { const risksToStaffPage = await ApplyPage.initialize(page, 'Risks to staff') diff --git a/integration_tests/fixtures/applicationData.json b/integration_tests/fixtures/applicationData.json index 8192f48a..9124545a 100644 --- a/integration_tests/fixtures/applicationData.json +++ b/integration_tests/fixtures/applicationData.json @@ -212,6 +212,7 @@ "concerns": {}, "self-harm": {}, "violence-and-arson": {}, + "living-in-the-community": {}, "risks-to-staff": {}, "additional-concerns": {}, "acct": {}, diff --git a/integration_tests/pages/apply/risks-and-needs/risk-information/livingInTheCommunityPage.ts b/integration_tests/pages/apply/risks-and-needs/risk-information/livingInTheCommunityPage.ts new file mode 100644 index 00000000..27d13cfc --- /dev/null +++ b/integration_tests/pages/apply/risks-and-needs/risk-information/livingInTheCommunityPage.ts @@ -0,0 +1,8 @@ +import { Cas2v2Application as Application } from '@approved-premises/api' +import ApplyPage from '../../applyPage' + +export default class LivingInTheCommunityPage extends ApplyPage { + constructor(private readonly application: Application) { + super('Living in the community', application, 'risk-information', 'living-in-the-community') + } +} diff --git a/integration_tests/tests/apply/risks-and-needs/risk-information/complete_living_in_the_community_page.cy.ts b/integration_tests/tests/apply/risks-and-needs/risk-information/complete_living_in_the_community_page.cy.ts new file mode 100644 index 00000000..87efd2a8 --- /dev/null +++ b/integration_tests/tests/apply/risks-and-needs/risk-information/complete_living_in_the_community_page.cy.ts @@ -0,0 +1,46 @@ +// Feature: complete living in the community page +// + +import LivingInTheCommunityPage from '../../../../pages/apply/risks-and-needs/risk-information/livingInTheCommunityPage' +import Page from '../../../../pages/page' +import { personFactory, applicationFactory } from '../../../../../server/testutils/factories/index' + +context('Complete "Living in the community" page', () => { + const person = personFactory.build({ name: 'Roger Smith' }) + + beforeEach(function test() { + cy.task('reset') + cy.task('stubSignIn') + cy.task('stubAuthUser') + + cy.fixture('applicationData.json').then(applicationData => { + applicationData['risk-information'] = {} + const application = applicationFactory.build({ + id: 'abc123', + person, + }) + application.data = applicationData + cy.wrap(application).as('application') + cy.wrap(application.data).as('applicationData') + }) + }) + + beforeEach(function test() { + // And an application exists + cy.task('stubApplicationGet', { application: this.application }) + cy.task('stubApplicationUpdate', { application: this.application }) + + // Given I am logged in + //--------------------- + cy.signIn() + + // And I visit the Living in the community page + // -------------------------------- + cy.visit('applications/abc123/tasks/risk-information/pages/living-in-the-community') + }) + + it('exists', function test() { + // Given I am on the Living in the community page + Page.verifyOnPage(LivingInTheCommunityPage, this.application) + }) +}) diff --git a/server/form-pages/apply/risks-and-needs/risk-information/index.ts b/server/form-pages/apply/risks-and-needs/risk-information/index.ts index fb858837..afe621f1 100644 --- a/server/form-pages/apply/risks-and-needs/risk-information/index.ts +++ b/server/form-pages/apply/risks-and-needs/risk-information/index.ts @@ -4,6 +4,7 @@ import SelfHarm from './selfHarm' import Acct from './acct' import AcctData from './custom-forms/acctData' import ViolenceAndArson from './violenceAndArson' +import LivingInTheCommunity from './livingInTheCommunity' import RisksToStaff from './risksToStaff' import AdditionalConcerns from './additionalConcerns' @@ -12,6 +13,6 @@ import { Task } from '../../../utils/decorators' @Task({ name: 'Add information about risks to the applicant and others', slug: 'risk-information', - pages: [Concerns, SelfHarm, Acct, AcctData, ViolenceAndArson, RisksToStaff, AdditionalConcerns], + pages: [Concerns, SelfHarm, Acct, AcctData, ViolenceAndArson, LivingInTheCommunity, RisksToStaff, AdditionalConcerns], }) export default class RiskToSelf {} diff --git a/server/form-pages/apply/risks-and-needs/risk-information/livingInTheCommunity.test.ts b/server/form-pages/apply/risks-and-needs/risk-information/livingInTheCommunity.test.ts new file mode 100644 index 00000000..436b126a --- /dev/null +++ b/server/form-pages/apply/risks-and-needs/risk-information/livingInTheCommunity.test.ts @@ -0,0 +1,18 @@ +import { itShouldHaveNextValue, itShouldHavePreviousValue } from '../../../shared-examples' +import { personFactory, applicationFactory } from '../../../../testutils/factories/index' +import LivingInTheCommunity from './livingInTheCommunity' + +describe('LivingInTheCommunity', () => { + const application = applicationFactory.build({ person: personFactory.build({ name: 'Roger Smith' }) }) + + describe('title', () => { + it('adds the page title', () => { + const page = new LivingInTheCommunity({}, application) + + expect(page.title).toEqual('Living in the community') + }) + }) + + itShouldHaveNextValue(new LivingInTheCommunity({}, application), 'risks-to-staff') + itShouldHavePreviousValue(new LivingInTheCommunity({}, application), 'violence-and-arson') +}) diff --git a/server/form-pages/apply/risks-and-needs/risk-information/livingInTheCommunity.ts b/server/form-pages/apply/risks-and-needs/risk-information/livingInTheCommunity.ts new file mode 100644 index 00000000..201c2649 --- /dev/null +++ b/server/form-pages/apply/risks-and-needs/risk-information/livingInTheCommunity.ts @@ -0,0 +1,46 @@ +import type { TaskListErrors } from '@approved-premises/ui' +import { Cas2v2Application as Application } from '@approved-premises/api' +import { nameOrPlaceholderCopy } from '../../../../utils/utils' +import { Page } from '../../../utils/decorators' +import TaskListPage from '../../../taskListPage' +import { getQuestions } from '../../../utils/questions' + +// eslint-disable-next-line @typescript-eslint/no-empty-object-type +type LivingInTheCommunityBody = {} + +@Page({ + name: 'living-in-the-community', + bodyProperties: [], +}) +export default class LivingInTheCommunity implements TaskListPage { + documentTitle = 'Living in the community' + + personName = nameOrPlaceholderCopy(this.application.person) + + title = 'Living in the community' + + questions = getQuestions(this.personName)['risk-information']['living-in-the-community'] + + body: LivingInTheCommunityBody + + constructor( + body: Partial, + private readonly application: Application, + ) { + this.body = body as LivingInTheCommunityBody + } + + previous() { + return 'violence-and-arson' + } + + next() { + return 'risks-to-staff' + } + + errors() { + const errors: TaskListErrors = {} + + return errors + } +} diff --git a/server/form-pages/apply/risks-and-needs/risk-information/risksToStaff.test.ts b/server/form-pages/apply/risks-and-needs/risk-information/risksToStaff.test.ts index c748259b..09c55fd0 100644 --- a/server/form-pages/apply/risks-and-needs/risk-information/risksToStaff.test.ts +++ b/server/form-pages/apply/risks-and-needs/risk-information/risksToStaff.test.ts @@ -14,5 +14,5 @@ describe('RisksToStaff', () => { }) itShouldHaveNextValue(new RisksToStaff({}, application), 'additional-concerns') - itShouldHavePreviousValue(new RisksToStaff({}, application), 'violence-and-arson') + itShouldHavePreviousValue(new RisksToStaff({}, application), 'living-in-the-community') }) diff --git a/server/form-pages/apply/risks-and-needs/risk-information/risksToStaff.ts b/server/form-pages/apply/risks-and-needs/risk-information/risksToStaff.ts index 8d416a38..a40fe9f1 100644 --- a/server/form-pages/apply/risks-and-needs/risk-information/risksToStaff.ts +++ b/server/form-pages/apply/risks-and-needs/risk-information/risksToStaff.ts @@ -31,7 +31,7 @@ export default class RisksToStaff implements TaskListPage { } previous() { - return 'violence-and-arson' + return 'living-in-the-community' } next() { diff --git a/server/form-pages/apply/risks-and-needs/risk-information/violenceAndArson.test.ts b/server/form-pages/apply/risks-and-needs/risk-information/violenceAndArson.test.ts index d9f130f6..05ffd03e 100644 --- a/server/form-pages/apply/risks-and-needs/risk-information/violenceAndArson.test.ts +++ b/server/form-pages/apply/risks-and-needs/risk-information/violenceAndArson.test.ts @@ -13,6 +13,6 @@ describe('ViolenceAndArson', () => { }) }) - itShouldHaveNextValue(new ViolenceAndArson({}, application), 'risks-to-staff') + itShouldHaveNextValue(new ViolenceAndArson({}, application), 'living-in-the-community') itShouldHavePreviousValue(new ViolenceAndArson({}, application), 'acct') }) diff --git a/server/form-pages/apply/risks-and-needs/risk-information/violenceAndArson.ts b/server/form-pages/apply/risks-and-needs/risk-information/violenceAndArson.ts index 20c51478..186d9ece 100644 --- a/server/form-pages/apply/risks-and-needs/risk-information/violenceAndArson.ts +++ b/server/form-pages/apply/risks-and-needs/risk-information/violenceAndArson.ts @@ -35,7 +35,7 @@ export default class ViolenceAndArson implements TaskListPage { } next() { - return 'risks-to-staff' + return 'living-in-the-community' } errors() { diff --git a/server/form-pages/utils/questions.ts b/server/form-pages/utils/questions.ts index f9c59674..d6b2e65c 100644 --- a/server/form-pages/utils/questions.ts +++ b/server/form-pages/utils/questions.ts @@ -665,6 +665,7 @@ export const getQuestions = (name: string) => { concerns: {}, 'self-harm': {}, 'violence-and-arson': {}, + 'living-in-the-community': {}, 'risks-to-staff': {}, 'additional-concerns': {}, 'acct-data': { diff --git a/server/utils/checkYourAnswersUtils.test.ts b/server/utils/checkYourAnswersUtils.test.ts index f4983bb8..dc01131b 100644 --- a/server/utils/checkYourAnswersUtils.test.ts +++ b/server/utils/checkYourAnswersUtils.test.ts @@ -520,6 +520,7 @@ describe('checkYourAnswersUtils', () => { 'concerns', 'self-harm', 'violence-and-arson', + 'living-in-the-community', 'risks-to-staff', 'additional-concerns', 'acct', diff --git a/server/views/applications/pages/risk-information/_risk-information-screen.njk b/server/views/applications/pages/risk-information/_risk-information-screen.njk index 4492f7e4..a8de905d 100644 --- a/server/views/applications/pages/risk-information/_risk-information-screen.njk +++ b/server/views/applications/pages/risk-information/_risk-information-screen.njk @@ -30,6 +30,10 @@ text: 'Violence and arson', href: paths.applications.pages.show({ id: applicationId, task: 'risk-information', page: 'violence-and-arson' }), active: (pageName === 'violence-and-arson') + }, { + text: 'Living in the community', + href: paths.applications.pages.show({ id: applicationId, task: 'risk-information', page: 'living-in-the-community' }), + active: (pageName === 'living-in-the-community') }, { text: 'Risks to staff', href: paths.applications.pages.show({ id: applicationId, task: 'risk-information', page: 'risks-to-staff' }), diff --git a/server/views/applications/pages/risk-information/living-in-the-community.njk b/server/views/applications/pages/risk-information/living-in-the-community.njk new file mode 100644 index 00000000..5c2347a7 --- /dev/null +++ b/server/views/applications/pages/risk-information/living-in-the-community.njk @@ -0,0 +1,5 @@ +{% extends "./_risk-information-screen.njk" %} +{% set pageName = "living-in-the-community" %} + +{% block questions %} +{% endblock %}