Skip to content

Commit

Permalink
HDCED text update (#717)
Browse files Browse the repository at this point in the history
* HDCED text update

* Commit missed files
  • Loading branch information
FaizJD030 authored May 31, 2024
1 parent cec8103 commit 49a8305
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 3 deletions.
9 changes: 8 additions & 1 deletion server/models/PrintNotificationSlipViewModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,23 @@ import PrisonerContextViewModel from './PrisonerContextViewModel'
import ViewRouteSentenceAndOffenceViewModel from './ViewRouteSentenceAndOffenceViewModel'

export default class PrintNotificationSlipViewModel extends PrisonerContextViewModel {
public hasHDCED: boolean

constructor(
public model: ViewRouteSentenceAndOffenceViewModel,
public calculationRequestId: number,
public nomsId: string,
public calculationDate: string,
public keyDatesArray: { date: string; description: string }[],
public keyDatesArray: { code: string; date: string; description: string }[],
public fromPage: string,
public pageType: string,
public calculationReason: string,
) {
super(model.prisonerDetail)
this.hasHDCED = this.hasHDCEDInReleaseDates()
}

hasHDCEDInReleaseDates(): boolean {
return this.keyDatesArray.some(keyDate => keyDate.code === 'HDCED')
}
}
56 changes: 56 additions & 0 deletions server/routes/viewRoutes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1221,6 +1221,7 @@ describe('View journey routes tests', () => {
const offenderSlipLink = $('[data-qa="slip-offender-copy"]').first()
const establishmentSlipLink = $('[data-qa="slip-establishment-copy"]').first()
const daysInUnusedRemandOrTaggedBail = $('[data-qa=days-in-unusedRemand-taggedBail]').first()
const offenderHDCED = $('[data-qa="offender-hdced-text"]').first()

expect(offenderSlipLink.attr('href')).toStrictEqual(
'/view/A1234AA/calculation-summary/123456/printNotificationSlip?fromPage=view&pageType=offender',
Expand Down Expand Up @@ -1272,6 +1273,7 @@ describe('View journey routes tests', () => {
expect(remandTo.text()).toContain('02 February 2021')
expect(remandDays.text()).toContain('2 days deducted')
expect(daysInUnusedRemandOrTaggedBail.length).toStrictEqual(0)
expect(offenderHDCED.length).toStrictEqual(0)
expect(appealCustody.text()).toContain(
'Days spent in custody pending appeal to count (must be completed manually):',
)
Expand Down Expand Up @@ -1299,13 +1301,17 @@ describe('View journey routes tests', () => {
const calcReasonTitle = $('[data-qa="calculation-reason-title"]')
const calcReason = $('[data-qa="calculation-reason"]')
const printInvoker = $('[data-qa="print-invoker"]').first()
const offenderHDCED = $('[data-qa="offender-hdced-text"]').first()

expect(printInvoker.attr('src')).toStrictEqual('/assets/print.js')
expect(calculatedBy.length).toStrictEqual(0)
expect(calcReasonTitle.length).toStrictEqual(0)
expect(calcReason.length).toStrictEqual(0)
expect(checkedBy.length).toStrictEqual(0)
expect(pageTitleCaption.text()).toStrictEqual('[Offender copy]')
expect(offenderHDCED.text()).toStrictEqual(
'Release on HDC (Home Detention Curfew) is subject to an assessment.',
)
expect(offenderDisagreeText.text()).toStrictEqual(
'If you disagree with the above dates, please write down what you think the dates should be and hand to your wing office.',
)
Expand All @@ -1330,6 +1336,7 @@ describe('View journey routes tests', () => {
const calcReasonTitle = $('[data-qa="calculation-reason-title"]').first()
const calcReason = $('[data-qa="calculation-reason"]').first()
const printInvoker = $('[data-qa="print-invoker"]').first()
const offenderHDCED = $('[data-qa="offender-hdced-text"]').first()

expect(printInvoker.attr('src')).toStrictEqual('/assets/print.js')
expect(calculatedBy.text()).toStrictEqual('Calculated by:')
Expand All @@ -1338,6 +1345,7 @@ describe('View journey routes tests', () => {
expect(checkedBy.text()).toStrictEqual('Checked by:')
expect(pageTitleCaption.text()).toStrictEqual('[Establishment copy]')
expect(offenderDisagreeText.length).toStrictEqual(0)
expect(offenderHDCED.length).toStrictEqual(0)
})
})

Expand Down Expand Up @@ -1366,6 +1374,54 @@ describe('View journey routes tests', () => {
})
})

it('GET /calculation/:nomsId/summary/:calculationRequestId/printNotificationSlip?fromPage=view&pageType=offender should generate page without HDCED text', () => {
const stubbedReleaseDatesWithoutHDCED: ReleaseDatesAndCalculationContext = {
calculation: {
calculationRequestId: 51245,
bookingId: 1201571,
prisonerId: 'A8031DY',
calculationStatus: 'CONFIRMED',
calculationReference: 'fe1909af-c780-4b61-9ca3-a82678de5dca',
calculationReason: {
id: 8,
isOther: false,
displayName: 'A calculation reason',
},
otherReasonDescription: '',
calculationDate: '2020-06-01',
calculationType: 'CALCULATED',
},
dates: [
{
type: 'SED',
description: 'Sentence expiry date',
date: '2021-02-03',
hints: [],
},
{
type: 'CRD',
description: 'Conditional release date',
date: '2021-02-03',
hints: [],
},
],
}
viewReleaseDatesService.getPrisonerDetail.mockResolvedValue(stubbedPrisonerData)
viewReleaseDatesService.getSentencesAndOffences.mockResolvedValue(stubbedSentencesAndOffences)
viewReleaseDatesService.getBookingAndSentenceAdjustments.mockResolvedValue(stubbedAdjustments)
calculateReleaseDatesService.getReleaseDatesForACalcReqId.mockResolvedValue(stubbedReleaseDatesWithoutHDCED)
return request(app)
.get('/calculation/A1234AA/summary/123456/printNotificationSlip?fromPage=view&pageType=offender')
.expect(200)
.expect('Content-Type', /html/)
.expect(res => {
const $ = cheerio.load(res.text)
const offenderHDCED = $('[data-qa="offender-hdced-text"]').first()

expect(offenderHDCED.length).toStrictEqual(0)
})
})

it('GET /calculation/:nomsId/summary/:calculationRequestId/printNotificationSlip?fromPage=calculation should generate correct unused remand', () => {
const stubbedAdjustmentsTB = {
sentenceAdjustments: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
<div class="print-width-container">
<div class="moj-width-container govuk-!-margin-bottom-4 govuk-!-display-none-print">
{% if fromPage == 'calculation' %}
<a data-qa="back-link" href="/calculation/{{ model.prisonerDetail.offenderNo }}/complete/{{ calculationRequestId }}">Back</a>
<a data-qa="back-link" class="govuk-back-link" href="/calculation/{{ model.prisonerDetail.offenderNo }}/complete/{{ calculationRequestId }}">Back</a>
{% elif fromPage == 'view' %}
<a data-qa="back-link" href="/?prisonId={{ model.prisonerDetail.offenderNo }}">Back</a>
<a data-qa="back-link" class="govuk-back-link" href="/?prisonId={{ model.prisonerDetail.offenderNo }}">Back</a>
{% endif %}
</div>

Expand Down Expand Up @@ -114,6 +114,9 @@
<p class="govuk-body govuk-!-margin-bottom-4" data-qa="appeal-bail">Days spent on bail pending appeal not to count <b>(must be completed manually)</b>:</p>
{% if pageType == 'offender' %}
<p data-qa="offender-disagree-text" class="govuk-body">If you disagree with the above dates, please write down what you think the dates should be and hand to your wing office.</p>
{% if hasHDCED %}
<p data-qa="offender-hdced-text" class="govuk-body">Release on HDC (Home Detention Curfew) is subject to an assessment.</p>
{% endif %}
{% endif %}
{% if pageType == 'establishment' %}
<p data-qa="calculated-by" class="govuk-body govuk-!-margin-bottom-2">Calculated by:</p>
Expand Down

0 comments on commit 49a8305

Please sign in to comment.