From eaef3c014e056ad3b93eea843b785ac440522be5 Mon Sep 17 00:00:00 2001 From: Maurice Date: Fri, 27 Nov 2026 20:35:01 +0100 Subject: [PATCH] test(pdf): read the export's note cards without non-null assertions The markdown test for the day notes reached its cards with three non-null assertions, which the client lint counts against the tests' baseline. A small lookup that fails with the missing selector reads them instead. --- client/src/components/PDF/TripPDF.test.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/client/src/components/PDF/TripPDF.test.ts b/client/src/components/PDF/TripPDF.test.ts index c41c910b3..a59079732 100644 --- a/client/src/components/PDF/TripPDF.test.ts +++ b/client/src/components/PDF/TripPDF.test.ts @@ -474,15 +474,20 @@ describe('downloadTripPDF', () => { await downloadTripPDF(md) const html = getIframe()?.srcdoc ?? '' const doc = new DOMParser().parseFromString(html, 'text/html') - const intro = doc.querySelector('.day-intro')! + const card = (selector: string) => { + const found = doc.querySelector(selector) + if (!found) throw new Error(`${selector} is not in the export`) + return found + } + const intro = card('.day-intro') expect(intro.querySelector('strong')?.textContent).toBe('Intro') expect([...intro.querySelectorAll('li')].map(li => li.textContent)).toEqual(['museum', 'lunch']) - const noteLine = doc.querySelector('.tl-note .note-time')! + const noteLine = card('.tl-note .note-time') expect(noteLine.querySelector('em')?.textContent).toBe('Bring') expect(noteLine.querySelector('hr')).not.toBeNull() expect(noteLine.querySelector('script')).toBeNull() expect(noteLine.textContent).toContain('') - const transportNote = doc.querySelector('.transport-note')! + const transportNote = card('.transport-note') expect(transportNote.querySelector('strong')?.textContent).toBe('14A') expect([...transportNote.querySelectorAll('ol li')].map(li => li.textContent)).toEqual(['check in', 'board']) expect(html).not.toContain('**')