Skip to content

Commit

Permalink
MAP-626 Reformat Pain inducing techniques question (#675)
Browse files Browse the repository at this point in the history
* MAP-626 Reformat pain inducing techniques question

* MAP-626 Fix ITs after pain techniques reformat
  • Loading branch information
danbenton-mojdt authored Jan 26, 2024
1 parent 68b23b4 commit d36d186
Show file tree
Hide file tree
Showing 15 changed files with 95 additions and 109 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ context('Enter use of force details page', () => {
useOfForceDetailsPage.escortingHold().check('true')
useOfForceDetailsPage.restraintPositions.check(restraintPositions)
useOfForceDetailsPage.handcuffsApplied().check('true')
useOfForceDetailsPage.painInducingTechniques().check('true')
useOfForceDetailsPage.painInducingTechniquesUsed.check(['THUMB_LOCK', 'THROUGH_RIGID_BAR_CUFFS'])
const relocationAndInjuriesPage = useOfForceDetailsPage.save()
return relocationAndInjuriesPage
Expand All @@ -63,7 +62,6 @@ context('Enter use of force details page', () => {
personalProtectionTechniques: true,
positiveCommunication: true,
restraintPositions: ['STANDING', 'ON_BACK', 'FACE_DOWN', 'KNEELING'],
painInducingTechniques: true,
painInducingTechniquesUsed: ['THROUGH_RIGID_BAR_CUFFS', 'THUMB_LOCK'],
})
})
Expand All @@ -89,7 +87,6 @@ context('Enter use of force details page', () => {
personalProtectionTechniques: true,
positiveCommunication: true,
restraintPositions: 'STANDING',
painInducingTechniques: true,
painInducingTechniquesUsed: ['THROUGH_RIGID_BAR_CUFFS', 'THUMB_LOCK'],
})
})
Expand Down Expand Up @@ -118,7 +115,8 @@ context('Enter use of force details page', () => {
useOfForceDetailsPage.restraintPositions.kneeling().should('be.checked')
useOfForceDetailsPage.restraintPositions.onBack().should('not.be.checked')
useOfForceDetailsPage.handcuffsApplied().should('have.value', 'true')
useOfForceDetailsPage.painInducingTechniques().should('have.value', 'true')
useOfForceDetailsPage.painInducingTechniquesUsed.throughRigidBarCuffs().should('be.checked')
useOfForceDetailsPage.painInducingTechniquesUsed.thumbLock().should('be.checked')
})

it('Displays validation messages', () => {
Expand All @@ -139,9 +137,9 @@ context('Enter use of force details page', () => {
useOfForceDetailsPage.guidingHoldOfficersInvolved.check('2')
useOfForceDetailsPage.escortingHold().check('true')
useOfForceDetailsPage.handcuffsApplied().check('true')
useOfForceDetailsPage.painInducingTechniques().check('true')
useOfForceDetailsPage.clickSaveAndContinue()
useOfForceDetailsPage.errorSummary().contains('Select yes if a baton was drawn')
useOfForceDetailsPage.errorSummary().contains('Enter the body-worn camera number')
useOfForceDetailsPage.errorSummary().contains('Select if any pain inducing techniques were used')
})
})
1 change: 0 additions & 1 deletion integration-tests/integration/seedData.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ const expectedPayload = {
escortingHold: true,
handcuffsApplied: true,
restraintPositions: ['STANDING', 'ON_BACK', 'FACE_DOWN', 'KNEELING'],
painInducingTechniques: true,
painInducingTechniquesUsed: ['FINAL_LOCK_FLEXION', 'THUMB_LOCK'],
positiveCommunication: true,
guidingHoldOfficersInvolved: 2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ const useOfForceDetailsPage = () =>

handcuffsApplied: () => cy.get('[name="handcuffsApplied"]'),

painInducingTechniques: () => cy.get('[name="painInducingTechniques"]'),
painInducingTechniquesUsed: {
check: value => cy.get('#pain-inducing-techniques [type="checkbox"]').check(value),
thumbLock: () => cy.get('#pain-inducing-techniques [type="checkbox"][value="THUMB_LOCK"]'),
Expand All @@ -47,6 +46,7 @@ const useOfForceDetailsPage = () =>
finalLockRotation: () => cy.get('#pain-inducing-techniques [type="checkbox"][value="FINAL_LOCK_ROTATION"]'),
throughRigidBarCuffs: () =>
cy.get('#pain-inducing-techniques [type="checkbox"][value="THROUGH_RIGID_BAR_CUFFS"]'),
none: () => cy.get('#pain-inducing-techniques [type="checkbox"][value="NONE"]'),
},

fillForm() {
Expand All @@ -62,7 +62,6 @@ const useOfForceDetailsPage = () =>
this.escortingHold().check('true')
this.restraintPositions.check(['STANDING', 'ON_BACK', 'FACE_DOWN', 'KNEELING'])
this.handcuffsApplied().check('true')
this.painInducingTechniques().check('true')
this.painInducingTechniquesUsed.check(['THUMB_LOCK', 'FINAL_LOCK_FLEXION'])
},

Expand Down
5 changes: 1 addition & 4 deletions integration-tests/pages/sections/reportDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const positiveCommunicationUsed = () => cy.get('[data-qa="positiveCommunication"
const handcuffsApplied = () => cy.get('[data-qa=handcuffsApplied]')
const prisonerCompliant = () => cy.get('[data-qa="compliancy"]')
const photosTaken = () => cy.get('[data-qa="photographs"]')
const painInducingTechniques = () => cy.get('[data-qa=painInducingTechniques]')
const painInducingTechniquesUsed = () => cy.get('[data-qa=painInducingTechniquesUsed]')
const reasonsForUseOfForce = () => cy.get('[data-qa="reasonsForUseOfForce"')
const primaryReasonForUseOfForce = () => cy.get('[data-qa="primaryReason"')
Expand All @@ -17,7 +16,6 @@ module.exports = {
handcuffsApplied,
prisonerCompliant,
photosTaken,
painInducingTechniques,
painInducingTechniquesUsed,
prison,
reasonsForUseOfForce,
Expand Down Expand Up @@ -68,8 +66,7 @@ module.exports = {
cy.get('[data-qa="restraintUsed"]').contains('On front (prone)')
cy.get('[data-qa="restraintUsed"]').contains('Kneeling')
handcuffsApplied().contains('Yes')
painInducingTechniques().contains('Yes')
cy.get('[data-qa="painInducingTechniques"]').contains('Yes - wrist flexion, thumb lock')
cy.get('[data-qa="painInducingTechniques"]').contains('Wrist flexion, thumb lock')

cy.get('[data-qa="prisonerRelocation"]').contains('Segregation unit')
prisonerCompliant().contains('Yes')
Expand Down
61 changes: 33 additions & 28 deletions server/config/forms/useOfForceDetailsForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,34 +109,39 @@ const completeSchema = joi.object({
})
.alter(optionalForPartialValidation),

painInducingTechniques: requiredBooleanMsg('Select yes if pain inducing techniques were used').alter(
optionalForPartialValidation
),

painInducingTechniquesUsed: joi.when('painInducingTechniques', {
is: true,
then: joi
.alternatives()
.try(
joi
.array()
.items(
requiredOneOfMsg(
'FINAL_LOCK_FLEXION',
'FINAL_LOCK_ROTATION',
'MANDIBULAR_ANGLE_TECHNIQUE',
'SHOULDER_CONTROL',
'THROUGH_RIGID_BAR_CUFFS',
'THUMB_LOCK',
'UPPER_ARM_CONTROL'
)('Select the pain inducing techniques used').alter(optionalForPartialValidation)
)
)
.required()
.messages({ 'any.required': 'Select the pain inducing techniques used' })
.alter(optionalForPartialValidation),
otherwise: joi.any().strip(),
}),
painInducingTechniquesUsed: joi
.alternatives()
.try(
joi
.valid(
'FINAL_LOCK_FLEXION',
'FINAL_LOCK_ROTATION',
'MANDIBULAR_ANGLE_TECHNIQUE',
'SHOULDER_CONTROL',
'THROUGH_RIGID_BAR_CUFFS',
'THUMB_LOCK',
'UPPER_ARM_CONTROL',
'NONE'
)
.messages({ 'any.only': 'Select if any pain inducing techniques were used' }),
joi
.array()
.items(
requiredOneOfMsg(
'FINAL_LOCK_FLEXION',
'FINAL_LOCK_ROTATION',
'MANDIBULAR_ANGLE_TECHNIQUE',
'SHOULDER_CONTROL',
'THROUGH_RIGID_BAR_CUFFS',
'THUMB_LOCK',
'UPPER_ARM_CONTROL',
'NONE'
)('Select if any pain inducing techniques were used').alter(optionalForPartialValidation)
)
)
.required()
.messages({ 'any.required': 'Select if any pain inducing techniques were used' })
.alter(optionalForPartialValidation),

handcuffsApplied: requiredBooleanMsg('Select yes if handcuffs were applied').alter(optionalForPartialValidation),
})
Expand Down
37 changes: 5 additions & 32 deletions server/config/forms/useOfForceDetailsValidation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,11 @@ describe('complete schema', () => {
escortingHold: true,
restraintPositions: ['STANDING', 'FACE_DOWN'],
handcuffsApplied: true,
painInducingTechniques: true,
painInducingTechniquesUsed: ['FINAL_LOCK_FLEXION', 'THUMB_LOCK'],
})
})

it('Should return 10 error massages if no input field is completed', () => {
it('Should return 9 error messages if no input field is completed', () => {
const input = {}
const { errors, formResponse } = check(input)

Expand Down Expand Up @@ -92,8 +91,8 @@ describe('complete schema', () => {
text: 'Select which control and restraint positions were used',
},
{
href: '#painInducingTechniques',
text: 'Select yes if pain inducing techniques were used',
href: '#painInducingTechniquesUsed',
text: 'Select if any pain inducing techniques were used',
},
{
href: '#handcuffsApplied',
Expand Down Expand Up @@ -189,7 +188,6 @@ describe('complete schema', () => {
guidingHold: true,
guidingHoldOfficersInvolved: 2,
handcuffsApplied: true,
painInducingTechniques: true,
painInducingTechniquesUsed: ['FINAL_LOCK_FLEXION', 'THUMB_LOCK'],
pavaDrawn: true,
pavaUsed: true,
Expand All @@ -215,7 +213,6 @@ describe('complete schema', () => {
guidingHold: true,
guidingHoldOfficersInvolved: 2,
handcuffsApplied: true,
painInducingTechniques: true,
painInducingTechniquesUsed: ['FINAL_LOCK_FLEXION', 'THUMB_LOCK'],
pavaDrawn: true,
pavaUsed: true,
Expand Down Expand Up @@ -245,7 +242,6 @@ describe('complete schema', () => {
guidingHold: true,
guidingHoldOfficersInvolved: 2,
handcuffsApplied: true,
painInducingTechniques: true,
painInducingTechniquesUsed: ['FINAL_LOCK_FLEXION', 'THUMB_LOCK'],
pavaDrawn: true,
pavaUsed: true,
Expand Down Expand Up @@ -462,63 +458,41 @@ describe('complete schema', () => {
expect(formResponse.handcuffsAplied).toBe(undefined)
})

it("Not selecting Yes or No for 'pain inducing techniques used' radio returns a validation error message", () => {
const input = {
...validInput,
painInducingTechniques: undefined,
}
const { errors, formResponse } = check(input)

expect(errors).toEqual([
{
href: '#painInducingTechniques',
text: 'Select yes if pain inducing techniques were used',
},
])
expect(formResponse.painInducingTechniques).toBe(undefined)
})

it("Selecting Yes to 'pain inducing techniques used' radio but nothing for 'techniques' checkboxes returns a validation error message", () => {
it("Selecting nothing for 'pain inducing techniques' checkboxes returns a validation error message", () => {
const input = {
...validInput,
painInducingTechniques: 'true',
painInducingTechniquesUsed: undefined,
}
const { errors, formResponse } = check(input)

expect(errors).toEqual([
{
href: '#painInducingTechniquesUsed',
text: 'Select the pain inducing techniques used',
text: 'Select if any pain inducing techniques were used',
},
])
expect(formResponse.painInducingTechniques).toEqual(true)
expect(formResponse.painInducingTechniquesUsed).toBe(undefined)
})

it("Selecting just 1 option for 'pain inducing techniques' returns no errors", () => {
const input = {
...validInput,
painInducingTechniques: 'true',
painInducingTechniquesUsed: ['THUMB_LOCK'],
}
const { errors, formResponse } = check(input)

expect(errors).toEqual([])
expect(formResponse.painInducingTechniques).toBe(true)
expect(formResponse.painInducingTechniquesUsed).toEqual(['THUMB_LOCK'])
})

it('Selecting more than 1 option for pain inducing techniques returns no errors', () => {
const input = {
...validInput,
painInducingTechniques: 'true',
painInducingTechniquesUsed: ['FINAL_LOCK_FLEXION', 'THUMB_LOCK'],
}
const { errors, formResponse } = check(input)

expect(errors).toEqual([])
expect(formResponse.painInducingTechniques).toEqual(true)
expect(formResponse.painInducingTechniquesUsed).toEqual(['FINAL_LOCK_FLEXION', 'THUMB_LOCK'])
})
})
Expand Down Expand Up @@ -546,7 +520,6 @@ describe('partial schema', () => {
escortingHold: true,
restraintPositions: ['STANDING', 'FACE_DOWN'],
handcuffsApplied: true,
painInducingTechniques: true,
painInducingTechniquesUsed: ['FINAL_LOCK_FLEXION', 'THUMB_LOCK'],
})
})
Expand Down
1 change: 1 addition & 0 deletions server/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export const PainInducingTechniquesUsed = toEnum({
THROUGH_RIGID_BAR_CUFFS: { value: 'THROUGH_RIGID_BAR_CUFFS', label: 'Through rigid bar cuffs' },
THUMB_LOCK: { value: 'THUMB_LOCK', label: 'Thumb lock' },
UPPER_ARM_CONTROL: { value: 'UPPER_ARM_CONTROL', label: 'Upper arm control' },
NONE: { value: 'NONE', label: 'No pain inducing techniques were used', exclusive: true },
})

export const RelocationLocation = toEnum({
Expand Down
4 changes: 2 additions & 2 deletions server/data/UseOfForceReport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export type UseOfForceDetails = {
restraint?: boolean
restraintPositions: string | string[]
handcuffsApplied: boolean
painInducingTechniques: boolean
painInducingTechniquesUsed: string[]
painInducingTechniques?: boolean
painInducingTechniquesUsed: string | string[]
}

export type ReasonsForUseOfForce = {
Expand Down
31 changes: 28 additions & 3 deletions server/routes/creatingReports/checkYourAnswers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describe('GET /check-your-answers', () => {
.expect(200)
.expect('Content-Type', /html/)
.expect(res => {
expect(res.text).not.toContain('Were pain inducing techniques used?')
expect(res.text).not.toContain('Which pain inducing techniques were used?')
})
})

Expand All @@ -98,7 +98,7 @@ describe('GET /check-your-answers', () => {
.expect(200)
.expect('Content-Type', /html/)
.expect(res => {
expect(res.text).toContain('Were pain inducing techniques used?')
expect(res.text).toContain('Which pain inducing techniques were used?')
})
})

Expand All @@ -125,10 +125,35 @@ describe('GET /check-your-answers', () => {
.expect(200)
.expect('Content-Type', /html/)
.expect(res => {
expect(res.text).toContain('Were pain inducing techniques used?')
expect(res.text).toContain('Which pain inducing techniques were used?')
})
})

it('Should contain the pain inducing techniques question [pain inducing techniques is undefined but techniques listed]', () => {
draftReportService.getReportStatus.mockReturnValue({ complete: true })
draftReportService.getCurrentDraft.mockResolvedValue({
form: {
incidentDetails: {},
useOfForceDetails: {
pavaDrawn: false,
batonDrawn: false,
guidingHold: false,
handcuffsApplied: false,
positiveCommunication: false,
painInducingTechniquesUsed: 'NONE',
personalProtectionTechniques: false,
restraintPositions: 'NONE',
},
},
})
return request(app)
.get('/report/-35/check-your-answers')
.expect(200)
.expect('Content-Type', /html/)
.expect(res => {
expect(res.text).toContain('Which pain inducing techniques were used?')
})
})
it('Should contain prisoner compliant', () => {
draftReportService.getReportStatus.mockReturnValue({ complete: true })
draftReportService.getCurrentDraft.mockResolvedValue({
Expand Down
Loading

0 comments on commit d36d186

Please sign in to comment.