Skip to content

Commit

Permalink
ADJST-984 Allow adjustments for released prisoners. (#857)
Browse files Browse the repository at this point in the history
* ADJST-984 Allow adjustments for released prisoners.

* ADJST-984 Only show recalls in dev.
  • Loading branch information
ldlharper authored Jan 10, 2025
1 parent e075381 commit 648434d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 89 deletions.
81 changes: 0 additions & 81 deletions server/routes/startRoutes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,85 +408,4 @@ describe('Start routes tests', () => {
expect(res.text).toContain('href="/calculation/ASD123/check-information?hasErrors=true')
})
})

describe('sub-nav tests in relation to prisoner being OUT or TRN', () => {
it('Do not show adjustments sub-nav link if prisoner is OUT', () => {
userPermissionsService.allowBulkLoad.mockReturnValue(true)
calculateReleaseDatesService.getCalculationHistory.mockResolvedValue(calculationHistory)
const cardAndAction = {
latestCalcCard: latestCalcCardForPrisoner,
latestCalcCardAction: latestCalcCardActionForPrisoner,
}
calculateReleaseDatesService.getLatestCalculationCardForPrisoner.mockResolvedValue(cardAndAction)
prisonerService.getPrisonerDetail.mockResolvedValue({ ...stubbedPrisonerData, agencyId: 'OUT' })

return request(app)
.get('?prisonId=123')
.expect(200)
.expect(res => {
const $ = cheerio.load(res.text)
const text = $('[data-qa=personOutsideBanner]').text().replace(/\s\s+/g, ' ').trim() // Remove space
expect(text).toBe('This person has been released Some information may be hidden')
const links = $('.moj-sub-navigation__link')
.filter((index, element) => $(element).attr('href').length > 0) // filter hidden links
.map((i, element) => {
return $(element).text()
})
.get()
expect(links).toStrictEqual(['Overview', 'Release dates and calculations'])
})
})

it('Do not show adjustments sub-nav link if prisoner is TRN', () => {
userPermissionsService.allowBulkLoad.mockReturnValue(true)
calculateReleaseDatesService.getCalculationHistory.mockResolvedValue(calculationHistory)
const cardAndAction = {
latestCalcCard: latestCalcCardForPrisoner,
latestCalcCardAction: latestCalcCardActionForPrisoner,
}
calculateReleaseDatesService.getLatestCalculationCardForPrisoner.mockResolvedValue(cardAndAction)
prisonerService.getPrisonerDetail.mockResolvedValue({ ...stubbedPrisonerData, agencyId: 'TRN' })

return request(app)
.get('?prisonId=123')
.expect(200)
.expect(res => {
const $ = cheerio.load(res.text)
const text = $('[data-qa=personTransferredBanner]').text().replace(/\s\s+/g, ' ').trim() // Remove space
expect(text).toBe('This person has been transferred Some information may be hidden')
const links = $('.moj-sub-navigation__link')
.filter((index, element) => $(element).attr('href').length > 0) // filter hidden links
.map((i, element) => {
return $(element).text()
})
.get()
expect(links).toStrictEqual(['Overview', 'Release dates and calculations'])
})
})

it('Do show adjustments sub-nav link if prisoner neither OUT or TRN', () => {
userPermissionsService.allowBulkLoad.mockReturnValue(true)
calculateReleaseDatesService.getCalculationHistory.mockResolvedValue(calculationHistory)
const cardAndAction = {
latestCalcCard: latestCalcCardForPrisoner,
latestCalcCardAction: latestCalcCardActionForPrisoner,
}
calculateReleaseDatesService.getLatestCalculationCardForPrisoner.mockResolvedValue(cardAndAction)
prisonerService.getPrisonerDetail.mockResolvedValue({ ...stubbedPrisonerData, agencyId: 'MDI' })

return request(app)
.get('?prisonId=123')
.expect(200)
.expect(res => {
const $ = cheerio.load(res.text)
const links = $('.moj-sub-navigation__link')
.filter((index, element) => $(element).attr('href').length > 0) // filter hidden links
.map((i, element) => {
return $(element).text()
})
.get()
expect(links).toStrictEqual(['Overview', 'Adjustments', 'Release dates and calculations'])
})
})
})
})
10 changes: 2 additions & 8 deletions server/views/pages/ccardIndex.njk
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,9 @@
{% set pageTitle = applicationName + " - Home" %}
{% set pageId = "ccard-index" %}

{% if commonElementConfig.establishmentCode == 'OUT' or commonElementConfig.establishmentCode == 'TRN' %}
{% set enableAdjustments = false %}
{% else %}
{% set enableAdjustments = true %}
{% endif %}

{% set navigation = {
activeSubNav: 'release-dates',
adjustments: { enabled: enableAdjustments },
activeSubNav: 'release-dates',
recalls: { enabled: commonElementConfig.environment == 'dev' },
documents: { enabled: false },
courtCases: { enabled: false },
recalls: { enabled: false }
Expand Down

0 comments on commit 648434d

Please sign in to comment.