generated from ministryofjustice/hmpps-template-typescript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Delete orphaned CPP details and current offence data
If a user answers yes to the community supervision question and fills in subsequent screens, the data will persist even after coming back to change the answer to 'no' and will show on the check your answers screen and be submitted with the application. This change ensures we remove that data when the answer is 'no.
- Loading branch information
Daniel Liburd
committed
Jan 8, 2025
1 parent
6efb7f7
commit 774ab28
Showing
2 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -212,4 +212,57 @@ describe('deleteOrphanedFollowOnAnswers', () => { | |
}) | ||
}) | ||
}) | ||
describe('cpp-details and current offences', () => { | ||
describe('when probation supervision is set to no', () => { | ||
const applicationData = { | ||
'community-supervision-and-current-offences': { | ||
'community-supervision': { | ||
probationSupervision: 'no', | ||
}, | ||
'cpp-details': { | ||
cppDetails: { | ||
name: 'A. CPP', | ||
probationRegion: 'some region', | ||
email: '[email protected]', | ||
telephone: '012345', | ||
}, | ||
}, | ||
'current-offence-data': [ | ||
{ | ||
titleAndNumber: 'Arson', | ||
offenceCategory: 'Arson', | ||
'offenceDate-day': '5', | ||
'offenceDate-month': '6', | ||
'offenceDate-year': '1940', | ||
sentenceLength: '3 years', | ||
summary: 'summary detail', | ||
outstandingCharges: 'yes', | ||
outstandingChargesDetail: 'outstanding charges detail', | ||
}, | ||
{ | ||
titleAndNumber: 'Stalking', | ||
offenceCategory: 'Stalking', | ||
'offenceDate-day': '6', | ||
'offenceDate-month': '7', | ||
'offenceDate-year': '2023', | ||
sentenceLength: '2 months', | ||
summary: 'more summary detail', | ||
outstandingCharges: 'no', | ||
}, | ||
], | ||
'current-offences': {}, | ||
}, | ||
} | ||
|
||
it('removes cpp details and current offence data', () => { | ||
expect(deleteOrphanedFollowOnAnswers(applicationData)).toEqual({ | ||
'community-supervision-and-current-offences': { | ||
'community-supervision': { | ||
probationSupervision: 'no', | ||
}, | ||
}, | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters