import { describe, it } from "vitest"; import { makeItems, prefsFor, PAGE_SIZE_IDS, renderFixture, type FixtureSpec } from "./harness"; import { checkRendered } from "./harness.check"; import { TEMPLATES } from "./registry"; /** The standalone templates sweep in a file of their own, so vitest runs the two sweeps in parallel and the suite's wall time stays put. */ export const STANDALONE_SWEEP = ["monolith", "cobalt-stripe", "marble", "highlighter"]; /** 1..45 generated rows on A4 and Letter for the templates `pick` selects, each render through the harness checks. */ export function describeSweep(pick: (id: string) => boolean): void { describe("template harness: item-count sweep", () => { for (const template of Object.values(TEMPLATES).filter((t) => pick(t.id))) { for (const size of PAGE_SIZE_IDS) { it(`${template.id}: 1..45 items on ${size}`, async () => { const prefs = prefsFor(size, { templateId: template.id }); for (let count = 1; count <= 45; count++) { const spec: FixtureSpec = { name: `sweep-${count}`, items: makeItems(count, true), invoice: { notes: count % 3 === 0 ? "Payment due within 30 days.\nThank you." : "" }, signature: count % 2 === 0 }; const r = await renderFixture(spec, prefs); checkRendered(r, `${template.id}/items=${count}/${size} (${r.result.pages} pages)`); } }); } } }); }