From 56a0d2acc4171dd0f3f484910bccf9f68ab3f293 Mon Sep 17 00:00:00 2001
From: GCheema <50441412+GurnankCheema@users.noreply.github.com>
Date: Mon, 29 Jan 2024 17:00:11 +0000
Subject: [PATCH] 1. made weapons observed non-unique 2. reinstated Not Known
 for body-worn cameras 3. fixed label and input associations for
 checkboxesWithNestedCheckboxes macro as it was cauing label on one question
 to trigger input on another

---
 .../reportPages/enter-use-of-force-details.cy.js       |  8 --------
 server/config/forms/useOfForceDetailsForm.js           |  5 ++---
 .../config/forms/useOfForceDetailsValidation.test.js   | 10 ----------
 server/config/types.test.ts                            |  2 +-
 server/config/types.ts                                 |  1 +
 5 files changed, 4 insertions(+), 22 deletions(-)

diff --git a/integration-tests/integration/reportPages/enter-use-of-force-details.cy.js b/integration-tests/integration/reportPages/enter-use-of-force-details.cy.js
index b6c30550..3b117c5f 100644
--- a/integration-tests/integration/reportPages/enter-use-of-force-details.cy.js
+++ b/integration-tests/integration/reportPages/enter-use-of-force-details.cy.js
@@ -186,15 +186,7 @@ context('Enter use of force details page', () => {
     useOfForceDetailsPage.bodyWornCameraNumber(0).type('1')
     useOfForceDetailsPage.addAnotherBodyWornCamera()
     useOfForceDetailsPage.bodyWornCameraNumber(1).type('1')
-
-    useOfForceDetailsPage.weaponsObserved().check('YES')
-    useOfForceDetailsPage.weaponTypes(0).type('gun')
-    useOfForceDetailsPage.addAnotherWeapon()
-    useOfForceDetailsPage.weaponTypes(1).type('gun')
-
     useOfForceDetailsPage.clickSaveAndContinue()
-
     useOfForceDetailsPage.errorSummary().contains("Camera '1' has already been added - remove this camera")
-    useOfForceDetailsPage.errorSummary().contains("Weapon 'gun' has already been added - remove this weapon")
   })
 })
diff --git a/server/config/forms/useOfForceDetailsForm.js b/server/config/forms/useOfForceDetailsForm.js
index bf439444..56ca7b14 100644
--- a/server/config/forms/useOfForceDetailsForm.js
+++ b/server/config/forms/useOfForceDetailsForm.js
@@ -19,7 +19,8 @@ const completeSchema = joi.object({
 
   bodyWornCamera: requiredOneOfMsg(
     'YES',
-    'NO'
+    'NO',
+    'NOT_KNOWN'
   )('Select yes if any part of the incident was captured on a body-worn camera').alter(optionalForPartialValidation),
 
   bodyWornCameraNumbers: joi
@@ -65,8 +66,6 @@ const completeSchema = joi.object({
       })
         .min(1)
         .message('Enter the type of weapon observed')
-        .ruleset.unique('weaponType')
-        .message("Weapon '{#value.weaponType}' has already been added - remove this weapon")
         .required()
         .alter(minZeroForPartialValidation),
       otherwise: joi.any().strip(),
diff --git a/server/config/forms/useOfForceDetailsValidation.test.js b/server/config/forms/useOfForceDetailsValidation.test.js
index 483f92a5..9a0a4cf9 100644
--- a/server/config/forms/useOfForceDetailsValidation.test.js
+++ b/server/config/forms/useOfForceDetailsValidation.test.js
@@ -360,16 +360,6 @@ describe('complete schema', () => {
       expect(errors).toEqual([{ href: '#weaponTypes[0]', text: '"weaponTypes" is required' }])
     })
 
-    it('Should return validation error if more than one weapon with same identifier', () => {
-      validInput.weaponsObserved = 'YES'
-      validInput.weaponTypes = [{ weaponType: 'Gun' }, { weaponType: 'Gun' }]
-      const { errors } = check(validInput)
-
-      expect(errors).toEqual([
-        { href: '#weaponTypes[1]', text: "Weapon 'Gun' has already been added - remove this weapon" },
-      ])
-    })
-
     it('Should not return validation error if all weapon observed identifiers are unique', () => {
       validInput.weaponsObserved = 'YES'
       validInput.weaponTypes = [{ weaponType: 'Gun' }, { weaponType: 'Knife' }]
diff --git a/server/config/types.test.ts b/server/config/types.test.ts
index a1e4544f..e97ddadb 100644
--- a/server/config/types.test.ts
+++ b/server/config/types.test.ts
@@ -2,7 +2,7 @@ import { BodyWornCameras, toLabel } from './types'
 
 describe('toLabel', () => {
   test('Found', () => {
-    return expect(toLabel(BodyWornCameras, 'YES')).toEqual('Yes')
+    return expect(toLabel(BodyWornCameras, 'NOT_KNOWN')).toEqual('Not Known')
   })
   test('Passed undefined', () => {
     return expect(toLabel(BodyWornCameras, undefined)).toEqual(undefined)
diff --git a/server/config/types.ts b/server/config/types.ts
index 263d4728..0980a3a3 100644
--- a/server/config/types.ts
+++ b/server/config/types.ts
@@ -24,6 +24,7 @@ export const findEnum = <K extends string>(type: LabelledEnum<K>, val: string):
 export const BodyWornCameras = toEnum({
   YES: { value: 'YES', label: 'Yes' },
   NO: { value: 'NO', label: 'No' },
+  NOT_KNOWN: { value: 'NOT_KNOWN', label: 'Not Known' },
 })
 
 export const WeaponsObserved = toEnum({