Skip to content

Commit d9b61cd

Browse files
authored
Merge pull request #137 from ministryofjustice/CBA-285-change-content-on-brain-injury-details-for-applicant-page
CBA-285: change content on brain injury details for applicant page
2 parents 35f0122 + 08db638 commit d9b61cd

File tree

8 files changed

+301
-197
lines changed

8 files changed

+301
-197
lines changed

e2e-tests/steps/risksAndNeedsSection.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,10 @@ async function completeBrainInjuryPage(page: Page, name: string) {
9595
const brainInjuryPage = await ApplyPage.initialize(page, `Brain injury needs for ${name}`)
9696

9797
await brainInjuryPage.checkRadioInGroup('brain injury?', 'No')
98+
await brainInjuryPage.checkRadioInGroup('any support', 'No')
99+
await brainInjuryPage.checkRadioInGroup('treatment', 'No')
98100
await brainInjuryPage.checkRadioInGroup('vulnerable', 'No')
99101
await brainInjuryPage.checkRadioInGroup('difficulties interacting', 'No')
100-
await brainInjuryPage.checkRadioInGroup('additional support', 'No')
101102

102103
await brainInjuryPage.clickSave()
103104
}

integration_tests/fixtures/applicationData.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,14 @@
196196
"brain-injury": {
197197
"hasBrainInjury": "no",
198198
"injuryDetail": "",
199+
"supportNeeded": "no",
200+
"supportDetail": "",
201+
"receivingTreatment": "no",
202+
"treatmentDetail": "",
199203
"isVulnerable": "no",
200204
"vulnerabilityDetail": "",
201205
"hasDifficultyInteracting": "no",
202-
"interactionDetail": "",
203-
"requiresAdditionalSupport": "no",
204-
"addSupportDetail": ""
206+
"interactionDetail": ""
205207
},
206208
"other-health": {
207209
"hasLongTermHealthCondition": "no",

integration_tests/pages/apply/risks_and_needs/health-needs/brainInjuryPage.ts

+11-6
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,24 @@ export default class BrainInjuryPage extends ApplyPage {
2828
}
2929

3030
pageHasBrainInjuryGuidance = (): void => {
31-
cy.get('.guidance').contains('This could be as a result of accident')
31+
cy.get('p').contains('This could be as a result of accident')
3232
}
3333

3434
describeInjuryAndNeeds = (): void => {
3535
this.checkRadioByNameAndValue('hasBrainInjury', 'yes')
3636
this.getTextInputByIdAndEnterDetails('injuryDetail', 'Has frontal lobe damange')
3737
}
3838

39+
describeSupportNeeded = (): void => {
40+
this.checkRadioByNameAndValue('supportNeeded', 'yes')
41+
this.getTextInputByIdAndEnterDetails('supportDetail', 'Requires regular support')
42+
}
43+
44+
describeTreatment = (): void => {
45+
this.checkRadioByNameAndValue('receivingTreatment', 'yes')
46+
this.getTextInputByIdAndEnterDetails('treatmentDetail', 'Lots of treatment')
47+
}
48+
3949
describeVulnerability = (): void => {
4050
this.checkRadioByNameAndValue('isVulnerable', 'yes')
4151
this.getTextInputByIdAndEnterDetails('vulnerabilityDetail', 'Medium: can put themselves in danger')
@@ -45,9 +55,4 @@ export default class BrainInjuryPage extends ApplyPage {
4555
this.checkRadioByNameAndValue('hasDifficultyInteracting', 'yes')
4656
this.getTextInputByIdAndEnterDetails('interactionDetail', 'Can misunderstand situations')
4757
}
48-
49-
describeAdditionalSupportNeeded = (): void => {
50-
this.checkRadioByNameAndValue('requiresAdditionalSupport', 'yes')
51-
this.getTextInputByIdAndEnterDetails('addSupportDetail', 'Requires regular support')
52-
}
5358
}

integration_tests/tests/apply/risks_and_needs/health-needs/brain_injury.cy.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,10 @@ context('Visit "brain injury" page', () => {
7070
const page = new BrainInjuryPage(this.application)
7171

7272
page.describeInjuryAndNeeds()
73+
page.describeSupportNeeded()
74+
page.describeTreatment()
7375
page.describeVulnerability()
7476
page.describeDifficultiesInteracting()
75-
page.describeAdditionalSupportNeeded()
7677

7778
page.clickSubmit()
7879

server/form-pages/apply/risks-and-needs/health-needs/brainInjury.test.ts

+122-130
Original file line numberDiff line numberDiff line change
@@ -6,185 +6,177 @@ describe('BrainInjury', () => {
66
const application = applicationFactory.build({ person: personFactory.build({ name: 'Roger Smith' }) })
77

88
describe('title', () => {
9-
it('personalises the page title', () => {
10-
const page = new BrainInjury({}, application)
9+
itShouldHaveNextValue(new BrainInjury({}, application), 'other-health')
10+
itShouldHavePreviousValue(new BrainInjury({}, application), 'learning-difficulties')
1111

12-
expect(page.title).toEqual('Brain injury needs for Roger Smith')
13-
})
14-
})
12+
describe('errors', () => {
13+
describe('when top-level questions are unanswered', () => {
14+
const page = new BrainInjury({}, application)
1515

16-
describe('questions', () => {
17-
const page = new BrainInjury({}, application)
16+
it('includes a validation error for _hasBrainInjury_', () => {
17+
expect(page.errors()).toHaveProperty(
18+
'hasBrainInjury',
19+
`Select if they have a brain injury, or select 'I do not know'`,
20+
)
21+
})
1822

19-
describe('hasBrainInjury', () => {
20-
it('has a question', () => {
21-
expect(page.questions.hasBrainInjury.question).toBeDefined()
22-
})
23-
it('has one follow-up question', () => {
24-
expect(page.questions.injuryDetail.question).toBeDefined()
25-
})
26-
})
23+
it('includes a validation error for _supportNeeded_', () => {
24+
expect(page.errors()).toHaveProperty(
25+
'supportNeeded',
26+
`Select if they need any support, or select 'I do not know'`,
27+
)
28+
})
2729

28-
describe('isVulnerable', () => {
29-
it('has a question', () => {
30-
expect(page.questions.isVulnerable.question).toBeDefined()
31-
})
32-
it('has one follow-up question', () => {
33-
expect(page.questions.vulnerabilityDetail.question).toBeDefined()
34-
})
35-
})
30+
it('includes a validation error for _receivingTreatment_', () => {
31+
expect(page.errors()).toHaveProperty(
32+
'receivingTreatment',
33+
`Select if they receive any treatment or medication, or select 'I do not know'`,
34+
)
35+
})
3636

37-
describe('hasDifficultyInteracting', () => {
38-
it('has a question', () => {
39-
expect(page.questions.hasDifficultyInteracting.question).toBeDefined()
40-
})
41-
it('has one follow-up question', () => {
42-
expect(page.questions.interactionDetail.question).toBeDefined()
43-
})
44-
})
37+
it('includes a validation error for _isVulnerable_', () => {
38+
expect(page.errors()).toHaveProperty(
39+
'isVulnerable',
40+
`Select if they are vulnerable, or select 'I do not know'`,
41+
)
42+
})
4543

46-
describe('requiresAdditionalSupport', () => {
47-
it('has a question', () => {
48-
expect(page.questions.requiresAdditionalSupport.question).toBeDefined()
49-
})
50-
it('has one follow-up question', () => {
51-
expect(page.questions.addSupportDetail.question).toBeDefined()
44+
it('includes a validation error for _hasDifficultyInteracting_', () => {
45+
expect(page.errors()).toHaveProperty(
46+
'hasDifficultyInteracting',
47+
`Select if they have difficulties interacting with other people, or select 'I do not know'`,
48+
)
49+
})
5250
})
53-
})
54-
})
55-
56-
itShouldHaveNextValue(new BrainInjury({}, application), 'other-health')
57-
itShouldHavePreviousValue(new BrainInjury({}, application), 'learning-difficulties')
5851

59-
describe('errors', () => {
60-
describe('when top-level questions are unanswered', () => {
61-
const page = new BrainInjury({}, application)
52+
describe('when _hasBrainInjury_ is YES', () => {
53+
const page = new BrainInjury({ hasBrainInjury: 'yes' }, application)
6254

63-
it('includes a validation error for _hasBrainInjury_', () => {
64-
expect(page.errors()).toHaveProperty('hasBrainInjury', 'Confirm whether they have a brain injury')
55+
describe('and _injuryDetail_ is UNANSWERED', () => {
56+
it('includes a validation error for _injuryDetail_', () => {
57+
expect(page.errors()).toHaveProperty('injuryDetail', 'Enter details of their brain injury and needs')
58+
})
59+
})
6560
})
6661

67-
it('includes a validation error for _isVulnerable_', () => {
68-
expect(page.errors()).toHaveProperty('isVulnerable', 'Confirm whether they are vulnerable')
69-
})
62+
describe('when _supportNeeded_ is YES', () => {
63+
const page = new BrainInjury({ supportNeeded: 'yes' }, application)
7064

71-
it('includes a validation error for _hasDifficultyInteracting_', () => {
72-
expect(page.errors()).toHaveProperty(
73-
'hasDifficultyInteracting',
74-
'Confirm whether they have difficulties interacting',
75-
)
76-
})
77-
78-
it('includes a validation error for _requiresAdditionalSupport_', () => {
79-
expect(page.errors()).toHaveProperty(
80-
'requiresAdditionalSupport',
81-
'Confirm whether additional support is required',
82-
)
65+
describe('and _supportDetail_ is UNANSWERED', () => {
66+
it('includes a validation error for _supportDetail_', () => {
67+
expect(page.errors()).toHaveProperty('supportDetail', 'Enter the type of support needed')
68+
})
69+
})
8370
})
84-
})
8571

86-
describe('when _hasBrainInjury_ is YES', () => {
87-
const page = new BrainInjury({ hasBrainInjury: 'yes' }, application)
72+
describe('when _receivingTreatment_ is YES', () => {
73+
const page = new BrainInjury({ receivingTreatment: 'yes' }, application)
8874

89-
describe('and _injuryDetail_ is UNANSWERED', () => {
90-
it('includes a validation error for _injuryDetail_', () => {
91-
expect(page.errors()).toHaveProperty('injuryDetail', 'Describe their brain injury and needs')
75+
describe('and _treatmentDetail_ is UNANSWERED', () => {
76+
it('includes a validation error for _treatmentDetail_', () => {
77+
expect(page.errors()).toHaveProperty(
78+
'treatmentDetail',
79+
'Enter details about their treatment and medication',
80+
)
81+
})
9282
})
9383
})
94-
})
9584

96-
describe('when _isVulnerable_ is YES', () => {
97-
const page = new BrainInjury({ isVulnerable: 'yes' }, application)
85+
describe('when _isVulnerable_ is YES', () => {
86+
const page = new BrainInjury({ isVulnerable: 'yes' }, application)
9887

99-
describe('and _vulnerabilityDetail_ is UNANSWERED', () => {
100-
it('includes a validation error for _vulnerabilityDetail_', () => {
101-
expect(page.errors()).toHaveProperty('vulnerabilityDetail', 'Describe their level of vulnerability')
88+
describe('and _vulnerabilityDetail_ is UNANSWERED', () => {
89+
it('includes a validation error for _vulnerabilityDetail_', () => {
90+
expect(page.errors()).toHaveProperty('vulnerabilityDetail', 'Enter how they are vulnerable')
91+
})
10292
})
10393
})
104-
})
10594

106-
describe('when _hasDifficultyInteracting_ is YES', () => {
107-
const page = new BrainInjury({ hasDifficultyInteracting: 'yes' }, application)
95+
describe('when _hasDifficultyInteracting_ is YES', () => {
96+
const page = new BrainInjury({ hasDifficultyInteracting: 'yes' }, application)
10897

109-
describe('and _interactionDetail_ is UNANSWERED', () => {
110-
it('includes a validation error for _interactionDetail_', () => {
111-
expect(page.errors()).toHaveProperty(
112-
'interactionDetail',
113-
'Describe their difficulties interacting with other people',
114-
)
98+
describe('and _interactionDetail_ is UNANSWERED', () => {
99+
it('includes a validation error for _interactionDetail_', () => {
100+
expect(page.errors()).toHaveProperty('interactionDetail', 'Enter the type of difficulties they have')
101+
})
115102
})
116103
})
117104
})
118105

119-
describe('when _requiresAdditionalSupport_ is YES', () => {
120-
const page = new BrainInjury({ requiresAdditionalSupport: 'yes' }, application)
106+
describe('onSave', () => {
107+
it('removes brain injury data when the question is set to "no"', () => {
108+
const body: Partial<BrainInjuryBody> = {
109+
hasBrainInjury: 'no',
110+
injuryDetail: 'Injury detail',
111+
}
112+
113+
const page = new BrainInjury(body, application)
114+
115+
page.onSave()
121116

122-
describe('and _addSupportDetail_ is UNANSWERED', () => {
123-
it('includes a validation error for _addSupportDetail_', () => {
124-
expect(page.errors()).toHaveProperty('addSupportDetail', 'Describe the additional support required')
117+
expect(page.body).toEqual({
118+
hasBrainInjury: 'no',
125119
})
126120
})
127-
})
128-
})
129121

130-
describe('onSave', () => {
131-
it('removes brain injury data when the question is set to "no"', () => {
132-
const body: Partial<BrainInjuryBody> = {
133-
hasBrainInjury: 'no',
134-
injuryDetail: 'Injury detail',
135-
}
122+
it('removes support data when the question is set to "no"', () => {
123+
const body: Partial<BrainInjuryBody> = {
124+
supportNeeded: 'no',
125+
supportDetail: 'Support detail',
126+
}
136127

137-
const page = new BrainInjury(body, application)
128+
const page = new BrainInjury(body, application)
138129

139-
page.onSave()
130+
page.onSave()
140131

141-
expect(page.body).toEqual({
142-
hasBrainInjury: 'no',
132+
expect(page.body).toEqual({
133+
supportNeeded: 'no',
134+
})
143135
})
144-
})
145136

146-
it('removes vulnerability data when the question is set to "no"', () => {
147-
const body: Partial<BrainInjuryBody> = {
148-
isVulnerable: 'no',
149-
vulnerabilityDetail: 'Vulnerability detail',
150-
}
137+
it('removes treatment data when the question is set to "no"', () => {
138+
const body: Partial<BrainInjuryBody> = {
139+
receivingTreatment: 'no',
140+
treatmentDetail: 'Treatment detail',
141+
}
151142

152-
const page = new BrainInjury(body, application)
143+
const page = new BrainInjury(body, application)
153144

154-
page.onSave()
145+
page.onSave()
155146

156-
expect(page.body).toEqual({
157-
isVulnerable: 'no',
147+
expect(page.body).toEqual({
148+
receivingTreatment: 'no',
149+
})
158150
})
159-
})
160151

161-
it('removes interaction difficulty data when the question is set to "no"', () => {
162-
const body: Partial<BrainInjuryBody> = {
163-
hasDifficultyInteracting: 'no',
164-
interactionDetail: 'Interaction detail',
165-
}
152+
it('removes vulnerability data when the question is set to "no"', () => {
153+
const body: Partial<BrainInjuryBody> = {
154+
isVulnerable: 'no',
155+
vulnerabilityDetail: 'Vulnerability detail',
156+
}
166157

167-
const page = new BrainInjury(body, application)
158+
const page = new BrainInjury(body, application)
168159

169-
page.onSave()
160+
page.onSave()
170161

171-
expect(page.body).toEqual({
172-
hasDifficultyInteracting: 'no',
162+
expect(page.body).toEqual({
163+
isVulnerable: 'no',
164+
})
173165
})
174-
})
175166

176-
it('removes additional support data when the question is set to "no"', () => {
177-
const body: Partial<BrainInjuryBody> = {
178-
requiresAdditionalSupport: 'no',
179-
addSupportDetail: 'Additional support detail',
180-
}
167+
it('removes interaction difficulty data when the question is set to "no"', () => {
168+
const body: Partial<BrainInjuryBody> = {
169+
hasDifficultyInteracting: 'no',
170+
interactionDetail: 'Interaction detail',
171+
}
181172

182-
const page = new BrainInjury(body, application)
173+
const page = new BrainInjury(body, application)
183174

184-
page.onSave()
175+
page.onSave()
185176

186-
expect(page.body).toEqual({
187-
requiresAdditionalSupport: 'no',
177+
expect(page.body).toEqual({
178+
hasDifficultyInteracting: 'no',
179+
})
188180
})
189181
})
190182
})

0 commit comments

Comments
 (0)