Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
353 changes: 229 additions & 124 deletions e2e-tests/tests/care-standards-tribunal-upload.spec.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
<a href="{{ t.factLinkUrl }}" class="govuk-link">{{ t.factLinkText }}</a> {{ t.factAdditionalText }}
</p>

<p class="govuk-body govuk-!-font-weight-bold govuk-!-margin-bottom-1">{{ header.duration }}</p>
<p class="govuk-body">{{ header.lastUpdated }}</p>
<p class="govuk-body govuk-!-font-weight-bold govuk-!-margin-bottom-1">{{ t.listForWeekCommencing }} {{ header.weekCommencingDate }}</p>
<p class="govuk-body">{{ t.lastUpdated }} {{ header.lastUpdatedDate }} {{ t.at }} {{ header.lastUpdatedTime }}</p>

<details class="govuk-details govuk-!-margin-top-6" data-module="govuk-details">
<details class="govuk-details govuk-!-margin-top-6" data-module="govuk-details" open>
<summary class="govuk-details__summary">
<span class="govuk-details__summary-text">
{{ t.importantInformationTitle }}
Expand Down Expand Up @@ -74,7 +74,7 @@
</table>
</div>

<p class="govuk-body govuk-!-margin-top-6">{{ t.dataSource }}: {{ dataSource }}</p>
<p class="govuk-body-s govuk-!-margin-top-6">{{ t.dataSource }}: {{ dataSource }}</p>

<div class="back-to-top">
<a href="#top" class="govuk-link">{{ t.backToTop }}</a>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
export const cy = {
pageTitle: "Welsh placeholder",
factLinkText: "Dod o hyd i fanylion cyswllt a gwybodaeth arall am lysoedd a thribiwnlysoedd",
pageTitle: "Rhestr Gwrandawiadau Wythnosol y Tribiwnlys Safonau Gofal",
listForWeekCommencing: "Rhestr ar gyfer yr wythnos yn dechrau ar",
lastUpdated: "Diweddarwyd ddiwethaf",
at: "am",
factLinkText: "Dod o hyd i fanylion cyswllt a gwybodaeth arall am lysoedd a thribiwnlysoedd yng Nghymru a Lloegr",
factLinkUrl: "https://www.find-court-tribunal.service.gov.uk/",
factAdditionalText: "yng Nghymru a Lloegr, a rhai tribiwnlysoedd nad ydynt wedi'u datganoli yn yr Alban.",
importantInformationTitle: "Welsh placeholder",
importantInformationText: "Welsh placeholder",
importantInformationLinkText: "Welsh placeholder",
factAdditionalText: "a rhai tribiwnlysoedd heb eu datganoli yn yr Alban.",
importantInformationTitle: "Gwybodaeth bwysig",
importantInformationText: "Cysylltwch â'r Swyddfa Safonau Gofal yn cst@justice.gov.uk i gael manylion am sut i gael mynediad at wrandawiadau fideo.",
importantInformationLinkText: "Arsylwi gwrandawiad llys neu dribiwnlys fel newyddiadurwr, ymchwilydd neu aelod o'r cyhoedd",
importantInformationLinkUrl: "https://www.gov.uk/guidance/observe-a-court-or-tribunal-hearing",
searchCasesTitle: "Welsh placeholder",
searchCasesLabel: "Welsh placeholder",
searchCasesTitle: "Chwilio Achosion",
searchCasesLabel: "Chwilio yn ôl rhif achos, manylion, lleoliad, barnwr, neu wybodaeth arall",
tableHeaders: {
date: "Welsh placeholder",
caseName: "Welsh placeholder",
hearingLength: "Welsh placeholder",
hearingType: "Welsh placeholder",
venue: "Welsh placeholder",
additionalInformation: "Welsh placeholder"
date: "Dyddiad",
caseName: "Enw'r achos",
hearingLength: "Hyd y gwrandawiad",
hearingType: "Math o wrandawiad",
venue: "Lleoliad",
additionalInformation: "Gwybodaeth ychwanegol"
},
dataSource: "Welsh placeholder for 'Data source'",
backToTop: "Welsh placeholder"
dataSource: "Ffynhonnell data",
backToTop: "Yn ôl i frig y dudalen",
provenanceLabels: {
MANUAL_UPLOAD: "Llwytho â Llaw",
XHIBIT: "XHIBIT",
SNL: "SNL",
COMMON_PLATFORM: "Platfform Cyffredin"
}
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
export const en = {
pageTitle: "Care Standards Tribunal Weekly Hearing List",
listForWeekCommencing: "List for week commencing",
lastUpdated: "Last updated",
at: "at",
factLinkText: "Find contact details and other information about courts and tribunals",
factLinkUrl: "https://www.find-court-tribunal.service.gov.uk/",
factAdditionalText: "in England and Wales, and some non-devolved tribunals in Scotland.",
Expand All @@ -18,5 +21,11 @@ export const en = {
additionalInformation: "Additional information"
},
dataSource: "Data source",
backToTop: "Back to top"
backToTop: "Back to top",
provenanceLabels: {
MANUAL_UPLOAD: "Manual Upload",
XHIBIT: "XHIBIT",
SNL: "SNL",
COMMON_PLATFORM: "Common Platform"
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ describe("Care Standards Tribunal page controller", () => {
courtName: "Care Standards Tribunal",
displayFrom: mockArtefact.displayFrom,
displayTo: mockArtefact.displayTo,
lastReceivedDate: mockArtefact.lastReceivedDate.toISOString()
lastReceivedDate: mockArtefact.lastReceivedDate.toISOString(),
listTitle: "Care Standards Tribunal Weekly Hearing List"
});
const renderCall = vi.mocked(res.render).mock.calls[0];
expect(renderCall[0]).toBe("care-standards-tribunal-weekly-hearing-list");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import path from "node:path";
import { fileURLToPath } from "node:url";
import { createJsonValidator } from "@hmcts/list-types-common";
import { prisma } from "@hmcts/postgres";
import { PROVENANCE_LABELS } from "@hmcts/publication";
import type { Request, Response } from "express";
import type { CareStandardsTribunalHearingList } from "../models/types.js";
import { renderCareStandardsTribunalData } from "../rendering/renderer.js";
Expand Down Expand Up @@ -82,10 +81,11 @@ export const GET = async (req: Request, res: Response) => {
courtName,
displayFrom: artefact.displayFrom,
displayTo: artefact.displayTo,
lastReceivedDate: artefact.lastReceivedDate.toISOString()
lastReceivedDate: artefact.lastReceivedDate.toISOString(),
listTitle: t.pageTitle
});

const dataSource = PROVENANCE_LABELS[artefact.provenance] || artefact.provenance;
const dataSource = t.provenanceLabels[artefact.provenance as keyof typeof t.provenanceLabels] || artefact.provenance;

res.render("care-standards-tribunal-weekly-hearing-list", {
en,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ describe("renderCareStandardsTribunalData", () => {
courtName: "Care Standards Tribunal",
displayFrom: new Date(2025, 0, 2),
displayTo: new Date(2025, 0, 8),
lastReceivedDate: "2025-01-01T09:55:00Z"
lastReceivedDate: "2025-01-01T09:55:00Z",
listTitle: "Care Standards Tribunal Weekly Hearing List"
};

const result = renderCareStandardsTribunalData(hearingList, options);

expect(result.header.listTitle).toBe("Care Standards Tribunal Weekly Hearing List");
expect(result.header.duration).toContain("List for week commencing");
expect(result.header.duration).toContain("2 January 2025");
expect(result.header.lastUpdated).toContain("Last updated");
expect(result.header.lastUpdated).toContain("1 January 2025");
expect(result.header.weekCommencingDate).toBe("2 January 2025");
expect(result.header.lastUpdatedDate).toBe("1 January 2025");
expect(result.header.lastUpdatedTime).toContain("am");

expect(result.hearings).toHaveLength(1);
expect(result.hearings[0].date).toBe("2 January 2025");
Expand Down Expand Up @@ -65,7 +65,8 @@ describe("renderCareStandardsTribunalData", () => {
courtName: "Care Standards Tribunal",
displayFrom: new Date(2025, 0, 2),
displayTo: new Date(2025, 0, 8),
lastReceivedDate: "2025-01-01T09:55:00Z"
lastReceivedDate: "2025-01-01T09:55:00Z",
listTitle: "Care Standards Tribunal Weekly Hearing List"
};

const result = renderCareStandardsTribunalData(hearingList, options);
Expand All @@ -92,7 +93,8 @@ describe("renderCareStandardsTribunalData", () => {
courtName: "Care Standards Tribunal",
displayFrom: new Date(2025, 0, 1),
displayTo: new Date(2025, 0, 7),
lastReceivedDate: "2025-01-01T09:55:00Z"
lastReceivedDate: "2025-01-01T09:55:00Z",
listTitle: "Care Standards Tribunal Weekly Hearing List"
};

const result = renderCareStandardsTribunalData(hearingList, options);
Expand All @@ -117,12 +119,13 @@ describe("renderCareStandardsTribunalData", () => {
courtName: "Care Standards Tribunal",
displayFrom: new Date(2025, 0, 2),
displayTo: new Date(2025, 0, 8),
lastReceivedDate: "2025-01-01T09:55:00Z"
lastReceivedDate: "2025-01-01T09:55:00Z",
listTitle: "Care Standards Tribunal Weekly Hearing List"
};

const result = renderCareStandardsTribunalData(hearingList, options);

expect(result.header.lastUpdated).toContain("at 9:55am");
expect(result.header.lastUpdatedTime).toBe("9:55am");
});

it("should format PM times correctly", () => {
Expand All @@ -142,12 +145,13 @@ describe("renderCareStandardsTribunalData", () => {
courtName: "Care Standards Tribunal",
displayFrom: new Date(2025, 0, 2),
displayTo: new Date(2025, 0, 8),
lastReceivedDate: "2025-01-01T14:30:00Z"
lastReceivedDate: "2025-01-01T14:30:00Z",
listTitle: "Care Standards Tribunal Weekly Hearing List"
};

const result = renderCareStandardsTribunalData(hearingList, options);

expect(result.header.lastUpdated).toContain("at 2:30pm");
expect(result.header.lastUpdatedTime).toBe("2:30pm");
});

it("should handle empty hearing list", () => {
Expand All @@ -158,7 +162,8 @@ describe("renderCareStandardsTribunalData", () => {
courtName: "Care Standards Tribunal",
displayFrom: new Date(2025, 0, 2),
displayTo: new Date(2025, 0, 8),
lastReceivedDate: "2025-01-01T09:55:00Z"
lastReceivedDate: "2025-01-01T09:55:00Z",
listTitle: "Care Standards Tribunal Weekly Hearing List"
};

const result = renderCareStandardsTribunalData(hearingList, options);
Expand All @@ -167,6 +172,32 @@ describe("renderCareStandardsTribunalData", () => {
expect(result.header.listTitle).toBe("Care Standards Tribunal Weekly Hearing List");
});

it("should use the provided listTitle from translations", () => {
const hearingList: CareStandardsTribunalHearingList = [
{
date: "02/01/2025",
caseName: "A Vs B",
hearingLength: "1 hour",
hearingType: "Substantive hearing",
venue: "Care Standards Tribunal",
additionalInformation: "Remote hearing"
}
];

const optionsWelsh = {
locale: "cy",
courtName: "Care Standards Tribunal",
displayFrom: new Date(2025, 0, 2),
displayTo: new Date(2025, 0, 8),
lastReceivedDate: "2025-01-01T09:55:00Z",
listTitle: "Rhestr Gwrandawiadau Wythnosol y Tribiwnlys Safonau Gofal"
};

const result = renderCareStandardsTribunalData(hearingList, optionsWelsh);

expect(result.header.listTitle).toBe("Rhestr Gwrandawiadau Wythnosol y Tribiwnlys Safonau Gofal");
});

it("should preserve all hearing fields without modification", () => {
const hearingList: CareStandardsTribunalHearingList = [
{
Expand All @@ -184,7 +215,8 @@ describe("renderCareStandardsTribunalData", () => {
courtName: "Care Standards Tribunal",
displayFrom: new Date(2025, 0, 2),
displayTo: new Date(2025, 0, 8),
lastReceivedDate: "2025-01-01T09:55:00Z"
lastReceivedDate: "2025-01-01T09:55:00Z",
listTitle: "Care Standards Tribunal Weekly Hearing List"
};

const result = renderCareStandardsTribunalData(hearingList, options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export interface RenderOptions {
displayFrom: Date;
displayTo: Date;
lastReceivedDate: string;
listTitle: string;
}

export interface RenderedHearing {
Expand All @@ -21,21 +22,16 @@ export interface RenderedHearing {
export interface RenderedData {
header: {
listTitle: string;
duration: string;
lastUpdated: string;
weekCommencingDate: string;
lastUpdatedDate: string;
lastUpdatedTime: string;
};
hearings: RenderedHearing[];
}

function formatLastUpdated(isoDateTime: string, locale: string): string {
const { date, time } = formatLastUpdatedDateTime(isoDateTime, locale);
return `${date} at ${time}`;
}

export function renderCareStandardsTribunalData(hearingList: CareStandardsTribunalHearingList, options: RenderOptions): RenderedData {
const listTitle = "Care Standards Tribunal Weekly Hearing List";
const duration = `List for week commencing ${formatDisplayDate(options.displayFrom, options.locale)}`;
const lastUpdated = `Last updated ${formatLastUpdated(options.lastReceivedDate, options.locale)}`;
const weekCommencingDate = formatDisplayDate(options.displayFrom, options.locale);
const { date: lastUpdatedDate, time: lastUpdatedTime } = formatLastUpdatedDateTime(options.lastReceivedDate, options.locale);

const renderedHearings = hearingList.map((hearing) => ({
date: formatDdMmYyyyDate(hearing.date, options.locale),
Expand All @@ -48,9 +44,10 @@ export function renderCareStandardsTribunalData(hearingList: CareStandardsTribun

return {
header: {
listTitle,
duration,
lastUpdated
listTitle: options.listTitle,
weekCommencingDate,
lastUpdatedDate,
lastUpdatedTime
},
hearings: renderedHearings
};
Expand Down
Loading