Skip to content

Commit

Permalink
Map 581 move question on body worn cameras to details screen (#672)
Browse files Browse the repository at this point in the history
* MAP-581 moved body camera question to report details page and updated unit tests

* MAP-581 update integration tests

* MAP-581 fix breaking test

* map-581 get body-camera details from 'evidence' and use in 'details' section

* map-581 made macros to be more generic

* MAP-581 remove temporary stop on integ tests
  • Loading branch information
GurnankCheema authored Jan 25, 2024
1 parent 6ea513a commit 4326a93
Show file tree
Hide file tree
Showing 20 changed files with 424 additions and 347 deletions.
2 changes: 1 addition & 1 deletion assets/js/add-another-evidence.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
new AddAnother($('.add-another-evidence'), '.remove-button-container')
new AddAnother($('.add-another-camera'), '.remove-button-container')
new AddAnother($('.add-another-input'), '.remove-button-container')
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ context('Submit the incident report', () => {

const useOfForceDetailsPage = UseOfForceDetailsPage.verifyOnPage()
useOfForceDetailsPage.fillForm()
useOfForceDetailsPage.bodyWornCamera().check('YES')
useOfForceDetailsPage.bodyWornCameraNumber(0).type('123')
useOfForceDetailsPage.addAnotherBodyWornCamera()
useOfForceDetailsPage.bodyWornCameraNumber(1).type('789')
useOfForceDetailsPage.addAnotherBodyWornCamera()
useOfForceDetailsPage.bodyWornCameraNumber(2).type('456')
const relocationAndInjuriesPage = useOfForceDetailsPage.save()
relocationAndInjuriesPage.fillForm()
const evidencePage = relocationAndInjuriesPage.save()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const { use } = require('passport')
const { offender } = require('../../mockApis/data')

const ReportUseOfForcePage = require('../../pages/createReport/reportUseOfForcePage')
Expand All @@ -21,6 +22,11 @@ context('Enter use of force details page', () => {

const useOfForceDetailsPage = UseOfForceDetailsPage.verifyOnPage()
useOfForceDetailsPage.positiveCommunication().check('true')
useOfForceDetailsPage.bodyWornCamera().check('YES')
useOfForceDetailsPage.bodyWornCameraNumber(0).type('123')
useOfForceDetailsPage.addAnotherBodyWornCamera()
useOfForceDetailsPage.bodyWornCameraNumber(1).type('345')
useOfForceDetailsPage.removeBodyWornCamera(0)
useOfForceDetailsPage.personalProtectionTechniques().check('true')
useOfForceDetailsPage.batonDrawn().check('true')
useOfForceDetailsPage.batonUsed().check('true')
Expand All @@ -45,6 +51,8 @@ context('Enter use of force details page', () => {

cy.task('getFormSection', { bookingId: offender.bookingId, formName: 'useOfForceDetails' }).then(({ section }) => {
expect(section).to.deep.equal({
bodyWornCamera: 'YES',
bodyWornCameraNumbers: [{ cameraNum: '345' }],
batonDrawn: true,
batonUsed: true,
guidingHold: true,
Expand All @@ -70,6 +78,8 @@ context('Enter use of force details page', () => {

cy.task('getFormSection', { bookingId: offender.bookingId, formName: 'useOfForceDetails' }).then(({ section }) => {
expect(section).to.deep.equal({
bodyWornCamera: 'YES',
bodyWornCameraNumbers: [{ cameraNum: '345' }],
batonDrawn: true,
batonUsed: true,
guidingHold: true,
Expand All @@ -96,6 +106,8 @@ context('Enter use of force details page', () => {

const useOfForceDetailsPage = UseOfForceDetailsPage.verifyOnPage()
useOfForceDetailsPage.positiveCommunication().should('have.value', 'true')
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.batonUsed().should('have.value', 'true')
Expand Down Expand Up @@ -123,6 +135,7 @@ context('Enter use of force details page', () => {

const useOfForceDetailsPage = UseOfForceDetailsPage.verifyOnPage()
useOfForceDetailsPage.positiveCommunication().check('true')
useOfForceDetailsPage.bodyWornCamera().check('YES')
useOfForceDetailsPage.personalProtectionTechniques().check('true')
useOfForceDetailsPage.pavaDrawn().check('true')
useOfForceDetailsPage.pavaUsed().check('true')
Expand All @@ -134,5 +147,6 @@ context('Enter use of force details page', () => {
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')
})
})
4 changes: 2 additions & 2 deletions integration-tests/integration/seedData.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ const expectedPayload = {
evidence: {
cctvRecording: 'NOT_KNOWN',
baggedEvidence: true,
bodyWornCamera: 'YES',
photographsTaken: true,
bodyWornCameraNumbers: [{ cameraNum: '123' }, { cameraNum: '789' }, { cameraNum: '456' }],
evidenceTagAndDescription: [
{ description: 'This evidence was collected from the prisoner 1', evidenceTagReference: 'Bagged evidence 1' },
{ description: 'This evidence was collected from the prisoner 2', evidenceTagReference: 'Bagged evidence 2' },
Expand All @@ -25,6 +23,8 @@ const expectedPayload = {
reasons: ['FIGHT_BETWEEN_PRISONERS'],
},
useOfForceDetails: {
bodyWornCamera: 'YES',
bodyWornCameraNumbers: [{ cameraNum: '123' }, { cameraNum: '789' }, { cameraNum: '456' }],
pavaUsed: true,
batonUsed: true,
pavaDrawn: true,
Expand Down
9 changes: 0 additions & 9 deletions integration-tests/pages/createReport/evidencePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,6 @@ const evidencePage = () =>
cy.get('[name="evidenceTagAndDescription[2][description]"]').type('Clothes samples')
this.photosTaken().check('true')
cy.get('[name="cctvRecording"]').check('NOT_KNOWN')
cy.get('[name="bodyWornCamera"]').check('YES')
cy.get('[name="bodyWornCameraNumbers[0][cameraNum]"]').type('123')
cy.get('[data-qa-add-another-camera = true]').click()
cy.get('[name="bodyWornCameraNumbers[1][cameraNum]"]').type('456')
cy.get('[data-qa-add-another-camera = true]').click()
cy.get('[name="bodyWornCameraNumbers[2][cameraNum]"]').type('789')
cy.get('.add-another-camera .add-another__remove-button').eq(1).click()
cy.get('[data-qa-add-another-camera = true]').click()
cy.get('[name="bodyWornCameraNumbers[2][cameraNum]"]').type('456')
},

save: () => {
Expand Down
7 changes: 7 additions & 0 deletions integration-tests/pages/createReport/useOfForceDetailsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ import RelocationAndInjuriesPage from './relocationAndInjuriesPage'
const useOfForceDetailsPage = () =>
page('Use of force details', {
positiveCommunication: () => cy.get('[name="positiveCommunication"]'),

bodyWornCamera: () => cy.get('[name="bodyWornCamera"]'),
bodyWornCameraNumber: index => cy.get(`[name="bodyWornCameraNumbers[${index}][cameraNum]"]`),
addAnotherBodyWornCamera: () => cy.get('[data-qa-add-another-input = true]').click(),
removeBodyWornCamera: index => cy.get('.add-another-input .add-another__remove-button').eq(index).click(),

personalProtectionTechniques: () => cy.get('[name="personalProtectionTechniques"]'),
batonDrawn: () => cy.get('[name="batonDrawn"]'),
batonUsed: () => cy.get('[name="batonUsed"]'),
Expand Down Expand Up @@ -45,6 +51,7 @@ const useOfForceDetailsPage = () =>

fillForm() {
this.positiveCommunication().check('true')
this.bodyWornCamera().check('NO')
this.personalProtectionTechniques().check('true')
this.batonDrawn().check('true')
this.batonUsed().check('true')
Expand Down
21 changes: 0 additions & 21 deletions server/config/forms/evidenceForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,6 @@ const completeSchema = joi.object({
'NO',
'NOT_KNOWN'
)('Select yes if any part of the incident captured on CCTV').alter(optionalForPartialValidation),

bodyWornCamera: requiredOneOfMsg(
'YES',
'NO',
'NOT_KNOWN'
)('Select yes if any part of the incident was captured on a body-worn camera').alter(optionalForPartialValidation),
bodyWornCameraNumbers: joi
.when('bodyWornCamera', {
is: 'YES',
then: arrayOfObjects({
cameraNum: requiredStringMsg('Enter the body-worn camera number').alter(optionalForPartialValidation),
})
.min(1)
.message('Enter the body-worn camera number')
.ruleset.unique('cameraNum')
.message("Camera '{#value.cameraNum}' has already been added - remove this camera")
.required()
.alter(minZeroForPartialValidation),
otherwise: joi.any().strip(),
})
.meta({ firstFieldName: 'bodyWornCameraNumbers[0]' }),
})

module.exports = {
Expand Down
Loading

0 comments on commit 4326a93

Please sign in to comment.