Skip to content

Commit

Permalink
MAP-961 change baton and pava question wording
Browse files Browse the repository at this point in the history
  • Loading branch information
GurnankCheema committed Apr 28, 2024
1 parent 707f18c commit 1d1a37e
Show file tree
Hide file tree
Showing 16 changed files with 184 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,52 @@ context('A reporter views their own report', () => {

const yourReportPage = YourReportPage.verifyOnPage()
yourReportPage.location().contains('–')
yourReportPage.batonDrawnAgainstPrisonerLabel().contains('Was a baton drawn against the prisoner?')
yourReportPage.pavaDrawnAgainstPrisonerLabel().contains('Was PAVA drawn against the prisoner?')
})

it('A user can view their own report with the old version of the Baton and PAVA questions', () => {
cy.task('stubLocationNotFound', '357591')

cy.login()

expectedPayload.useOfForceDetails.batonDrawnAgainstPrisoner = undefined
expectedPayload.useOfForceDetails.pavaDrawnAgainstPrisoner = undefined
expectedPayload.useOfForceDetails.batonDrawn = true
expectedPayload.useOfForceDetails.pavaDrawn = true

cy.task('seedReport', {
status: ReportStatus.SUBMITTED,
submittedDate: '2019-09-04 11:27:52',
involvedStaff: [
{
username: 'MR_ZAGATO',
name: 'MR_ZAGATO name',
email: '[email protected]',
},
{
username: 'MRS_JONES',
name: 'MRS_JONES name',
email: '[email protected]',
},
{
username: 'TEST_USER',
name: 'TEST_USER name',
email: '[email protected]',
},
],
payload: expectedPayload,
})

const yourStatementsPage = YourStatementsPage.goTo()
yourStatementsPage.yourReportsTab().click()

const yourReportsPage = YourReportsPage.verifyOnPage()
yourReportsPage.reports(0).action().click()

const yourReportPage = YourReportPage.verifyOnPage()
yourReportPage.location().contains('–')
yourReportPage.batonDrawnLabel().contains('Was a baton drawn by anyone during this incident?')
yourReportPage.pavaDrawnLabel().contains('Was PAVA drawn by anyone during this incident?')
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ context('Enter use of force details page', () => {
useOfForceDetailsPage.bodyWornCameraNumber(1).type('345')
useOfForceDetailsPage.removeBodyWornCamera(0)
useOfForceDetailsPage.personalProtectionTechniques().check('true')
useOfForceDetailsPage.batonDrawn().check('true')
useOfForceDetailsPage.batonDrawnAgainstPrisoner().check('true')
useOfForceDetailsPage.batonUsed().check('true')
useOfForceDetailsPage.pavaDrawn().check('true')
useOfForceDetailsPage.weaponsObserved().check('NO')
useOfForceDetailsPage.pavaDrawnAgainstPrisoner().check('true')
useOfForceDetailsPage.pavaUsed().check('true')
useOfForceDetailsPage.weaponsObserved().check('NO')
useOfForceDetailsPage.guidingHold().check('true')
useOfForceDetailsPage.guidingHoldOfficersInvolved.check('2')
useOfForceDetailsPage.escortingHold().check('true')
Expand All @@ -51,13 +51,13 @@ context('Enter use of force details page', () => {
expect(section).to.deep.equal({
bodyWornCamera: 'YES',
bodyWornCameraNumbers: [{ cameraNum: '345' }],
batonDrawn: true,
batonDrawnAgainstPrisoner: true,
batonUsed: true,
guidingHold: true,
guidingHoldOfficersInvolved: 2,
escortingHold: true,
handcuffsApplied: true,
pavaDrawn: true,
pavaDrawnAgainstPrisoner: true,
pavaUsed: true,
weaponsObserved: 'NO',
personalProtectionTechniques: true,
Expand All @@ -77,13 +77,13 @@ context('Enter use of force details page', () => {
expect(section).to.deep.equal({
bodyWornCamera: 'YES',
bodyWornCameraNumbers: [{ cameraNum: '345' }],
batonDrawn: true,
batonDrawnAgainstPrisoner: true,
batonUsed: true,
guidingHold: true,
guidingHoldOfficersInvolved: 2,
escortingHold: true,
handcuffsApplied: true,
pavaDrawn: true,
pavaDrawnAgainstPrisoner: true,
weaponsObserved: 'NO',
pavaUsed: true,
personalProtectionTechniques: true,
Expand All @@ -105,9 +105,9 @@ context('Enter use of force details page', () => {
useOfForceDetailsPage.bodyWornCamera().should('have.value', 'YES')
useOfForceDetailsPage.bodyWornCameraNumber(0).should('have.value', '345')
useOfForceDetailsPage.personalProtectionTechniques().should('have.value', 'true')
useOfForceDetailsPage.batonDrawn().should('have.value', 'true')
useOfForceDetailsPage.batonDrawnAgainstPrisoner().should('have.value', 'true')
useOfForceDetailsPage.batonUsed().should('have.value', 'true')
useOfForceDetailsPage.pavaDrawn().should('have.value', 'true')
useOfForceDetailsPage.pavaDrawnAgainstPrisoner().should('have.value', 'true')
useOfForceDetailsPage.pavaUsed().should('have.value', 'true')
useOfForceDetailsPage.guidingHold().should('have.value', 'true')
useOfForceDetailsPage.guidingHoldOfficersInvolved.two().should('be.checked')
Expand All @@ -132,7 +132,7 @@ context('Enter use of force details page', () => {
const useOfForceDetailsPage = UseOfForceDetailsPage.verifyOnPage()
useOfForceDetailsPage.positiveCommunication().check('true')
useOfForceDetailsPage.personalProtectionTechniques().check('true')
useOfForceDetailsPage.pavaDrawn().check('true')
useOfForceDetailsPage.pavaDrawnAgainstPrisoner().check('true')
useOfForceDetailsPage.pavaUsed().check('true')
useOfForceDetailsPage.guidingHold().check('true')
useOfForceDetailsPage.guidingHoldOfficersInvolved.check('2')
Expand All @@ -159,7 +159,7 @@ context('Enter use of force details page', () => {
useOfForceDetailsPage.positiveCommunication().check('true')
useOfForceDetailsPage.bodyWornCamera().check('YES')
useOfForceDetailsPage.personalProtectionTechniques().check('true')
useOfForceDetailsPage.pavaDrawn().check('true')
useOfForceDetailsPage.pavaDrawnAgainstPrisoner().check('true')
useOfForceDetailsPage.pavaUsed().check('true')
useOfForceDetailsPage.weaponsObserved().check('YES')
useOfForceDetailsPage.guidingHold().check('true')
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/integration/seedData.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ const expectedPayload = {
bodyWornCameraNumbers: [{ cameraNum: '123' }, { cameraNum: '789' }, { cameraNum: '456' }],
pavaUsed: true,
batonUsed: true,
pavaDrawn: true,
weaponsObserved: 'YES',
weaponTypes: [{ weaponType: 'gun' }, { weaponType: 'knife' }, { weaponType: 'fork' }],
batonDrawn: true,
batonDrawnAgainstPrisoner: true,
pavaDrawnAgainstPrisoner: true,
guidingHold: true,
escortingHold: true,
handcuffsApplied: true,
Expand Down
10 changes: 5 additions & 5 deletions integration-tests/pages/createReport/useOfForceDetailsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ const useOfForceDetailsPage = () =>
cy.get('.add-another-body-worn-camera .add-another__remove-button').eq(index).click(),

personalProtectionTechniques: () => cy.get('[name="personalProtectionTechniques"]'),
batonDrawn: () => cy.get('[name="batonDrawn"]'),
batonDrawnAgainstPrisoner: () => cy.get('[name="batonDrawnAgainstPrisoner"]'),
batonUsed: () => cy.get('[name="batonUsed"]'),
pavaDrawn: () => cy.get('[name="pavaDrawn"]'),
pavaDrawnAgainstPrisoner: () => cy.get('[name="pavaDrawnAgainstPrisoner"]'),
pavaUsed: () => cy.get('[name="pavaUsed"]'),
weaponsObserved: () => cy.get('[name="weaponsObserved"]'),
weaponTypes: index => cy.get(`[name="weaponTypes[${index}][weaponType]"]`),
addAnotherWeapon: () => cy.get('[dataqa=add-another-weapons-observed]').click(),
pavaUsed: () => cy.get('[name="pavaUsed"]'),
guidingHold: () => cy.get('[name="guidingHold"]'),
guidingHoldOfficersInvolved: {
check: value => cy.get('[name="guidingHoldOfficersInvolved"]').check(value),
Expand Down Expand Up @@ -57,9 +57,9 @@ const useOfForceDetailsPage = () =>
this.positiveCommunication().check('true')
this.bodyWornCamera().check('NO')
this.personalProtectionTechniques().check('true')
this.batonDrawn().check('true')
this.batonDrawnAgainstPrisoner().check('true')
this.batonUsed().check('true')
this.pavaDrawn().check('true')
this.pavaDrawnAgainstPrisoner().check('true')
this.pavaUsed().check('true')
this.weaponsObserved().check('NO')
this.guidingHold().check('true')
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/pages/sections/reportDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ module.exports = {

positiveCommunicationUsed().contains('Yes')
cy.get('[data-qa="personalProtection"]').contains('Yes')
cy.get('[data-qa="batonDrawn"]').contains('Yes and used')
cy.get('[data-qa="pavaDrawn"]').contains('Yes and used')
cy.get('[data-qa="batonDrawnAgainstPrisoner"]').contains('Yes and used')
cy.get('[data-qa="pavaDrawnAgainstPrisoner"]').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('Standing')
Expand Down
8 changes: 8 additions & 0 deletions integration-tests/pages/yourReports/yourReportPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ const viewYourReportPage = () =>

location: () => cy.get('[data-qa="location"]'),

batonDrawnLabel: () => cy.get('[data-qa="batonDrawn"]').parent(),

batonDrawnAgainstPrisonerLabel: () => cy.get('[data-qa="batonDrawnAgainstPrisoner"]').parent(),

pavaDrawnLabel: () => cy.get('[data-qa="pavaDrawn"]').parent(),

pavaDrawnAgainstPrisonerLabel: () => cy.get('[data-qa="pavaDrawnAgainstPrisoner"]').parent(),

verifyInputs: reportDetails.verifyInputs,

useOfForcePlanned: reportDetails.useOfForcePlanned,
Expand Down
18 changes: 9 additions & 9 deletions server/config/forms/useOfForceDetailsForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,21 @@ const completeSchema = joi.object({
optionalForPartialValidation
),

batonDrawn: requiredBooleanMsg('Select yes if a baton was drawn').alter(optionalForPartialValidation),
batonDrawnAgainstPrisoner: requiredBooleanMsg('Select yes if a baton was drawn').alter(optionalForPartialValidation),

batonUsed: joi.when('batonDrawn', {
batonUsed: joi.when('batonDrawnAgainstPrisoner', {
is: true,
then: requiredBooleanMsg('Select yes if a baton was used').alter(optionalForPartialValidation),
otherwise: joi.any().strip(),
}),

pavaDrawn: requiredBooleanMsg('Select yes if PAVA was drawn').alter(optionalForPartialValidation),
pavaDrawnAgainstPrisoner: requiredBooleanMsg('Select yes if PAVA was drawn').alter(optionalForPartialValidation),

pavaUsed: joi.when('pavaDrawnAgainstPrisoner', {
is: true,
then: requiredBooleanMsg('Select yes if PAVA was used').alter(optionalForPartialValidation),
otherwise: joi.any().strip(),
}),

weaponsObserved: requiredOneOfMsg(
'YES',
Expand All @@ -72,12 +78,6 @@ const completeSchema = joi.object({
})
.meta({ firstFieldName: 'weaponTypes[0]' }),

pavaUsed: joi.when('pavaDrawn', {
is: true,
then: requiredBooleanMsg('Select yes if PAVA was used').alter(optionalForPartialValidation),
otherwise: joi.any().strip(),
}),

guidingHold: requiredBooleanMsg('Select yes if a guiding hold was used').alter(optionalForPartialValidation),

guidingHoldOfficersInvolved: joi.when('guidingHold', {
Expand Down
Loading

0 comments on commit 1d1a37e

Please sign in to comment.