Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CBA-280: add content to liaison and diversion assessment page #134

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions e2e-tests/steps/risksAndNeedsSection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -14,7 +14,6 @@ export default class BrainInjuryPage extends ApplyPage {
)

pageIsActiveInNavigation('Brain injury')
pageHasLinkToGuidance()
this.pageHasBrainInjuryGuidance()
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -12,7 +12,6 @@ export default class CommunicationAndLanguagePage extends ApplyPage {
'health-needs',
'communication-and-language',
)
pageHasLinkToGuidance()
pageIsActiveInNavigation('Communication and language')
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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)
}
}
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -14,7 +14,6 @@ export default class LearningDifficultiesPage extends ApplyPage {
)

pageIsActiveInNavigation('Learning difficulties')
pageHasLinkToGuidance()
this.pageHasNeurodiversityGuidance()
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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')
}
}
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -12,7 +12,6 @@ export default class MentalHealthPage extends ApplyPage {
'health-needs',
'mental-health',
)
pageHasLinkToGuidance()
pageIsActiveInNavigation('Mental health')
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -12,7 +12,6 @@ export default class OtherHealthPage extends ApplyPage {
'health-needs',
'other-health',
)
pageHasLinkToGuidance()
pageIsActiveInNavigation('Other health')
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -12,7 +12,6 @@ export default class PhysicalHealthPage extends ApplyPage {
'health-needs',
'physical-health',
)
pageHasLinkToGuidance()
pageIsActiveInNavigation('Physical health')
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -12,7 +12,6 @@ export default class SubstanceMisusePage extends ApplyPage {
'health-needs',
'substance-misuse',
)
pageHasLinkToGuidance()
pageIsActiveInNavigation('Substance misuse')
}

Expand Down
7 changes: 0 additions & 7 deletions integration_tests/pages/apply/risks_and_needs/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)')
}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
})
})
Original file line number Diff line number Diff line change
@@ -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)
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -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')
})
})

Expand All @@ -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'",
)
})
})
Expand Down
Loading
Loading