test: cover the text editor engine and FreeText flattening

Adds a node-side harness that drives the engine wasm directly, fixtures
that build PDFs in-memory, and cases for font fallback and flattening.
The engine loader now tolerates a runtime without import.meta.resolve so
the suite can load it outside a browser.
This commit is contained in:
alam00000
2026-08-21 12:50:07 +05:30
parent 5392c1be76
commit aee3e0a65a
10 changed files with 850 additions and 24 deletions
+18 -13
View File
@@ -13,7 +13,10 @@ if (typeof globalThis.DOMMatrix === 'undefined') {
globalThis.DOMMatrix = TestDOMMatrix as unknown as typeof DOMMatrix;
}
const hasDom = typeof window !== 'undefined';
afterEach(() => {
if (!hasDom) return;
document.body.innerHTML = '';
document.head.innerHTML = '';
});
@@ -24,19 +27,21 @@ global.ResizeObserver = vi.fn().mockImplementation(() => ({
disconnect: vi.fn(),
}));
Object.defineProperty(window, 'matchMedia', {
writable: true,
value: vi.fn().mockImplementation((query) => ({
matches: false,
media: query,
onchange: null,
addListener: vi.fn(),
removeListener: vi.fn(),
addEventListener: vi.fn(),
removeEventListener: vi.fn(),
dispatchEvent: vi.fn(),
})),
});
if (hasDom) {
Object.defineProperty(window, 'matchMedia', {
writable: true,
value: vi.fn().mockImplementation((query) => ({
matches: false,
media: query,
onchange: null,
addListener: vi.fn(),
removeListener: vi.fn(),
addEventListener: vi.fn(),
removeEventListener: vi.fn(),
dispatchEvent: vi.fn(),
})),
});
}
global.IntersectionObserver = vi.fn().mockImplementation(() => ({
observe: vi.fn(),