test(pdf): cover roundtrip under locale=fr and locale=en
3 new cases: - exports with locale=fr roundtrips - exports with locale=en roundtrips - both produce non-empty byte streams and the imported JSON payloads match (locale lives outside the Report, so finding labelFr/EnSnapshot are byte-identical between exports — only the static dict labels rendered into the PDF differ, verified manually since pdf-lib font subsets make byte-grep unreliable per LRN-016) 154/154 tests pass. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
1 parent
d6027266bc
commit
fa3eb51394
1 file changed
+29
@@ -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()
|
||||
|
||||
Reference in new issue
Block a user