[test] Playwright e2e: PDF render-decode correctness across image codecs (CCITT/JBIG2/JPEG/JPX + multi-page + text-only) #714
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
Follow-up to #708 / PR #713. That fix configured pdf.js 5.x
wasmUrlso CCITT/JBIG2/JPEG2000 scans stop rendering blank, and serves the wasm from/pdfjs-wasm/.In #713 we attempted an in-browser vitest behavioral test (render a committed fixture with the real pdf.js loader, assert the canvas is non-blank). It was green locally but flaky in CI — the pdf.js worker could not fetch
/pdfjs-wasm/in the CI Chromium container, so the canvas stayed blank. That test was removed in favour of deterministic guards:getDocumentis called with a non-nullwasmUrlending in/;frontend/scripts/assert-pdfjs-wasm.mjs(postbuild) assertsjbig2.wasm/openjpeg.wasmship intobuild/client/pdfjs-wasm/;node buildserves/pdfjs-wasm/jbig2.wasm→ 200application/wasm.These cover the regression deterministically, but no automated test asserts a real page actually paints. Sara (QA) and Elicit (Requirements) flagged this gap on #713; this issue tracks closing it properly.
Why e2e, not vitest browser mode
The vitest browser server's serving of
/pdfjs-wasm/(and pdf.js worker behaviour) is environment-fragile in CI. A Playwright e2e test runs against a real built server (npm run build && npm run preview, or the adapter-nodenode build), where/pdfjs-wasm/is served frombuild/client/exactly as in production — the reliable place to assert real rendering.frontend/e2e/already exists with Playwright configured ande2e/fixtures/*.pdf.Scope
Add a Playwright e2e spec that, against a built+served frontend, renders PDFs through the document viewer and asserts the page canvas is non-blank (sample the canvas via
page.evaluate+getImageData, count non-background pixels > threshold — mirror the pixel oracle from the removed vitest test).Codec / structure matrix (one fixture per row)
jbig2.wasmmodule.jbig2.wasmpath; needs a real JBIG2 fixture (nojbig2encwas available when #713 was done — source a small public-domain sample or generate one in CI).openjpeg.wasm); assert if a fixture can be produced, else explicitly skip with a note.pdfunite) — both pages and the page between render.e2e/fixtures/minimal.pdfalready qualifies) — renders, guards over-scoping.JBig2 failed to initialize/wasmUrlwarnings appear in the page console.Fixtures
-compress Group4for CCITT,-compress JPEGfor DCT;pdfuniteto build the mixed-codec doc). Do not fetch from staging at test time.PdfVieweragainst a fixture URL (prefer the former to avoid test-only routes).Acceptance criteria
wasmUrlis removed fromgetDocument.wasmUrl/JBig2 failed to initializeconsole warnings on affected docs.frontend/e2e/Playwright setup; documented in the test how to regenerate fixtures.Out of scope
standardFontDataUrl/iccUrl(still no affected document found).References
frontend/src/lib/document/viewer/usePdfRenderer.svelte.ts(WASM_URL),frontend/scripts/assert-pdfjs-wasm.mjs,docs/adr/028-pdfjs-wasm-decoders-and-csp-constraint.md