fix: journey year helper takes what a journey row carries; PDF markdown test without casts

This commit is contained in:
Maurice
2026-10-24 08:59:15 +02:00
parent 0534d7b3a7
commit ad4074f107
2 changed files with 5 additions and 5 deletions
+3 -3
View File
@@ -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 |', '', '<script>alert(1)</script>'].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('<strong>Colosseum</strong>')
expect(html).toContain('<td>9:00</td>')
expect(html).not.toContain('**Colosseum**')
+2 -2
View File
@@ -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()) : '';
}