diff --git a/e2e-tests/steps/risksAndNeedsSection.ts b/e2e-tests/steps/risksAndNeedsSection.ts index be83c557..8d2de732 100644 --- a/e2e-tests/steps/risksAndNeedsSection.ts +++ b/e2e-tests/steps/risksAndNeedsSection.ts @@ -103,9 +103,9 @@ async function completeBrainInjuryPage(page: Page, name: string) { } async function completeLiaisonAndDiversionPage(page: Page, name: string) { - const liaisonAndDiversionPage = await ApplyPage.initialize(page, `Liaison & Diversion Assessment for ${name}`) + const liaisonAndDiversionPage = await ApplyPage.initialize(page, `Liaison and Diversion Assessment for ${name}`) - await liaisonAndDiversionPage.checkRadioInGroup('Liaison & Diversion Assessment', 'No') + await liaisonAndDiversionPage.checkRadioInGroup('Liaison and Diversion Assessment', 'No') await liaisonAndDiversionPage.clickSave() } diff --git a/integration_tests/pages/apply/risks_and_needs/health-needs/brainInjuryPage.ts b/integration_tests/pages/apply/risks_and_needs/health-needs/brainInjuryPage.ts index 3fdc4d35..37650e95 100644 --- a/integration_tests/pages/apply/risks_and_needs/health-needs/brainInjuryPage.ts +++ b/integration_tests/pages/apply/risks_and_needs/health-needs/brainInjuryPage.ts @@ -1,7 +1,7 @@ import { Cas2v2Application as Application } from '@approved-premises/api' import ApplyPage from '../../applyPage' import paths from '../../../../../server/paths/apply' -import { pageIsActiveInNavigation, pageHasLinkToGuidance } from '../utils' +import { pageIsActiveInNavigation } from '../utils' import { nameOrPlaceholderCopy } from '../../../../../server/utils/utils' export default class BrainInjuryPage extends ApplyPage { @@ -14,7 +14,6 @@ export default class BrainInjuryPage extends ApplyPage { ) pageIsActiveInNavigation('Brain injury') - pageHasLinkToGuidance() this.pageHasBrainInjuryGuidance() } diff --git a/integration_tests/pages/apply/risks_and_needs/health-needs/communicationAndLanguagePage.ts b/integration_tests/pages/apply/risks_and_needs/health-needs/communicationAndLanguagePage.ts index f627eb11..624ea187 100644 --- a/integration_tests/pages/apply/risks_and_needs/health-needs/communicationAndLanguagePage.ts +++ b/integration_tests/pages/apply/risks_and_needs/health-needs/communicationAndLanguagePage.ts @@ -1,7 +1,7 @@ import { Cas2v2Application as Application } from '@approved-premises/api' import ApplyPage from '../../applyPage' import paths from '../../../../../server/paths/apply' -import { pageIsActiveInNavigation, pageHasLinkToGuidance } from '../utils' +import { pageIsActiveInNavigation } from '../utils' import { nameOrPlaceholderCopy } from '../../../../../server/utils/utils' export default class CommunicationAndLanguagePage extends ApplyPage { @@ -12,7 +12,6 @@ export default class CommunicationAndLanguagePage extends ApplyPage { 'health-needs', 'communication-and-language', ) - pageHasLinkToGuidance() pageIsActiveInNavigation('Communication and language') } diff --git a/integration_tests/pages/apply/risks_and_needs/health-needs/independentLivingPage.ts b/integration_tests/pages/apply/risks_and_needs/health-needs/independentLivingPage.ts new file mode 100644 index 00000000..5ae24dda --- /dev/null +++ b/integration_tests/pages/apply/risks_and_needs/health-needs/independentLivingPage.ts @@ -0,0 +1,27 @@ +import { Cas2v2Application as Application } from '@approved-premises/api' +import ApplyPage from '../../applyPage' +import paths from '../../../../../server/paths/apply' +import { nameOrPlaceholderCopy } from '../../../../../server/utils/utils' + +export default class IndependentLivingPage extends ApplyPage { + constructor(private readonly application: Application) { + super( + `Can ${nameOrPlaceholderCopy(application.person)} live independently and in shared accommodation?`, + application, + 'health-needs', + 'independent-living', + ) + } + + static visit(application: Application): IndependentLivingPage { + cy.visit( + paths.applications.pages.show({ + id: application.id, + task: 'health-needs', + page: 'independent-living', + }), + ) + + return new IndependentLivingPage(application) + } +} diff --git a/integration_tests/pages/apply/risks_and_needs/health-needs/learningDifficultiesPage.ts b/integration_tests/pages/apply/risks_and_needs/health-needs/learningDifficultiesPage.ts index 83a85edc..b875763a 100644 --- a/integration_tests/pages/apply/risks_and_needs/health-needs/learningDifficultiesPage.ts +++ b/integration_tests/pages/apply/risks_and_needs/health-needs/learningDifficultiesPage.ts @@ -1,7 +1,7 @@ import { Cas2v2Application as Application } from '@approved-premises/api' import ApplyPage from '../../applyPage' import paths from '../../../../../server/paths/apply' -import { pageIsActiveInNavigation, pageHasLinkToGuidance } from '../utils' +import { pageIsActiveInNavigation } from '../utils' import { nameOrPlaceholderCopy } from '../../../../../server/utils/utils' export default class LearningDifficultiesPage extends ApplyPage { @@ -14,7 +14,6 @@ export default class LearningDifficultiesPage extends ApplyPage { ) pageIsActiveInNavigation('Learning difficulties') - pageHasLinkToGuidance() this.pageHasNeurodiversityGuidance() } diff --git a/integration_tests/pages/apply/risks_and_needs/health-needs/liaisonAndDiversionPage.ts b/integration_tests/pages/apply/risks_and_needs/health-needs/liaisonAndDiversionPage.ts new file mode 100644 index 00000000..bc38a3ae --- /dev/null +++ b/integration_tests/pages/apply/risks_and_needs/health-needs/liaisonAndDiversionPage.ts @@ -0,0 +1,31 @@ +import { Cas2v2Application as Application } from '@approved-premises/api' +import ApplyPage from '../../applyPage' +import paths from '../../../../../server/paths/apply' +import { nameOrPlaceholderCopy } from '../../../../../server/utils/utils' + +export default class LiaisonAndDiversionPage extends ApplyPage { + constructor(private readonly application: Application) { + super( + `Liaison and Diversion Assessment for ${nameOrPlaceholderCopy(application.person)}`, + application, + 'health-needs', + 'liaison-and-diversion', + ) + } + + static visit(application: Application): LiaisonAndDiversionPage { + cy.visit( + paths.applications.pages.show({ + id: application.id, + task: 'health-needs', + page: 'liaison-and-diversion', + }), + ) + + return new LiaisonAndDiversionPage(application) + } + + completeForm(): void { + this.checkRadioByNameAndValue('liaisonAndDiversionAssessment', 'yes') + } +} diff --git a/integration_tests/pages/apply/risks_and_needs/health-needs/mentalHealthPage.ts b/integration_tests/pages/apply/risks_and_needs/health-needs/mentalHealthPage.ts index 125ca5e2..ad1d88aa 100644 --- a/integration_tests/pages/apply/risks_and_needs/health-needs/mentalHealthPage.ts +++ b/integration_tests/pages/apply/risks_and_needs/health-needs/mentalHealthPage.ts @@ -1,7 +1,7 @@ import { Cas2v2Application as Application } from '@approved-premises/api' import ApplyPage from '../../applyPage' import paths from '../../../../../server/paths/apply' -import { pageIsActiveInNavigation, pageHasLinkToGuidance, fieldIsOptional } from '../utils' +import { pageIsActiveInNavigation, fieldIsOptional } from '../utils' import { nameOrPlaceholderCopy } from '../../../../../server/utils/utils' export default class MentalHealthPage extends ApplyPage { @@ -12,7 +12,6 @@ export default class MentalHealthPage extends ApplyPage { 'health-needs', 'mental-health', ) - pageHasLinkToGuidance() pageIsActiveInNavigation('Mental health') } diff --git a/integration_tests/pages/apply/risks_and_needs/health-needs/otherHealthPage.ts b/integration_tests/pages/apply/risks_and_needs/health-needs/otherHealthPage.ts index 719db444..2e13238c 100644 --- a/integration_tests/pages/apply/risks_and_needs/health-needs/otherHealthPage.ts +++ b/integration_tests/pages/apply/risks_and_needs/health-needs/otherHealthPage.ts @@ -1,7 +1,7 @@ import { Cas2v2Application as Application } from '@approved-premises/api' import ApplyPage from '../../applyPage' import paths from '../../../../../server/paths/apply' -import { pageIsActiveInNavigation, pageHasLinkToGuidance } from '../utils' +import { pageIsActiveInNavigation } from '../utils' import { nameOrPlaceholderCopy } from '../../../../../server/utils/utils' export default class OtherHealthPage extends ApplyPage { @@ -12,7 +12,6 @@ export default class OtherHealthPage extends ApplyPage { 'health-needs', 'other-health', ) - pageHasLinkToGuidance() pageIsActiveInNavigation('Other health') } diff --git a/integration_tests/pages/apply/risks_and_needs/health-needs/physicalHealthPage.ts b/integration_tests/pages/apply/risks_and_needs/health-needs/physicalHealthPage.ts index c51bef23..295cdb14 100644 --- a/integration_tests/pages/apply/risks_and_needs/health-needs/physicalHealthPage.ts +++ b/integration_tests/pages/apply/risks_and_needs/health-needs/physicalHealthPage.ts @@ -1,7 +1,7 @@ import { Cas2v2Application as Application } from '@approved-premises/api' import ApplyPage from '../../applyPage' import paths from '../../../../../server/paths/apply' -import { pageIsActiveInNavigation, pageHasLinkToGuidance } from '../utils' +import { pageIsActiveInNavigation } from '../utils' import { nameOrPlaceholderCopy } from '../../../../../server/utils/utils' export default class PhysicalHealthPage extends ApplyPage { @@ -12,7 +12,6 @@ export default class PhysicalHealthPage extends ApplyPage { 'health-needs', 'physical-health', ) - pageHasLinkToGuidance() pageIsActiveInNavigation('Physical health') } diff --git a/integration_tests/pages/apply/risks_and_needs/health-needs/substanceMisusePage.ts b/integration_tests/pages/apply/risks_and_needs/health-needs/substanceMisusePage.ts index 7f07363b..7576d87d 100644 --- a/integration_tests/pages/apply/risks_and_needs/health-needs/substanceMisusePage.ts +++ b/integration_tests/pages/apply/risks_and_needs/health-needs/substanceMisusePage.ts @@ -1,7 +1,7 @@ import { Cas2v2Application as Application } from '@approved-premises/api' import ApplyPage from '../../applyPage' import paths from '../../../../../server/paths/apply' -import { pageIsActiveInNavigation, pageHasLinkToGuidance } from '../utils' +import { pageIsActiveInNavigation } from '../utils' import { nameOrPlaceholderCopy } from '../../../../../server/utils/utils' export default class SubstanceMisusePage extends ApplyPage { @@ -12,7 +12,6 @@ export default class SubstanceMisusePage extends ApplyPage { 'health-needs', 'substance-misuse', ) - pageHasLinkToGuidance() pageIsActiveInNavigation('Substance misuse') } diff --git a/integration_tests/pages/apply/risks_and_needs/utils.ts b/integration_tests/pages/apply/risks_and_needs/utils.ts index 5fddcaaa..31f54cc6 100644 --- a/integration_tests/pages/apply/risks_and_needs/utils.ts +++ b/integration_tests/pages/apply/risks_and_needs/utils.ts @@ -2,13 +2,6 @@ export const pageIsActiveInNavigation = (linkText: string): void => { cy.get('.moj-side-navigation__item--active a').contains(linkText) } -export const pageHasLinkToGuidance = (): void => { - cy.get('a') - .contains('Who to contact for health care information') - .should('have.attr', 'href') - .and('match', new RegExp(Cypress._.escapeRegExp('tasks/health-needs/pages/guidance'))) -} - export const fieldIsOptional = (labelId: string): void => { cy.get(`label[for="${labelId}"]`).contains('(optional)') } diff --git a/integration_tests/tests/apply/risks_and_needs/health-needs/health_needs_guidance_page.cy.ts b/integration_tests/tests/apply/risks_and_needs/health-needs/health_needs_information.cy.ts similarity index 90% rename from integration_tests/tests/apply/risks_and_needs/health-needs/health_needs_guidance_page.cy.ts rename to integration_tests/tests/apply/risks_and_needs/health-needs/health_needs_information.cy.ts index a5f8b55e..33a7d290 100644 --- a/integration_tests/tests/apply/risks_and_needs/health-needs/health_needs_guidance_page.cy.ts +++ b/integration_tests/tests/apply/risks_and_needs/health-needs/health_needs_information.cy.ts @@ -1,7 +1,7 @@ -// Feature: Referrer completes 'Health needs: guidance' page -// So that I can complete the first page of the "Health needs" task +// Feature: Referrer completes 'Health needs information' page +// So that I can complete the "Health needs" task // As a referrer -// I want to confirm that I've understood the guidance on that page +// I want to confirm that I've understood the information on that page // // Scenario: Follows link from task list // Given there is a section with a task @@ -21,7 +21,7 @@ import Page from '../../../../pages/page' import HealthNeedsInformationPage from '../../../../pages/apply/risks_and_needs/health-needs/healthNeedsInformationPage' import { personFactory, applicationFactory } from '../../../../../server/testutils/factories/index' -context('Visit "Risks and needs" section', () => { +context('Visit health needs information page', () => { const person = personFactory.build({ name: 'Roger Smith' }) beforeEach(function test() { diff --git a/integration_tests/tests/apply/risks_and_needs/health-needs/independent_living.cy.ts b/integration_tests/tests/apply/risks_and_needs/health-needs/independent_living.cy.ts new file mode 100644 index 00000000..959d16fc --- /dev/null +++ b/integration_tests/tests/apply/risks_and_needs/health-needs/independent_living.cy.ts @@ -0,0 +1,72 @@ +// Feature: Referrer completes 'Independent living' page +// So that I can complete the "Health needs" task +// As a referrer +// I want to complete the independent living page +// +// Scenario: Follows link from task list +// Given there is a section with a task +// And an application exists +// And I am logged in +// +// Scenario: view Independent living page +// When I visit the Independent living page +// Then I see the Independent living page +// +// Scenario: continues to next page in "health needs" task +// When I continue to the next task/page +// Then I should be on the substance misuse page + +import Page from '../../../../pages/page' +import HealthNeedsInformationPage from '../../../../pages/apply/risks_and_needs/health-needs/healthNeedsInformationPage' +import { personFactory, applicationFactory } from '../../../../../server/testutils/factories/index' +import IndependentLivingPage from '../../../../pages/apply/risks_and_needs/health-needs/independentLivingPage' + +context('Visit Independent living 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['health-needs'] = {} + const application = applicationFactory.build({ + id: 'abc123', + person, + data: applicationData, + }) + cy.wrap(application).as('application') + }) + }) + + 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() + }) + + // Scenario: view Independent living page + it('shows the page', function test() { + // When I visit the Independent living page + IndependentLivingPage.visit(this.application) + + // Then I see the Independent living page + Page.verifyOnPage(IndependentLivingPage, this.application) + }) + + // Scenario: continues to next page in "health needs" task + it('continues to the next page', function test() { + // When I continue to the next task/page + const page = IndependentLivingPage.visit(this.application) + page.clickSubmit() + + // Then I should be on the health needs information page + Page.verifyOnPage(HealthNeedsInformationPage, this.application) + }) +}) diff --git a/integration_tests/tests/apply/risks_and_needs/health-needs/liaison_and_diversion.cy.ts b/integration_tests/tests/apply/risks_and_needs/health-needs/liaison_and_diversion.cy.ts new file mode 100644 index 00000000..74d3653c --- /dev/null +++ b/integration_tests/tests/apply/risks_and_needs/health-needs/liaison_and_diversion.cy.ts @@ -0,0 +1,78 @@ +// Feature: Referrer completes 'Liaison and diversion assessment' page +// So that I can complete the "Health needs" task +// As a referrer +// I want to complete the Liaison and diversion assessment page +// +// Scenario: Follows link from task list +// Given there is a section with a task +// And an application exists +// And I am logged in +// +// Scenario: view Liaison and diversion assessment page +// Given I am on the task list page +// When I follow the link to the health needs task +// Then I see the Liaison and diversion assessment page +// +// Scenario: continues to next page in "health needs" task +// When I continue to the next task/page +// Then I should be on the independent living page + +import Page from '../../../../pages/page' +import { personFactory, applicationFactory } from '../../../../../server/testutils/factories/index' +import LiaisonAndDiversionPage from '../../../../pages/apply/risks_and_needs/health-needs/liaisonAndDiversionPage' +import TaskListPage from '../../../../pages/apply/taskListPage' +import IndependentLivingPage from '../../../../pages/apply/risks_and_needs/health-needs/independentLivingPage' + +context('Visit Liaison and diversion assessment 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['health-needs'] = {} + const application = applicationFactory.build({ + id: 'abc123', + person, + data: applicationData, + }) + cy.wrap(application).as('application') + }) + }) + + 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() + }) + + // Scenario: view Liaison and diversion assessment page + it('shows the page', function test() { + // Given I am on the task list page + const page = TaskListPage.visit(this.application) + + // When I follow the link to the health needs task + page.clickLink('Add health needs') + + // Then I see the Liaison and diversion assessment page + Page.verifyOnPage(LiaisonAndDiversionPage, this.application) + }) + + // Scenario: continues to next page in "health needs" task + it('continues to the next page', function test() { + // When I continue to the next task/page + const page = LiaisonAndDiversionPage.visit(this.application) + page.completeForm() + page.clickSubmit() + + // Then I should be on the independent living page + Page.verifyOnPage(IndependentLivingPage, this.application) + }) +}) diff --git a/server/form-pages/apply/risks-and-needs/health-needs/liaisonAndDiversion.test.ts b/server/form-pages/apply/risks-and-needs/health-needs/liaisonAndDiversion.test.ts index 6a4f165d..cf28768f 100644 --- a/server/form-pages/apply/risks-and-needs/health-needs/liaisonAndDiversion.test.ts +++ b/server/form-pages/apply/risks-and-needs/health-needs/liaisonAndDiversion.test.ts @@ -9,7 +9,7 @@ describe('LiaisonAndDiversion', () => { it('personalises the page title', () => { const page = new LiaisonAndDiversion({}, application) - expect(page.title).toEqual('Liaison & Diversion Assessment for Roger Smith') + expect(page.title).toEqual('Liaison and Diversion Assessment for Roger Smith') }) }) @@ -33,7 +33,7 @@ describe('LiaisonAndDiversion', () => { it('includes a validation error for _liaisonAndDiversionAssessment_', () => { expect(page.errors()).toHaveProperty( 'liaisonAndDiversionAssessment', - 'Confirm whether a Liaison & Diversion Assessment has been requested', + "Select if a Liaison and Diversion Assessment has been carried out, or select 'I don't know'", ) }) }) diff --git a/server/form-pages/apply/risks-and-needs/health-needs/liaisonAndDiversion.ts b/server/form-pages/apply/risks-and-needs/health-needs/liaisonAndDiversion.ts index 32ab23f9..6890d0eb 100644 --- a/server/form-pages/apply/risks-and-needs/health-needs/liaisonAndDiversion.ts +++ b/server/form-pages/apply/risks-and-needs/health-needs/liaisonAndDiversion.ts @@ -14,11 +14,11 @@ type LiaisonAndDiversionBody = { bodyProperties: ['liaisonAndDiversionAssessment'], }) export default class LiaisonAndDiversion implements TaskListPage { - documentTitle = 'Liaison & Diversion Assessment for the person' + documentTitle = 'Liaison and Diversion Assessment for the person' personName = nameOrPlaceholderCopy(this.application.person) - title = `Liaison & Diversion Assessment for ${this.personName}` + title = `Liaison and Diversion Assessment for ${this.personName}` questions = getQuestions(this.personName)['health-needs']['liaison-and-diversion'] @@ -43,7 +43,8 @@ export default class LiaisonAndDiversion implements TaskListPage { const errors: TaskListErrors = {} if (!this.body.liaisonAndDiversionAssessment) { - errors.liaisonAndDiversionAssessment = `Confirm whether a Liaison & Diversion Assessment has been requested` + errors.liaisonAndDiversionAssessment = + "Select if a Liaison and Diversion Assessment has been carried out, or select 'I don't know'" } return errors diff --git a/server/form-pages/utils/questions.ts b/server/form-pages/utils/questions.ts index c4fe7deb..1aa3aa65 100644 --- a/server/form-pages/utils/questions.ts +++ b/server/form-pages/utils/questions.ts @@ -646,8 +646,9 @@ export const getQuestions = (name: string) => { }, 'liaison-and-diversion': { liaisonAndDiversionAssessment: { - question: `Does ${name} have a Liaison & Diversion Assessment?`, - answers: yesOrNo, + question: `Has a Liaison and Diversion Assessment been carried out for ${name}?`, + hint: 'This may have been carried out by the police or in court if the applicant has any mental health issues, learning disabilities, substance misuse problems, or other vulnerabilities.', + answers: yesNoOrIDontKnow, }, }, 'other-health': { diff --git a/server/views/applications/pages/health-needs/_health-needs-screen.njk b/server/views/applications/pages/health-needs/_health-needs-screen.njk index cf344fef..d64dae60 100644 --- a/server/views/applications/pages/health-needs/_health-needs-screen.njk +++ b/server/views/applications/pages/health-needs/_health-needs-screen.njk @@ -8,13 +8,6 @@
diff --git a/server/views/applications/pages/health-needs/liaison-and-diversion.njk b/server/views/applications/pages/health-needs/liaison-and-diversion.njk index b62b5a0f..51de31de 100644 --- a/server/views/applications/pages/health-needs/liaison-and-diversion.njk +++ b/server/views/applications/pages/health-needs/liaison-and-diversion.njk @@ -13,6 +13,7 @@ classes: "govuk-fieldset__legend--m" } }, + hint: { text: page.questions.liaisonAndDiversionAssessment.hint }, items: [ { value: "yes", @@ -21,6 +22,13 @@ { value: "no", text: "No" + }, + { + divider: 'or' + }, + { + value: "dontKnow", + text: "I don't know" } ] },