Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -105,7 +105,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 @@ -79,10 +79,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,26 +7,22 @@ export interface RenderOptions {
displayFrom: Date;
displayTo: Date;
lastReceivedDate: string;
listTitle: string;
}

export interface RenderedData {
header: {
listTitle: string;
duration: string;
lastUpdated: string;
weekCommencingDate: string;
lastUpdatedDate: string;
lastUpdatedTime: string;
};
hearings: CareStandardsTribunalHearing[];
}

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 @@ -39,9 +35,10 @@ export function renderCareStandardsTribunalData(hearingList: CareStandardsTribun

return {
header: {
listTitle,
duration,
lastUpdated
listTitle: options.listTitle,
weekCommencingDate,
lastUpdatedDate,
lastUpdatedTime
},
hearings: renderedHearings
};
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"jws": "4.0.1",
"lodash": "4.17.23",
"node-forge": "1.3.3",
"qs": "6.14.1",
"qs": "6.14.2",
"tar": "7.5.7",
"undici": "6.23.0",
"vite": "7.3.0"
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6911,12 +6911,12 @@ __metadata:
languageName: node
linkType: hard

"qs@npm:6.14.1":
version: 6.14.1
resolution: "qs@npm:6.14.1"
"qs@npm:6.14.2":
version: 6.14.2
resolution: "qs@npm:6.14.2"
dependencies:
side-channel: "npm:^1.1.0"
checksum: 10c0/0e3b22dc451f48ce5940cbbc7c7d9068d895074f8c969c0801ac15c1313d1859c4d738e46dc4da2f498f41a9ffd8c201bd9fb12df67799b827db94cc373d2613
checksum: 10c0/646110124476fc9acf3c80994c8c3a0600cbad06a4ede1c9e93341006e8426d64e85e048baf8f0c4995f0f1bf0f37d1f3acc5ec1455850b81978792969a60ef6
languageName: node
linkType: hard

Expand Down
Loading