Add pagination blocks, renderCore, layout audit and react-pdf quirk tests

TableGuard, BottomSpacer, FirstPageHeader and PageChrome implement the
verified pagination rules; renderCore returns bytes, a normalised layout
tree, audit issues and a layout fingerprint. auditLayout detects overlaps,
ink overflow, truncation, header-only pages and split blocks. Quirk tests
pin the react-pdf behaviours the design depends on, and a child-process
test pins the page-level absolute Svg hang.
This commit is contained in:
2026-10-04 05:05:51 +05:30
parent 40aa3e05d9
commit 8d4f8e666b
24 changed files with 2187 additions and 5 deletions
+20
View File
@@ -0,0 +1,20 @@
import { describe, expect, it } from "vitest";
import { chromeHeight } from "./metrics";
describe("chromeHeight", () => {
it("is ceil((ascent - descent + lineGap) / upm * size) + 1 from the manifest", () => {
// Plex: 1025 + 275 = 1300 / 1000 = 1.3 em
expect(chromeHeight({ face: "IBM Plex Sans", weight: 400, size: 8 })).toBe(Math.ceil(10.4) + 1);
expect(chromeHeight("footer")).toBe(Math.ceil(9.75) + 1);
expect(chromeHeight({ face: "IBM Plex Sans", weight: 400, size: 10 })).toBe(14);
});
it("covers the line react-pdf draws for render-prop text", () => {
// A 8 pt Plex line is 10.4 pt tall (verified in the layout tree); the reserve must be at least that.
expect(chromeHeight({ face: "IBM Plex Sans", weight: 400, size: 8 })).toBeGreaterThanOrEqual(10.4);
});
it("falls back across weights and styles instead of failing", () => {
expect(chromeHeight({ face: "IBM Plex Sans", weight: 600, italic: true, size: 8 })).toBe(12);
});
});