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.
Man 309 links to previous orders (#294)
* MAN-309 - add new page * MAN-309 - add card elements * MAN-309 - add new e2e test * MAN-309 - update e2e test * MAN-309 - update route url
- Loading branch information
1 parent
fc89ba4
commit ebfc76e
Showing
16 changed files
with
490 additions
and
7 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
61 changes: 61 additions & 0 deletions
61
integration_tests/e2e/sentence/previous-orders/previous-order.cy.ts
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,61 @@ | ||
import Page from '../../../pages' | ||
import PreviousOrderPage from '../../../pages/sentence/previous-orders/previous-order' | ||
|
||
context('Sentence', () => { | ||
it('Previous order page is rendered', () => { | ||
cy.visit('/case/X000001/sentence/previous-orders/3') | ||
|
||
const page = Page.verifyOnPage(PreviousOrderPage) | ||
const breadCrumbElement = '.govuk-breadcrumbs__list-item' | ||
|
||
page.assertTextElementAtIndex('h2', 0, 'Previous orders') | ||
|
||
page.assertAnchorElementAtIndex(breadCrumbElement, 0, '/case') | ||
page.assertTextAtAnchorElementAtIndex(breadCrumbElement, 0, 'My cases') | ||
|
||
page.assertAnchorElementAtIndex(breadCrumbElement, 1, '/case/X000001') | ||
page.assertTextAtAnchorElementAtIndex(breadCrumbElement, 1, 'Caroline Wolff') | ||
|
||
page.assertAnchorElementAtIndex(breadCrumbElement, 2, '/case/X000001/sentence') | ||
page.assertTextAtAnchorElementAtIndex(breadCrumbElement, 2, 'Sentence') | ||
|
||
page.assertAnchorElementAtIndex(breadCrumbElement, 3, '/case/X000001/sentence/previous-orders') | ||
page.assertTextAtAnchorElementAtIndex(breadCrumbElement, 3, 'Previous orders') | ||
|
||
page.assertTextElementAtIndex('h2', 1, 'CJA - Std Determinate Custody (16 Months)') | ||
|
||
page.assertPageElementAtIndexWithin('section', 0, 'h2', 0, 'Offence') | ||
page.assertPageElementAtIndexWithin('section', 0, 'dt', 0, 'Main offence') | ||
page.assertPageElementAtIndexWithin('section', 0, 'dt', 1, 'Offence date') | ||
page.assertPageElementAtIndexWithin('section', 0, 'dt', 2, 'Notes') | ||
page.assertPageElementAtIndexWithin('section', 0, 'dt', 3, 'Additional offences') | ||
page.assertPageElementAtIndexWithin('section', 0, 'dd', 0, 'Speeding (1 count)') | ||
page.assertPageElementAtIndexWithin('section', 0, 'dd', 1, '20 January 2024') | ||
page.assertPageElementAtIndexWithin('section', 0, 'dd', 2, 'My note') | ||
page.assertPageElementAtIndexWithin('section', 0, 'dd', 3, 'Burglary (2 count)') | ||
|
||
page.assertPageElementAtIndexWithin('section', 1, 'h2', 0, 'Conviction') | ||
page.assertPageElementAtIndexWithin('section', 1, 'dt', 0, 'Sentencing court') | ||
page.assertPageElementAtIndexWithin('section', 1, 'dt', 1, 'Responsible court') | ||
page.assertPageElementAtIndexWithin('section', 1, 'dt', 2, 'Conviction date') | ||
page.assertPageElementAtIndexWithin('section', 1, 'dt', 3, 'Additional sentences') | ||
page.assertPageElementAtIndexWithin('section', 1, 'dd', 0, 'Hull Court') | ||
page.assertPageElementAtIndexWithin('section', 1, 'dd', 1, 'Birmingham Court') | ||
page.assertPageElementAtIndexWithin('section', 1, 'dd', 2, '20 March 2024') | ||
page.assertPageElementAtIndexWithin('section', 1, 'dd', 3, 'Disqualified from Driving') | ||
|
||
page.assertPageElementAtIndexWithin('section', 2, 'h2', 0, 'Sentence') | ||
page.assertPageElementAtIndexWithin('section', 2, 'dt', 0, 'Order') | ||
page.assertPageElementAtIndexWithin('section', 2, 'dt', 1, 'Sentence start date') | ||
page.assertPageElementAtIndexWithin('section', 2, 'dt', 2, 'Sentence end date') | ||
page.assertPageElementAtIndexWithin('section', 2, 'dt', 3, 'Terminated date') | ||
page.assertPageElementAtIndexWithin('section', 2, 'dt', 4, 'Termination reason') | ||
page.assertPageElementAtIndexWithin('section', 2, 'dt', 5, 'Court documents') | ||
page.assertPageElementAtIndexWithin('section', 2, 'dd', 0, '12 month community order') | ||
page.assertPageElementAtIndexWithin('section', 2, 'dd', 1, '1 February 2024') | ||
page.assertPageElementAtIndexWithin('section', 2, 'dd', 2, '1 November 2024') | ||
page.assertPageElementAtIndexWithin('section', 2, 'dd', 3, '31 January 2025') | ||
page.assertPageElementAtIndexWithin('section', 2, 'dd', 4, '11 months elapsed (of 12 months)') | ||
page.assertPageElementAtIndexWithin('section', 2, 'dd', 5, 'Pre-sentence report') | ||
}) | ||
}) |
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
7 changes: 7 additions & 0 deletions
7
integration_tests/pages/sentence/previous-orders/previous-order.ts
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 PreviousOrderPage extends Page { | ||
constructor() { | ||
super('Previous orders') | ||
} | ||
} |
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,8 @@ | ||
import { Name } from './common' | ||
import { Sentence } from './sentenceDetails' | ||
|
||
export interface PreviousOrderDetail { | ||
name: Name | ||
title: string | ||
sentence: Sentence | ||
} |
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,62 @@ | ||
{% set hasAdditionalSentences = sentence.conviction.additionalSentences and sentence.conviction.additionalSentences.length > 0 %} | ||
{% set additionalSentences %} | ||
{% for additionalSentence in sentence.conviction.additionalSentences %} | ||
{% set detailsHtml %} | ||
{{ govukSummaryList({ | ||
rows: [ | ||
{ | ||
key: { text: 'Sentence' }, | ||
value: { text: additionalSentence.description } | ||
}, | ||
{ | ||
key: { text: 'Value' }, | ||
value: { text: additionalSentence.value } | ||
} if additionalSentence.value, | ||
{ | ||
key: { text: 'Length' }, | ||
value: { text: additionalSentence.length } | ||
} if additionalSentence.length, | ||
{ | ||
key: { text: 'Notes' }, | ||
value: { html: additionalSentence.notes | nl2br if additionalSentence.notes else 'No notes' } | ||
} | ||
] | ||
}) }} | ||
{% endset %} | ||
{{ govukDetails({ | ||
classes: 'govuk-!-margin-bottom-1', | ||
summaryText: additionalSentence.description, | ||
html: detailsHtml | ||
}) }} | ||
{% endfor %} | ||
{% endset %} | ||
|
||
{% set conviction %} | ||
{{ govukSummaryList({ | ||
rows: [ | ||
{ | ||
key: { text: "Sentencing court" }, | ||
value: { html: sentence.conviction.sentencingCourt | nl2br if sentence.conviction.sentencingCourt else 'No court details' } | ||
}, | ||
{ | ||
key: { text: "Responsible court" }, | ||
value: { html: sentence.conviction.responsibleCourt | nl2br if sentence.conviction.responsibleCourt else 'No court details' } | ||
}, | ||
{ | ||
key: { text: "Conviction date" }, | ||
value: { html: sentence.conviction.convictionDate | dateWithYear | nl2br if sentence.conviction.convictionDate else 'No conviction date' } | ||
}, | ||
{ | ||
key: { text: "Additional sentences" }, | ||
value: { html: additionalSentences if hasAdditionalSentences else 'No additional sentences' } | ||
} | ||
] | ||
}) }} | ||
{% endset %} | ||
|
||
{{ appSummaryCard({ | ||
attributes: {'data-qa': 'convictionCard'}, | ||
titleText: 'Conviction', | ||
classes: 'govuk-!-margin-bottom-6 app-summary-card--large-title', | ||
html: conviction | ||
}) }} |
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,42 @@ | ||
{% set hasAdditionalOffences = sentence.offenceDetails.additionalOffences and sentence.offenceDetails.additionalOffences.length > 0 %} | ||
{% set additionalOffences %} | ||
{% if hasAdditionalOffences %} | ||
<ol class="govuk-list{% if sentence.offenceDetails.additionalOffences > 1 %} govuk-list--number{% endif %}"> | ||
{% for additionalOffence in sentence.offenceDetails.additionalOffences %} | ||
<li>{{ additionalOffence.description }} ({{ additionalOffence.count }} count)</li> | ||
{% endfor %} | ||
</ol> | ||
|
||
<a href="/case/{{ crn }}/sentence/offences/{{ sentence.offenceDetails.eventNumber }}">View additional offence details</a> | ||
{% endif %} | ||
{% endset %} | ||
|
||
{% set offence %} | ||
{{ govukSummaryList({ | ||
rows: [ | ||
{ | ||
key: { text: "Main offence" }, | ||
value: { html: sentence.offenceDetails.offence.description + ' (' + sentence.offenceDetails.offence.count + ' count)' } | ||
}, | ||
{ | ||
key: { text: "Offence date" }, | ||
value: { html: sentence.offenceDetails.dateOfOffence | dateWithYear } | ||
}, | ||
{ | ||
key: { text: "Notes" }, | ||
value: { html: sentence.offenceDetails.notes | nl2br if sentence.offenceDetails.notes else 'No notes' } | ||
}, | ||
{ | ||
key: { text: "Additional offences" }, | ||
value: { html: additionalOffences if hasAdditionalOffences else 'No additional offences' } | ||
} | ||
] | ||
}) }} | ||
{% endset %} | ||
|
||
{{ appSummaryCard({ | ||
attributes: {'data-qa': 'offenceCard'}, | ||
titleText: 'Offence', | ||
classes: 'govuk-!-margin-bottom-6 app-summary-card--large-title', | ||
html: offence | ||
}) }} |
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,55 @@ | ||
{% set hasCourtDocuments = sentence.courtDocuments and sentence.courtDocuments.length > 0 %} | ||
{% set courtDocuments %} | ||
<ul class="govuk-list govuk-!-margin-top-0"> | ||
{% for doc in sentence.courtDocuments %} | ||
<li> | ||
<a href="personal-details/documents/{{ doc.id }}/download" download="{{ doc.documentName }}">{{ doc.documentName }}</a><br> | ||
<span class="govuk-!-font-size-16"> | ||
{% if doc.lastSaved %} | ||
Last updated {{ doc.lastSaved | dateWithYearShortMonth }} | ||
{% else %} | ||
Unavailable | ||
{% endif %} | ||
</span> | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
{% endset %} | ||
|
||
{% set sentence %} | ||
{{ govukSummaryList({ | ||
rows: [ | ||
{ | ||
key: { text: "Order" }, | ||
value: { html: sentence.order.description | nl2br if sentence.order.description else 'No order details' } | ||
}, | ||
{ | ||
key: { text: "Sentence start date" }, | ||
value: { html: sentence.order.startDate | dateWithYear | nl2br if sentence.order.startDate else 'No start date details' } | ||
}, | ||
{ | ||
key: { text: "Sentence end date" }, | ||
value: { html: sentence.order.releaseDate | dateWithYear | nl2br if sentence.order.releaseDate else 'No release date details' } | ||
}, | ||
{ | ||
key: { text: "Terminated date" }, | ||
value: { html: sentence.order.endDate | dateWithYear | nl2br if sentence.order.endDate else 'No end date details' } | ||
}, | ||
{ | ||
key: { text: "Termination reason" }, | ||
value: { html: sentence.order.startDate | monthsOrDaysElapsed + ' elapsed (of ' + sentence.order.length + ' months)' | nl2br if sentence.order.startDate else 'No details' } | ||
}, | ||
{ | ||
key: { text: "Court documents" }, | ||
value: { html: '<span data-qa="courtDocumentsValue">' + courtDocuments if hasCourtDocuments else 'No court documents' + '</span>' } | ||
} | ||
] | ||
}) }} | ||
{% endset %} | ||
|
||
{{ appSummaryCard({ | ||
attributes: {'data-qa': 'sentenceCard'}, | ||
titleText: 'Sentence', | ||
classes: 'govuk-!-margin-bottom-6 app-summary-card--large-title', | ||
html: sentence | ||
}) }} |
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
41 changes: 41 additions & 0 deletions
41
server/views/pages/sentence/previous-orders/previous-order.njk
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,41 @@ | ||
{% extends "../../../partials/layout.njk" %} | ||
{% set headerPersonName = previousOrderDetail.name.forename + ' ' + previousOrderDetail.name.surname %} | ||
|
||
{% block beforeContent %} | ||
{{ govukBreadcrumbs({ | ||
items: [ | ||
{ | ||
text: "My cases", | ||
href: "/case" | ||
}, | ||
{ | ||
text: headerPersonName, | ||
href: "/case/" + crn, | ||
attributes: { "data-ai-id": "breadcrumbPersonNameLink" } | ||
}, | ||
{ | ||
text: "Sentence", | ||
href: "/case/" + crn + "/sentence" | ||
}, | ||
{ | ||
text: "Previous orders", | ||
href: "/case/" + crn + "/sentence/previous-orders" | ||
} | ||
] | ||
}) }} | ||
{% endblock %} | ||
{% block content %} | ||
<div class="govuk-!-margin-bottom-0"> | ||
<h2 class="govuk-caption-l" data-qa="pageHeading">Previous orders</h2> | ||
</div> | ||
|
||
{% set sentence = previousOrderDetail.sentence %} | ||
{% if sentence %} | ||
<h2 class="govuk-heading-m govuk-!-margin-bottom-4"> | ||
{{ previousOrderDetail.title }} | ||
</h2> | ||
{% include '../_sentence-offence.njk' %} | ||
{% include '../_conviction.njk' %} | ||
{% include '../_sentence.njk' %} | ||
{% endif %} | ||
{% endblock %} |
Oops, something went wrong.