diff --git a/packages/cli/src/commands/snapshot-fonts.test.ts b/packages/cli/src/commands/snapshot-fonts.test.ts new file mode 100644 index 0000000000..cd50f8d411 --- /dev/null +++ b/packages/cli/src/commands/snapshot-fonts.test.ts @@ -0,0 +1,27 @@ +import { describe, expect, it, vi } from "vitest"; + +const mocks = vi.hoisted(() => ({ + bundleToSingleHtml: vi.fn(async () => "
bundled"), + injectDeterministicFontFaces: vi.fn(async (html: string) => `${html}\n`), +})); + +vi.mock("@hyperframes/core/compiler", () => ({ + bundleToSingleHtml: mocks.bundleToSingleHtml, +})); +vi.mock("@hyperframes/producer", () => ({ + injectDeterministicFontFaces: mocks.injectDeterministicFontFaces, +})); + +import { prepareSnapshotHtml } from "./snapshot.js"; + +describe("prepareSnapshotHtml", () => { + it("injects the same deterministic font faces used by render", async () => { + const html = await prepareSnapshotHtml("/project"); + + expect(mocks.bundleToSingleHtml).toHaveBeenCalledWith("/project"); + expect(mocks.injectDeterministicFontFaces).toHaveBeenCalledWith( + "bundled", + ); + expect(html).toContain(""); + }); +}); diff --git a/packages/cli/src/commands/snapshot.ts b/packages/cli/src/commands/snapshot.ts index e1f34f9615..14164ebe6d 100644 --- a/packages/cli/src/commands/snapshot.ts +++ b/packages/cli/src/commands/snapshot.ts @@ -180,6 +180,15 @@ export function computeSnapshotTimes( * Render key frames from a composition as PNG screenshots. * The agent can Read these to verify its output visually. */ +export async function prepareSnapshotHtml(projectDir: string): Promise