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
3 changes: 2 additions & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,9 @@ jobs:
path: e2e-tests/junit-results.xml
reporter: java-junit
fail-on-error: false
fail-on-empty: false

# Upload artifacts on failure for debugging
# Upload artifacts on failure for debugging
- name: Upload Playwright test results
uses: actions/upload-artifact@v6
if: always() && steps.e2e-tests.outcome == 'failure'
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/job.e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ jobs:
path: e2e-tests/junit-results.xml
reporter: java-junit
fail-on-error: false
fail-on-empty: false
search-files: filesystem

# Upload artifacts on failure for debugging
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ describe("Upper Tribunal Administrative Appeals Chamber page controller", () =>
expect(getPublicationJson).toHaveBeenCalledWith("test-artefact-123");
expect(renderUtaacDailyHearingListData).toHaveBeenCalledWith(mockJsonData, {
locale: "en",
courtName: "Upper Tribunal (Administrative Appeals Chamber)",
contentDate: mockArtefact.contentDate,
lastReceivedDate: mockArtefact.lastReceivedDate.toISOString(),
listTitle: "Upper Tribunal (Administrative Appeals Chamber) Daily Hearing list"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export const GET = createSimpleListTypeHandler<UtaacHearingList>({
const t = locale === "cy" ? cy : en;
const { header, hearings } = renderUtaacDailyHearingListData(jsonData, {
locale,
courtName: "Upper Tribunal (Administrative Appeals Chamber)",
contentDate: artefact.contentDate,
lastReceivedDate: artefact.lastReceivedDate.toISOString(),
listTitle: t.pageTitle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ describe("Upper Tribunal Lands Chamber page controller", () => {
expect(getPublicationJson).toHaveBeenCalledWith("test-artefact-123");
expect(renderUtlcDailyHearingListData).toHaveBeenCalledWith(mockJsonData, {
locale: "en",
courtName: "Upper Tribunal (Lands Chamber)",
contentDate: mockArtefact.contentDate,
lastReceivedDate: mockArtefact.lastReceivedDate.toISOString(),
listTitle: "Upper Tribunal (Lands Chamber) Daily Hearing list"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export const GET = createSimpleListTypeHandler<UtlcHearingList>({
const t = locale === "cy" ? cy : en;
const { header, hearings } = renderUtlcDailyHearingListData(jsonData, {
locale,
courtName: "Upper Tribunal (Lands Chamber)",
contentDate: artefact.contentDate,
lastReceivedDate: artefact.lastReceivedDate.toISOString(),
listTitle: t.pageTitle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ describe("Upper Tribunal Tax and Chancery Chamber page controller", () => {
expect(getPublicationJson).toHaveBeenCalledWith("test-artefact-123");
expect(renderUtccDailyHearingListData).toHaveBeenCalledWith(mockJsonData, {
locale: "en",
courtName: "Upper Tribunal Tax and Chancery Chamber",
contentDate: mockArtefact.contentDate,
lastReceivedDate: mockArtefact.lastReceivedDate.toISOString(),
listTitle: "Upper Tribunal Tax and Chancery Chamber Daily Hearing list"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export const GET = createSimpleListTypeHandler<UtccHearingList>({
const t = locale === "cy" ? cy : en;
const { header, hearings } = renderUtccDailyHearingListData(jsonData, {
locale,
courtName: "Upper Tribunal Tax and Chancery Chamber",
contentDate: artefact.contentDate,
lastReceivedDate: artefact.lastReceivedDate.toISOString(),
listTitle: t.pageTitle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,9 @@ describe("generateUtaacDailyHearingListPdf", () => {

expect(renderUtaacDailyHearingListData).toHaveBeenCalledWith(mockHearingList, {
locale: "cy",
courtName: "Upper Tribunal (Administrative Appeals Chamber)",
contentDate,
lastReceivedDate: expect.any(String),
listTitle: "Upper Tribunal (Administrative Appeals Chamber) Daily Hearing List"
listTitle: "Rhestr Gwrandawiadau Dyddiol Tribiwnlys Uwch (Siambr Apeliadau Gweinyddol)"
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import { renderUtaacDailyHearingListData } from "../rendering/renderer.js";
const __dirname = path.dirname(fileURLToPath(import.meta.url));

export const generateUtaacDailyHearingListPdf = createUtDailyHearingListPdfGenerator<UtaacHearingList>(
"Upper Tribunal (Administrative Appeals Chamber)",
"Upper Tribunal (Administrative Appeals Chamber) Daily Hearing List",
renderUtaacDailyHearingListData,
() => import("../locales/en.js"),
() => import("../locales/cy.js"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { renderUtaacDailyHearingListData } from "./renderer.js";
describe("renderUtaacDailyHearingListData", () => {
const baseOptions = {
locale: "en",
courtName: "Upper Tribunal (Administrative Appeals Chamber)",
contentDate: new Date(2025, 0, 15),
lastReceivedDate: "2025-01-15T09:55:00Z",
listTitle: "Upper Tribunal (Administrative Appeals Chamber) Daily Hearing List"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type { UtaacHearing, UtaacHearingList } from "../models/types.js";

export interface RenderOptions {
locale: string;
courtName: string;
contentDate: Date;
lastReceivedDate: string;
listTitle: string;
Expand Down
16 changes: 2 additions & 14 deletions libs/list-types/upper-tribunal-common/src/pdf-generator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,7 @@ describe("createUtDailyHearingListPdfGenerator", () => {
});

const makeGenerator = () =>
createUtDailyHearingListPdfGenerator(
"Test Court",
"Test List Title",
mockRenderFn,
mockImportEn,
mockImportCy,
"/fake/dirname",
mockProvenanceLabels,
mockGeneratePdfFn
);
createUtDailyHearingListPdfGenerator(mockRenderFn, mockImportEn, mockImportCy, "/fake/dirname", mockProvenanceLabels, mockGeneratePdfFn);

it("should generate and store PDF successfully", async () => {
// Arrange
Expand All @@ -71,10 +62,7 @@ describe("createUtDailyHearingListPdfGenerator", () => {
// Assert
expect(result.success).toBe(true);
expect(result.pdfPath).toContain("artefact-123.pdf");
expect(mockRenderFn).toHaveBeenCalledWith(
baseOptions.jsonData,
expect.objectContaining({ courtName: "Test Court", listTitle: "Test List Title", locale: "en" })
);
expect(mockRenderFn).toHaveBeenCalledWith(baseOptions.jsonData, expect.objectContaining({ listTitle: "English", locale: "en" }));
});

it("should use Welsh translations when locale is cy", async () => {
Expand Down
10 changes: 3 additions & 7 deletions libs/list-types/upper-tribunal-common/src/pdf-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {

export interface DailyHearingListRenderOptions {
locale: string;
courtName: string;
contentDate: Date;
lastReceivedDate: string;
listTitle: string;
Expand All @@ -23,8 +22,6 @@ export interface DailyHearingListRenderedData {
}

export function createUtDailyHearingListPdfGenerator<T>(
courtName: string,
listTitle: string,
renderFn: (data: T, options: DailyHearingListRenderOptions) => DailyHearingListRenderedData,
importEn: () => Promise<{ en: Record<string, unknown> }>,
importCy: () => Promise<{ cy: Record<string, unknown> }>,
Expand All @@ -34,16 +31,15 @@ export function createUtDailyHearingListPdfGenerator<T>(
) {
return async function generatePdf(options: BasePdfGenerationOptions<T> & { contentDate: Date }): Promise<PdfGenerationResult> {
try {
const translations = await loadTranslations(options.locale, importEn, importCy);

const renderedData = renderFn(options.jsonData, {
locale: options.locale,
courtName,
contentDate: options.contentDate,
lastReceivedDate: new Date().toISOString(),
listTitle
listTitle: translations.pageTitle as string
});

const translations = await loadTranslations(options.locale, importEn, importCy);

const provenanceLabel = options.provenance ? provenanceLabels[options.provenance] || options.provenance : "";

const env = configureNunjucks(dirname);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,9 @@ describe("generateUtlcDailyHearingListPdf", () => {

expect(renderUtlcDailyHearingListData).toHaveBeenCalledWith(mockHearingList, {
locale: "cy",
courtName: "Upper Tribunal (Lands Chamber)",
contentDate,
lastReceivedDate: expect.any(String),
listTitle: "Upper Tribunal (Lands Chamber) Daily Hearing List"
listTitle: "Rhestr Gwrandawiadau Dyddiol Tribiwnlys Uwch (Siambr Tiroedd)"
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import { renderUtlcDailyHearingListData } from "../rendering/renderer.js";
const __dirname = path.dirname(fileURLToPath(import.meta.url));

export const generateUtlcDailyHearingListPdf = createUtDailyHearingListPdfGenerator<UtlcHearingList>(
"Upper Tribunal (Lands Chamber)",
"Upper Tribunal (Lands Chamber) Daily Hearing List",
renderUtlcDailyHearingListData,
() => import("../locales/en.js"),
() => import("../locales/cy.js"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { renderUtlcDailyHearingListData } from "./renderer.js";
describe("renderUtlcDailyHearingListData", () => {
const baseOptions = {
locale: "en",
courtName: "Upper Tribunal (Lands Chamber)",
contentDate: new Date(2025, 0, 15),
lastReceivedDate: "2025-01-15T09:55:00Z",
listTitle: "Upper Tribunal (Lands Chamber) Daily Hearing List"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type { UtlcHearing, UtlcHearingList } from "../models/types.js";

export interface RenderOptions {
locale: string;
courtName: string;
contentDate: Date;
lastReceivedDate: string;
listTitle: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,9 @@ describe("generateUtccDailyHearingListPdf", () => {

expect(renderUtccDailyHearingListData).toHaveBeenCalledWith(mockHearingList, {
locale: "cy",
courtName: "Upper Tribunal Tax and Chancery Chamber",
contentDate,
lastReceivedDate: expect.any(String),
listTitle: "Upper Tribunal Tax and Chancery Chamber Daily Hearing List"
listTitle: "Rhestr Gwrandawiadau Dyddiol Tribiwnlys Uwch Siambr Dreth a Siawnsri"
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import { renderUtccDailyHearingListData } from "../rendering/renderer.js";
const __dirname = path.dirname(fileURLToPath(import.meta.url));

export const generateUtccDailyHearingListPdf = createUtDailyHearingListPdfGenerator<UtccHearingList>(
"Upper Tribunal Tax and Chancery Chamber",
"Upper Tribunal Tax and Chancery Chamber Daily Hearing List",
renderUtccDailyHearingListData,
() => import("../locales/en.js"),
() => import("../locales/cy.js"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { renderUtccDailyHearingListData } from "./renderer.js";
describe("renderUtccDailyHearingListData", () => {
const baseOptions = {
locale: "en",
courtName: "Upper Tribunal Tax and Chancery Chamber",
contentDate: new Date(2025, 0, 15),
lastReceivedDate: "2025-01-15T09:55:00Z",
listTitle: "Upper Tribunal Tax and Chancery Chamber Daily Hearing List"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type { UtccHearing, UtccHearingList } from "../models/types.js";

export interface RenderOptions {
locale: string;
courtName: string;
contentDate: Date;
lastReceivedDate: string;
listTitle: string;
Expand Down
Loading