diff --git a/packages/cli/src/utils/bundleWithLocalizedFonts.test.ts b/packages/cli/src/utils/bundleWithLocalizedFonts.test.ts index fc0d59c08..957f432c7 100644 --- a/packages/cli/src/utils/bundleWithLocalizedFonts.test.ts +++ b/packages/cli/src/utils/bundleWithLocalizedFonts.test.ts @@ -4,11 +4,6 @@ vi.mock("@hyperframes/core/compiler", () => ({ bundleToSingleHtml: vi.fn(async () => "
bundled"), })); -const injectMock = vi.fn(async (html: string) => html.replace("bundled", "bundled+fonts")); -vi.mock("@hyperframes/producer", () => ({ - injectDeterministicFontFaces: (html: string) => injectMock(html), -})); - import { bundleWithLocalizedFonts } from "./bundleWithLocalizedFonts.js"; afterEach(() => { @@ -16,17 +11,19 @@ afterEach(() => { }); describe("bundleWithLocalizedFonts", () => { - it("localizes fonts on top of the plain bundle", async () => { - const html = await bundleWithLocalizedFonts("/project"); - expect(injectMock).toHaveBeenCalledOnce(); + it("runs the injected font localizer over the plain bundle", async () => { + const localize = vi.fn(async (html: string) => html.replace("bundled", "bundled+fonts")); + const html = await bundleWithLocalizedFonts("/project", localize); + expect(localize).toHaveBeenCalledOnce(); + expect(localize).toHaveBeenCalledWith("bundled"); expect(html).toBe("bundled+fonts"); }); - it("falls open to the plain bundle when font localization throws", async () => { - injectMock.mockRejectedValueOnce(new Error("offline / fetch layer unavailable")); - const html = await bundleWithLocalizedFonts("/project"); - // Never worse than a plain bundleToSingleHtml — the remote still - // loads at capture time as before. - expect(html).toBe("bundled"); + it("returns the localizer's output verbatim (localization is the last step)", async () => { + const html = await bundleWithLocalizedFonts( + "/project", + async () => "embedded-face", + ); + expect(html).toBe("embedded-face"); }); }); diff --git a/packages/cli/src/utils/bundleWithLocalizedFonts.ts b/packages/cli/src/utils/bundleWithLocalizedFonts.ts index 901a2ff5e..fa0bc339b 100644 --- a/packages/cli/src/utils/bundleWithLocalizedFonts.ts +++ b/packages/cli/src/utils/bundleWithLocalizedFonts.ts @@ -16,16 +16,37 @@ * underlying injector leaves the HTML unchanged, so this never makes a bundle * worse than plain `bundleToSingleHtml`. */ -export async function bundleWithLocalizedFonts(projectDir: string): Promise