mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-24 07:53:09 +00:00
fix: journey year helper takes what a journey row carries; PDF markdown test without casts
This commit is contained in:
@@ -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,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()) : '';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user