From d33b3a81b10c91da4ccee4d2fa97431c436b3a38 Mon Sep 17 00:00:00 2001 From: Maurice Date: Sat, 24 Oct 2026 08:59:15 +0200 Subject: [PATCH] fix: journey year helper takes what a journey row carries; PDF markdown test without casts --- client/src/components/PDF/TripPDF.test.ts | 6 +++--- client/src/pages/journey/journeyModel.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/client/src/components/PDF/TripPDF.test.ts b/client/src/components/PDF/TripPDF.test.ts index 950cae85a..6f33da5bb 100644 --- a/client/src/components/PDF/TripPDF.test.ts +++ b/client/src/components/PDF/TripPDF.test.ts @@ -401,9 +401,9 @@ describe('downloadTripPDF', () => { it('FE-COMP-TRIPPDF-016c: renders markdown in a place description, sanitized', async () => { const description = ['**Colosseum** tickets', '', '| Gate | Time |', '| --- | --- |', '| A | 9:00 |', '', ''].join('\n') const place = { ...placeWithDetails, description } - const md = { ...richArgs, places: [place], assignments: { '10': [{ ...assignmentForDay, place }] } } - await downloadTripPDF(md as any) - const html = getIframe()!.srcdoc + const md = { ...richArgs, places: [place], assignments: { '10': [{ ...assignmentForDay, place }] } as typeof richArgs.assignments } + await downloadTripPDF(md) + const html = getIframe()?.srcdoc ?? '' expect(html).toContain('Colosseum') expect(html).toContain('9:00') expect(html).not.toContain('**Colosseum**') diff --git a/client/src/pages/journey/journeyModel.ts b/client/src/pages/journey/journeyModel.ts index da2379dd8..0c1b26b5c 100644 --- a/client/src/pages/journey/journeyModel.ts +++ b/client/src/pages/journey/journeyModel.ts @@ -2,12 +2,12 @@ export function journeyYearLabel(journey: { trip_date_min?: string | null; trip_date_max?: string | null; - created_at: string; + created_at?: string | null; }): string { // The dates are calendar dates, so the year is read from the text, not through a Date in some zone. const from = journey.trip_date_min?.slice(0, 4); const to = journey.trip_date_max?.slice(0, 4); if (from && to && to !== from) return `${from}/${to}`; if (from || to) return (from || to) as string; - return String(new Date(journey.created_at).getFullYear()); + return journey.created_at ? String(new Date(journey.created_at).getFullYear()) : ''; }