diff --git a/tests/unit/pdf.roundtrip.test.ts b/tests/unit/pdf.roundtrip.test.ts index 8bfbf5d1..ddb79baf 100644 --- a/tests/unit/pdf.roundtrip.test.ts +++ b/tests/unit/pdf.roundtrip.test.ts @@ -32,6 +32,35 @@ describe('PDF roundtrip', () => { expect(imported.version).toBe(2) }) + it('roundtrips a report exported with locale=fr', async () => { + const bytes = await exportReportToPdf(report, { locale: 'fr' }) + const imported = await importReportFromPdf(bytes) + expect(imported.animal.name).toBe('Mistral') + expect(imported.version).toBe(2) + }) + + it('roundtrips a report exported with locale=en', async () => { + const bytes = await exportReportToPdf(report, { locale: 'en' }) + const imported = await importReportFromPdf(bytes) + expect(imported.animal.name).toBe('Mistral') + expect(imported.version).toBe(2) + }) + + it('FR and EN exports both produce non-empty byte streams', async () => { + // pdf-lib subsets fonts (LRN-016), so plain-text grep over the bytes + // is unreliable. The imported JSON is the strongest invariant — the + // locale lives outside the Report, so both imports return the same + // payload while the static label snapshots differ inside the PDF. + const fr = await exportReportToPdf(report, { locale: 'fr' }) + const en = await exportReportToPdf(report, { locale: 'en' }) + expect(fr.byteLength).toBeGreaterThan(0) + expect(en.byteLength).toBeGreaterThan(0) + const frImported = await importReportFromPdf(fr) + const enImported = await importReportFromPdf(en) + expect(frImported.animal.name).toBe(enImported.animal.name) + expect(frImported.version).toBe(enImported.version) + }) + it('rejects a legacy v1 PDF with a version-specific message', async () => { const doc = await PDFDocument.create() doc.addPage()