Skip to content

Commit

Permalink
RASS-248 add appearance table (#336)
Browse files Browse the repository at this point in the history
  • Loading branch information
carloveo-moj authored Jul 10, 2024
1 parent af63249 commit e8cfeff
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 0 deletions.
22 changes: 22 additions & 0 deletions integration_tests/e2e/courtCaseDetails.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,28 @@ context('Court Case details Page', () => {
'Next hearing date': '15 12 2024',
})
})

it('appearances table shows correct data', () => {
courtCaseDetailsPage
.appearancesTable()
.getTable()
.should('deep.equal', [
{
'Case reference': 'C894623',
Location: 'Birmingham Crown Court',
'Warrant date': '15 12 2023',
Outcome: 'Remand in Custody (Bail Refused)',
'': 'Edit',
},
{
'Case reference': 'F23325',
Location: 'Birmingham Crown Court',
'Warrant date': '15 10 2022',
Outcome: 'Sentence Postponed',
'': 'Edit',
},
])
})
})

context('Latest sentence appearance', () => {
Expand Down
2 changes: 2 additions & 0 deletions integration_tests/pages/courtCaseDetailsPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ export default class CourtCaseDetailsPage extends Page {
}

appearancesSummaryList = (): PageElement => cy.get('[data-qa=appearancesSummaryList]')

appearancesTable = (): PageElement => cy.get('[data-qa=appearancesTable]')
}
2 changes: 2 additions & 0 deletions server/routes/data/CourtCaseDetailsModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,7 @@ export default class CourtCaseDetailsModel {
periodLengthToSentenceLength(pageCourtCaseContent.latestAppearance.overallSentenceLength),
)
}
this.appearanceTotal = pageCourtCaseContent.appearances.length
this.appearances = pageCourtCaseContent.appearances
}
}
40 changes: 40 additions & 0 deletions server/views/pages/courtCaseDetails.njk
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{% from "govuk/components/summary-list/macro.njk" import govukSummaryList %}
{% from "../components/offenceCard/macro.njk" import offenceCard %}
{% from "govuk/components/button/macro.njk" import govukButton %}
{% from "govuk/components/table/macro.njk" import govukTable %}


{% set pageTitle = applicationName + " - Court case details" %}
Expand Down Expand Up @@ -47,6 +48,18 @@
}))%}
{% endif %}

{% set appearanceRows = [] %}

{% for appearance in courtCaseDetails.appearances %}
{% set appearanceRows = (appearanceRows.concat([[
{ text: appearance.courtCaseReference },
{ text: appearance.courtCode },
{ text: appearance.appearanceDate | formatDate },
{ text: appearance.outcome },
{ html: '<a href="/person/' + nomsId + '/edit-court-case/' + courtCaseDetails.courtCaseUuid + '/edit-court-appearance/' + appearance.appearanceUuid + '/details">Edit</a>' }
]]))%}
{% endfor %}

{% block content %}
{{ super() }}
<div class="govuk-grid-row govuk-!-margin-top-4">
Expand All @@ -60,6 +73,33 @@
}
}) }}

<h2 class="govuk-heading-m govuk-!-margin-top-8">
Appearances <span class="govuk-body">({{ courtCaseDetails.appearanceTotal }})</span>
</h2>

{{ govukTable({
head: [
{
text: "Case reference"
},
{
text: "Location"
},
{
text: "Warrant date"
},
{
text: "Outcome"
},
{
text: ""
}],
rows: appearanceRows,
attributes: {
"data-qa": "appearancesTable"
}
})}}

</div>
</div>

Expand Down

0 comments on commit e8cfeff

Please sign in to comment.