docs(docs): RUST.md §10.8 R4.6 record (buffers, memory, parity, E3/E4 three engines, release series, W1, risks); ledger targets filled; compare-exports script; roundtrip raster-failure case; TODO R4.6 closed; memory BDR-062, LRN-063/064, journal

This commit is contained in:
bchanot committed 2026-10-19 02:49:42 +02:00
1 parent cdcdda8e1c
commit 264c5fa3fc
14 files changed
+5230 -38

No files matched your search

+43
View File
@@ -13,6 +13,7 @@ import { dirname, resolve } from 'node:path'
import type { Observation, Report } from '@faunosteo/core-wasm/types'
import { composeHighlightedViewSvg } from '@faunosteo/pdf'
import { exportReportToPdf } from '@/pdf/export'
import { browserRasterizer } from '@/pdf/browserRasterizer'
import { defaultPdfLabels } from '@/pdf/labels'
import { importReportFromPdf, ImportError } from '@/pdf/import'
import { formatDate } from '@/lib/dates'
@@ -305,6 +306,48 @@ describe('PDF content on a two-observation report', () => {
})
})
describe('a raster the browser cannot draw', () => {
it('is a view_raster_failed warning; the export continues without that image', async () => {
const report = minimalReport(sheet, { observations: [fullObservation()] })
const whole = await readDrawing(await exportPdf(report, 'fr'))
const failing = vi.mocked(browserRasterizer)
failing.mockImplementation(async (svg) => {
// The head view's picture is framed on the head's own viewBox.
if (svg.includes('viewBox="60 100 500 380"')) {
throw new Error('canvas lost')
}
const { ONE_PX_PNG } = await import('../helpers/goldens')
return ONE_PX_PNG
})
try {
const { pdf, warnings } = await exportReportToPdf(report, sheet, {
locale: 'fr',
})
expect(warnings).toEqual([
{ kind: 'view_raster_failed', observationId: 'obs-full', viewId: 'head' },
])
const bytes = await bytesOf(pdf)
const { images, texts } = await readDrawing(bytes)
// One image fewer on the observation page (the head view), the logos and
// the main view drawn; the page keeps its texts and the file still
// carries the whole report.
expect(images.filter((i) => i.page === 0)).toHaveLength(
whole.images.filter((i) => i.page === 0).length - 1,
)
expect(texts.map((t) => t.text)).toContain(fr['pdf.view.general']!)
expect(texts.map((t) => t.text)).not.toContain(
`${fr['pdf.view.detail_prefix']}TÊTE (VUE LATÉRALE GAUCHE)`,
)
expect((await readBack(bytes)).report).toEqual(report)
} finally {
failing.mockImplementation(async () => {
const { ONE_PX_PNG } = await import('../helpers/goldens')
return ONE_PX_PNG
})
}
})
})
describe('attachment rejection', () => {
async function pdfWith(name: string, payload: unknown): Promise<Uint8Array> {
const doc = await PDFDocument.create()