Summary
Fix the unit/UI test environment so pdfjs-dist and react-pdf dependencies do not crash the suite in jsdom.
Why
The current test environment fails with DOMMatrix is not defined, preventing the suite from validating actual logic changes.
Current evidence
npm run test:unit and UI tests fail before assertions run.
src/services/PDFService.ts and src/components/reader/ReaderViewport.tsx import PDF dependencies directly in test contexts.
Scope
- Add the required polyfills or targeted mocks for
DOMMatrix and related PDF primitives.
- Isolate rendering-heavy dependencies so store/service tests do not load browser-only code unnecessarily.
- Document the chosen strategy in test setup.
- Keep the fix minimal and maintainable.
Acceptance criteria
- Unit and UI test suites start reliably in jsdom.
- PDF-related modules no longer crash test initialization.
- The setup is documented and reproducible on CI.
Out of scope
- Replacing
react-pdf or pdfjs-dist entirely.
Summary
Fix the unit/UI test environment so
pdfjs-distandreact-pdfdependencies do not crash the suite in jsdom.Why
The current test environment fails with
DOMMatrix is not defined, preventing the suite from validating actual logic changes.Current evidence
npm run test:unitand UI tests fail before assertions run.src/services/PDFService.tsandsrc/components/reader/ReaderViewport.tsximport PDF dependencies directly in test contexts.Scope
DOMMatrixand related PDF primitives.Acceptance criteria
Out of scope
react-pdforpdfjs-distentirely.