diff --git a/integration_tests/e2e/courtCaseDetails.cy.ts b/integration_tests/e2e/courtCaseDetails.cy.ts index ffc4c2fa..72bae889 100644 --- a/integration_tests/e2e/courtCaseDetails.cy.ts +++ b/integration_tests/e2e/courtCaseDetails.cy.ts @@ -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', () => { diff --git a/integration_tests/pages/courtCaseDetailsPage.ts b/integration_tests/pages/courtCaseDetailsPage.ts index 0e21d327..098c213d 100644 --- a/integration_tests/pages/courtCaseDetailsPage.ts +++ b/integration_tests/pages/courtCaseDetailsPage.ts @@ -6,4 +6,6 @@ export default class CourtCaseDetailsPage extends Page { } appearancesSummaryList = (): PageElement => cy.get('[data-qa=appearancesSummaryList]') + + appearancesTable = (): PageElement => cy.get('[data-qa=appearancesTable]') } diff --git a/server/routes/data/CourtCaseDetailsModel.ts b/server/routes/data/CourtCaseDetailsModel.ts index 10648e27..803d813b 100644 --- a/server/routes/data/CourtCaseDetailsModel.ts +++ b/server/routes/data/CourtCaseDetailsModel.ts @@ -51,5 +51,7 @@ export default class CourtCaseDetailsModel { periodLengthToSentenceLength(pageCourtCaseContent.latestAppearance.overallSentenceLength), ) } + this.appearanceTotal = pageCourtCaseContent.appearances.length + this.appearances = pageCourtCaseContent.appearances } } diff --git a/server/views/pages/courtCaseDetails.njk b/server/views/pages/courtCaseDetails.njk index 10d13d92..fc0aa42b 100644 --- a/server/views/pages/courtCaseDetails.njk +++ b/server/views/pages/courtCaseDetails.njk @@ -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" %} @@ -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: 'Edit' } + ]]))%} +{% endfor %} + {% block content %} {{ super() }}
@@ -60,6 +73,33 @@ } }) }} +

+ Appearances ({{ courtCaseDetails.appearanceTotal }}) +

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