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.
* PI-2054: Added compliance
- Loading branch information
Showing
19 changed files
with
833 additions
and
24 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
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import Page from '../pages/page' | ||
import CompliancePage from '../pages/compliance' | ||
|
||
context('Compliance', () => { | ||
it('Compliance page is rendered', () => { | ||
cy.visit('/case/X000001/compliance') | ||
const page = Page.verifyOnPage(CompliancePage) | ||
page.getCardHeader('sentence1').should('contain.text', 'Sentence (3)') | ||
page | ||
.getRowData('sentence1', 'mainOffenceDescription', 'Value') | ||
.should('contain.text', 'Having possession a picklock') | ||
page.getRowData('sentence1', 'orderDescription', 'Value').should('contain.text', 'ORA Community Order') | ||
page.getRowData('sentence1', 'startDate', 'Value').should('contain.text', '2 March 2020') | ||
page.getRowData('sentence1', 'breach', 'Value').should('contain.text', 'A breach is in progress') | ||
|
||
page.getCardHeader('breach1').should('contain.text', 'Breach details') | ||
page.getRowData('breach1', 'startDate', 'Value').should('contain.text', '2 March 2020') | ||
page.getRowData('breach1', 'status', 'Value').should('contain.text', 'An active breach status') | ||
|
||
page.getCardHeader('activity1').should('contain.text', '10 days RAR, 9 completed') | ||
page.getRowData('activity1', 'appointments', 'Value').should('contain.text', '1 national standard appointments') | ||
page.getRowData('activity1', 'withoutOutcome', 'Value').should('contain.text', '3 without a recorded outcome') | ||
|
||
page.getRowData('activity1', 'waitingForEvidence', 'Value').should('contain.text', '1 absence waiting for evidence') | ||
page.getRowData('activity1', 'complied', 'Value').should('contain.text', '2 complied') | ||
page.getRowData('activity1', 'failureToComply', 'Value').should('contain.text', '2 failures to comply') | ||
|
||
page.getRowData('activity1', 'warningLetter', 'Value').should('contain.text', 'First warning letter sent') | ||
page.getRowData('activity1', 'acceptableAbsences', 'Value').should('contain.text', '1 acceptable absences') | ||
page.getRowData('activity1', 'rescheduled', 'Value').should('contain.text', '1 rescheduled') | ||
|
||
page.getCardHeader('sentence2').should('contain.text', 'Sentence (1)') | ||
page | ||
.getRowData('sentence2', 'mainOffenceDescription', 'Value') | ||
.should('contain.text', 'Another main offence - 18502') | ||
page.getRowData('sentence2', 'orderDescription', 'Value').should('contain.text', 'ORA Community Order') | ||
page.getRowData('sentence2', 'startDate', 'Value').should('contain.text', '2 March 2020') | ||
page.getRowData('sentence2', 'breach', 'Value').should('contain.text', 'No breaches on current order') | ||
|
||
page.getCardHeader('previousOrder1').should('contain.text', '12 month Community Order') | ||
page | ||
.getRowData('previousOrder1', 'mainOffenceDescription', 'Value') | ||
.should('contain.text', 'Common Assault and Battery') | ||
page | ||
.getRowData('previousOrder1', 'status', 'Value') | ||
.should('contain.text', 'Completed - Sentence/ PSS Expiry Reached') | ||
page.getRowData('previousOrder1', 'startDate', 'Value').should('contain.text', '12 December 1990') | ||
page.getRowData('previousOrder1', 'endDate', 'Value').should('contain.text', '12 December 1991') | ||
page.getRowData('previousOrder1', 'breaches', 'Value').should('contain.text', '2') | ||
}) | ||
}) |
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
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import Page from './page' | ||
|
||
export default class CompliancePage extends Page { | ||
constructor() { | ||
super('Compliance') | ||
} | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { PersonSummary } from './common' | ||
import { ActivityCount, Compliance, Offence, Order, PreviousOrders, Rar } from './overview' | ||
|
||
export interface PersonCompliance { | ||
personSummary: PersonSummary | ||
previousOrders: PreviousOrders | ||
currentSentences: SentenceCompliance[] | ||
} | ||
|
||
export interface SentenceCompliance { | ||
activity: ActivityCount | ||
compliance: Compliance | ||
mainOffence: Offence | ||
order: Order | ||
activeBreach?: Breach | ||
rar?: Rar | ||
} | ||
|
||
export interface Breach { | ||
startDate: string | ||
status: string | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { type RequestHandler, Router } from 'express' | ||
import { auditService } from '@ministryofjustice/hmpps-audit-client' | ||
import { v4 } from 'uuid' | ||
import asyncMiddleware from '../middleware/asyncMiddleware' | ||
import type { Services } from '../services' | ||
import MasApiClient from '../data/masApiClient' | ||
|
||
export default function complianceRoutes(router: Router, { hmppsAuthClient }: Services) { | ||
const get = (path: string | string[], handler: RequestHandler) => router.get(path, asyncMiddleware(handler)) | ||
|
||
get('/case/:crn/compliance', async (req, res, _next) => { | ||
const { crn } = req.params | ||
const token = await hmppsAuthClient.getSystemClientToken(res.locals.user.username) | ||
|
||
await auditService.sendAuditMessage({ | ||
action: 'VIEW_MAS_COMPLIANCE', | ||
who: res.locals.user.username, | ||
subjectId: crn, | ||
subjectType: 'CRN', | ||
correlationId: v4(), | ||
service: 'hmpps-manage-a-supervision-ui', | ||
}) | ||
|
||
const masClient = new MasApiClient(token) | ||
|
||
const personCompliance = await masClient.getPersonCompliance(crn) | ||
res.render('pages/compliance', { | ||
personCompliance, | ||
crn, | ||
}) | ||
}) | ||
} |
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
{% extends "../partials/case.njk" %} | ||
{% from "govuk/components/notification-banner/macro.njk" import govukNotificationBanner %} | ||
{% set pageTitle = applicationName + " - Compliance" %} | ||
{% set currentSectionName = 'Compliance' %} | ||
{% set title = 'Compliance' %} | ||
{% set currentNavSection = 'compliance' %} | ||
{% set headerPersonName = personCompliance.personSummary.name | fullName %} | ||
{% set headerCRN = personCompliance.personSummary.crn %} | ||
{% block pageTitle %}{{ title }}{% endblock %} | ||
|
||
{% block beforeContent %} | ||
{{ govukBreadcrumbs({ | ||
items: [ | ||
{ | ||
text: "Your cases", | ||
href: "/search" | ||
}, | ||
{ | ||
text: headerPersonName, | ||
href: "/case/" + crn | ||
}, | ||
{ | ||
text: currentSectionName | ||
} | ||
] | ||
}) }} | ||
{% endblock %} | ||
|
||
{% block pageContent %} | ||
|
||
{% set showWarning = false %} | ||
{% for sentence in personCompliance.currentSentences %} | ||
{% if sentence.compliance.currentBreaches > 0 %} | ||
{% set showWarning = true %} | ||
{% endif %} | ||
{% endfor %} | ||
|
||
{% if showWarning === true %} | ||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds"> | ||
{{ govukWarningText({ | ||
html: 'There are multiple breach NSIs in progress on Delius.<br />Use Delius to check and correct any problems.<div class="govuk-!-margin-top-1"><a href="/case/' + crn + '/handoff/delius">Go to Delius</a></div>', | ||
iconFallbackText: 'Warning' | ||
}) }} | ||
</div> | ||
</div> | ||
{% endif %} | ||
|
||
<p class="govuk-!-margin-bottom-6"> | ||
<a href="/case/{{ crn }}/handoff/delius">Use Delius to start a breach</a> | ||
</p> | ||
|
||
{% include './compliance/_compliance-current-order.njk' %} | ||
{% include './compliance/_compliance-previous-orders.njk' %} | ||
|
||
|
||
{% endblock %} |
Oops, something went wrong.