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

MAP-573 Add escorting hold question #671

Merged
merged 13 commits into from
Jan 19, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ context('Check your answers page', () => {
selectUofReasonsPage.checkReason('FIGHT_BETWEEN_PRISONERS')
selectUofReasonsPage.clickSave()
const useOfForceDetailsPage = UseOfForceDetailsPage.verifyOnPage()
useOfForceDetailsPage.postiveCommunication().check('false')
useOfForceDetailsPage.positiveCommunication().check('false')
operation(useOfForceDetailsPage)
const revisitedAnswersPage = CheckAnswersPage.verifyOnPage()
revisitedAnswersPage.positiveCommunicationUsed().contains(finalValue)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ context('Enter use of force details page', () => {
selectUofReasonsPage.clickSaveAndContinue()

const useOfForceDetailsPage = UseOfForceDetailsPage.verifyOnPage()
useOfForceDetailsPage.postiveCommunication().check('true')
useOfForceDetailsPage.positiveCommunication().check('true')
useOfForceDetailsPage.personalProtectionTechniques().check('true')
useOfForceDetailsPage.batonDrawn().check('true')
useOfForceDetailsPage.batonUsed().check('true')
useOfForceDetailsPage.pavaDrawn().check('true')
useOfForceDetailsPage.pavaUsed().check('true')
useOfForceDetailsPage.guidingHold().check('true')
useOfForceDetailsPage.guidingHoldOfficersInvolved.check('2')
useOfForceDetailsPage.escortingHold().check('true')
useOfForceDetailsPage.restraint().check('true')
useOfForceDetailsPage.restraintPositions.check(restraintPositions)
useOfForceDetailsPage.handcuffsApplied().check('true')
Expand All @@ -48,6 +49,7 @@ context('Enter use of force details page', () => {
batonUsed: true,
guidingHold: true,
guidingHoldOfficersInvolved: 2,
escortingHold: true,
handcuffsApplied: true,
pavaDrawn: true,
pavaUsed: true,
Expand All @@ -72,6 +74,7 @@ context('Enter use of force details page', () => {
batonUsed: true,
guidingHold: true,
guidingHoldOfficersInvolved: 2,
escortingHold: true,
handcuffsApplied: true,
pavaDrawn: true,
pavaUsed: true,
Expand All @@ -92,14 +95,15 @@ context('Enter use of force details page', () => {
cy.go('back')

const useOfForceDetailsPage = UseOfForceDetailsPage.verifyOnPage()
useOfForceDetailsPage.postiveCommunication().should('have.value', 'true')
useOfForceDetailsPage.positiveCommunication().should('have.value', 'true')
useOfForceDetailsPage.personalProtectionTechniques().should('have.value', 'true')
useOfForceDetailsPage.batonDrawn().should('have.value', 'true')
useOfForceDetailsPage.batonUsed().should('have.value', 'true')
useOfForceDetailsPage.pavaDrawn().should('have.value', 'true')
useOfForceDetailsPage.pavaUsed().should('have.value', 'true')
useOfForceDetailsPage.guidingHold().should('have.value', 'true')
useOfForceDetailsPage.guidingHoldOfficersInvolved.two().should('be.checked')
useOfForceDetailsPage.escortingHold().should('have.value', 'true')
useOfForceDetailsPage.restraint().should('have.value', 'true')
useOfForceDetailsPage.restraintPositions.standing().should('be.checked')
useOfForceDetailsPage.restraintPositions.faceDown().should('not.be.checked')
Expand All @@ -118,12 +122,13 @@ context('Enter use of force details page', () => {
selectUofReasonsPage.clickSaveAndContinue()

const useOfForceDetailsPage = UseOfForceDetailsPage.verifyOnPage()
useOfForceDetailsPage.postiveCommunication().check('true')
useOfForceDetailsPage.positiveCommunication().check('true')
useOfForceDetailsPage.personalProtectionTechniques().check('true')
useOfForceDetailsPage.pavaDrawn().check('true')
useOfForceDetailsPage.pavaUsed().check('true')
useOfForceDetailsPage.guidingHold().check('true')
useOfForceDetailsPage.guidingHoldOfficersInvolved.check('2')
useOfForceDetailsPage.escortingHold().check('true')
useOfForceDetailsPage.restraint().check('false')
useOfForceDetailsPage.handcuffsApplied().check('true')
useOfForceDetailsPage.painInducingTechniques().check('true')
Expand Down
1 change: 1 addition & 0 deletions integration-tests/integration/seedData.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const expectedPayload = {
pavaDrawn: true,
batonDrawn: true,
guidingHold: true,
escortingHold: true,
restraint: true,
handcuffsApplied: true,
restraintPositions: ['STANDING', 'ON_BACK', 'FACE_DOWN', 'KNEELING'],
Expand Down
8 changes: 5 additions & 3 deletions integration-tests/pages/createReport/useOfForceDetailsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@ import RelocationAndInjuriesPage from './relocationAndInjuriesPage'

const useOfForceDetailsPage = () =>
page('Use of force details', {
postiveCommunication: () => cy.get('[name="positiveCommunication"]'),
positiveCommunication: () => cy.get('[name="positiveCommunication"]'),
personalProtectionTechniques: () => cy.get('[name="personalProtectionTechniques"]'),
batonDrawn: () => cy.get('[name="batonDrawn"]'),
batonUsed: () => cy.get('[name="batonUsed"]'),
pavaDrawn: () => cy.get('[name="pavaDrawn"]'),
pavaUsed: () => cy.get('[name="pavaUsed"]'),
guidingHold: () => cy.get('[name="guidingHold"]'),

guidingHoldOfficersInvolved: {
check: value => cy.get('[name="guidingHoldOfficersInvolved"]').check(value),
one: () => cy.get('[name="guidingHoldOfficersInvolved"][value="1"]'),
two: () => cy.get('[name="guidingHoldOfficersInvolved"][value="2"]'),
},

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

restraintPositions: {
check: value => cy.get('#control-and-restraint [type="checkbox"]').check(value),
standing: () => cy.get('#control-and-restraint [type="checkbox"][value="STANDING"]'),
Expand All @@ -43,14 +44,15 @@ const useOfForceDetailsPage = () =>
},

fillForm() {
this.postiveCommunication().check('true')
this.positiveCommunication().check('true')
this.personalProtectionTechniques().check('true')
this.batonDrawn().check('true')
this.batonUsed().check('true')
this.pavaDrawn().check('true')
this.pavaUsed().check('true')
this.guidingHold().check('true')
this.guidingHoldOfficersInvolved.check('2')
this.escortingHold().check('true')
this.restraint().check('true')
this.restraintPositions.check(['STANDING', 'ON_BACK', 'FACE_DOWN', 'KNEELING'])
this.handcuffsApplied().check('true')
Expand Down
1 change: 1 addition & 0 deletions integration-tests/pages/sections/reportDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ module.exports = {
cy.get('[data-qa="batonDrawn"]').contains('Yes and used')
cy.get('[data-qa="pavaDrawn"]').contains('Yes and used')
cy.get('[data-qa="guidingHold"]').contains('Yes - 2 officers involved')
cy.get('[data-qa="escortingHold"]').contains('Yes')
cy.get('[data-qa="restraintUsed"]').contains('Yes - standing, on back (supine), on front (prone), kneeling')
handcuffsApplied().contains('Yes')
painInducingTechniques().contains('Yes')
Expand Down
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
"mocha": "^10.2.0",
"mocha-junit-reporter": "^2.2.0",
"nock": "^13.3.1",
"node-sass": "^8.0.0",
"node-sass": "^9.0.0",
"nodemon": "^3.0.1",
"prettier": "^2.8.8",
"supertest": "^6.3.3",
Expand Down
2 changes: 2 additions & 0 deletions server/config/forms/useOfForceDetailsForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ const completeSchema = joi.object({
otherwise: joi.any().strip(),
}),

escortingHold: requiredBooleanMsg('Select yes if an escorting hold was used').alter(optionalForPartialValidation),

restraint: requiredBooleanMsg('Select yes if control and restraint was used').alter(optionalForPartialValidation),

restraintPositions: joi.when('restraint', {
Expand Down
29 changes: 27 additions & 2 deletions server/config/forms/useOfForceDetailsValidation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ beforeEach(() => {
pavaUsed: 'true',
guidingHold: 'true',
guidingHoldOfficersInvolved: '2',
escortingHold: 'true',
restraint: 'true',
restraintPositions: ['STANDING', 'FACE_DOWN'],
handcuffsApplied: 'true',
Expand All @@ -44,6 +45,7 @@ describe('complete schema', () => {
pavaUsed: true,
guidingHold: true,
guidingHoldOfficersInvolved: 2,
escortingHold: true,
restraint: true,
restraintPositions: ['STANDING', 'FACE_DOWN'],
handcuffsApplied: true,
Expand All @@ -52,7 +54,7 @@ describe('complete schema', () => {
})
})

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

Expand All @@ -77,6 +79,10 @@ describe('complete schema', () => {
href: '#guidingHold',
text: 'Select yes if a guiding hold was used',
},
{
href: '#escortingHold',
text: 'Select yes if an escorting hold was used',
},
{
href: '#restraint',
text: 'Select yes if control and restraint was used',
Expand All @@ -91,7 +97,7 @@ describe('complete schema', () => {
},
])

expect(errors.length).toEqual(8)
expect(errors.length).toEqual(9)

expect(formResponse).toEqual({})
})
Expand Down Expand Up @@ -240,6 +246,22 @@ describe('complete schema', () => {
expect(formResponse.guidingHoldOfficersInvolved).toEqual(2)
})

it("Not selecting an option for 'escorting hold' returns validation error message plus 'how many officers involved' is undefined", () => {
const input = {
...validInput,
escortingHold: undefined,
}
const { errors, formResponse } = check(input)

expect(errors).toEqual([
{
href: '#escortingHold',
text: 'Select yes if an escorting hold was used',
},
])
expect(formResponse.escortingHold).toEqual(undefined)
})

it("Not selecting an option for 'restraint'returns a validation error message plus 'restraint positions' is undefined", () => {
const input = {
...validInput,
Expand Down Expand Up @@ -393,6 +415,7 @@ describe('partial schema', () => {
pavaUsed: true,
guidingHold: true,
guidingHoldOfficersInvolved: 2,
escortingHold: true,
restraint: true,
restraintPositions: ['STANDING', 'FACE_DOWN'],
handcuffsApplied: true,
Expand All @@ -415,6 +438,7 @@ describe('partial schema', () => {
batonDrawn: 'true',
pavaDrawn: 'true',
guidingHold: 'true',
escortingHold: 'true',
restraint: 'true',
restraintPositions: [],
})
Expand All @@ -423,6 +447,7 @@ describe('partial schema', () => {
expect(formResponse).toEqual({
batonDrawn: true,
guidingHold: true,
escortingHold: true,
pavaDrawn: true,
restraint: true,
})
Expand Down
1 change: 1 addition & 0 deletions server/data/UseOfForceReport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export type UseOfForceDetails = {
pavaUsed: boolean
guidingHold: boolean
guidingHoldOfficersInvolved: number
escortingHold?: boolean
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this optional ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so, given previously created reports won't have a value for it

restraint: boolean
restraintPositions: string[]
handcuffsApplied: boolean
Expand Down
1 change: 1 addition & 0 deletions server/routes/creatingReports/checkYourAnswers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ describe('GET /check-your-answers', () => {
restraint: false,
batonDrawn: false,
guidingHold: false,
escortingHold: false,
handcuffsApplied: false,
positiveCommunication: false,
personalProtectionTechniques: false,
Expand Down
3 changes: 3 additions & 0 deletions server/routes/creatingReports/createReport.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const validUseOfForceDetailsRequest = {
batonDrawn: 'false',
pavaDrawn: 'false',
guidingHold: 'false',
escortingHold: 'false',
restraint: 'false',
painInducingTechniques: 'false',
handcuffsApplied: 'false',
Expand All @@ -56,6 +57,7 @@ const validUseofForceDetailUpdate = [
{
batonDrawn: false,
guidingHold: false,
escortingHold: false,
handcuffsApplied: false,
painInducingTechniques: false,
pavaDrawn: false,
Expand Down Expand Up @@ -112,6 +114,7 @@ describe('POST save and return to tasklist', () => {
expect(draftReportService.process).toBeCalledTimes(1)
expect(draftReportService.process).toBeCalledWith(user, 1, 'useOfForceDetails', {
guidingHold: false,
escortingHold: false,
handcuffsApplied: false,
painInducingTechniques: false,
pavaDrawn: false,
Expand Down
2 changes: 2 additions & 0 deletions server/services/drafts/reportStatusChecker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ describe('statusCheck', () => {
restraint: false,
batonDrawn: false,
guidingHold: false,
escortingHold: false,
handcuffsApplied: false,
positiveCommunication: false,
personalProtectionTechniques: true,
Expand Down Expand Up @@ -105,6 +106,7 @@ describe('statusCheck', () => {
restraint: false,
batonDrawn: null,
guidingHold: false,
escortingHold: false,
handcuffsApplied: null,
positiveCommunication: false,
personalProtectionTechniques: undefined,
Expand Down
1 change: 1 addition & 0 deletions server/services/reportDetailBuilder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ describe('Build details', () => {
batonDrawn: undefined,
controlAndRestraintUsed: undefined,
guidingHoldUsed: undefined,
escortingHoldUsed: undefined,
handcuffsApplied: undefined,
painInducingTechniques: undefined,
pavaDrawn: undefined,
Expand Down
1 change: 1 addition & 0 deletions server/services/reportSummary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const createUseOfForceDetails = (
guidingHoldUsed: whenPresent(details.guidingHold, value =>
value ? howManyOfficersInvolved(details.guidingHoldOfficersInvolved) : NO
),
escortingHoldUsed: details.escortingHold,
controlAndRestraintUsed: whenPresent(details.restraint, value =>
value === true && details.restraintPositions ? getRestraintPositions(details.restraintPositions) : NO
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{% from "govuk/components/radios/macro.njk" import govukRadios %}
{% from "govuk/components/error-summary/macro.njk" import govukErrorSummary %}

{% set pageTitle = 'Are you sure you want to delete staff member?' %}
{% set pageTitle = 'Are you sure you want to delete staff member?' %}

{% block content %}
<div class="govuk-grid-row govuk-body">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{% from "govuk/components/radios/macro.njk" import govukRadios %}
{% from "govuk/components/error-summary/macro.njk" import govukErrorSummary %}

{% set pageTitle = 'There is more than 1 person with that name' %}
{% set pageTitle = 'There is more than 1 person with that name' %}

{% block content %}
<form method="post">
Expand Down
2 changes: 1 addition & 1 deletion server/views/formPages/addingStaff/staff-involved.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{% from "govuk/components/table/macro.njk" import govukTable %}
{% from "govuk/components/error-summary/macro.njk" import govukErrorSummary %}

{% set pageTitle = 'Staff involved in use of force' %}
{% set pageTitle = 'Staff involved in use of force' %}

{% block formItems %}
<div class="govuk-grid-row govuk-body">
Expand Down
2 changes: 1 addition & 1 deletion server/views/formPages/addingStaff/staff-member-name.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{% from "govuk/components/fieldset/macro.njk" import govukFieldset %}
{% from "govuk/components/error-summary/macro.njk" import govukErrorSummary %}

{% set pageTitle = "What is the staff member's name?" %}
{% set pageTitle = "What is the staff member's name?" %}

{% block content %}
<div class="govuk-grid-row govuk-body">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends "../../partials/layout.html" %}
{% from "govuk/components/button/macro.njk" import govukButton %}

{% set pageTitle = name + ' cannot be found' %}
{% set pageTitle = name + ' cannot be found' %}

{% block content %}
<div class="govuk-grid-row govuk-body">
Expand Down
Loading
Loading