fix(cli): bundle preview font localization (#2449)

This commit is contained in:
Miguel Ángel
2026-07-14 18:02:51 -04:00
committed by GitHub
parent 0b3dfb3f84
commit 9ce44b6603
2 changed files with 23 additions and 10 deletions
@@ -1,9 +1,19 @@
import { afterEach, describe, expect, it, vi } from "vitest";
const producerMocks = vi.hoisted(() => ({
loadProducer: vi.fn(async () => ({
injectDeterministicFontFaces: async (html: string) => `${html}<!--bundled-producer-->`,
})),
}));
vi.mock("@hyperframes/core/compiler", () => ({
bundleToSingleHtml: vi.fn(async () => "<html><body>bundled</body></html>"),
}));
vi.mock("./producer.js", () => ({
loadProducer: producerMocks.loadProducer,
}));
import {
__resetFontLocalizationWarningsForTests,
bundleWithLocalizedFonts,
@@ -31,6 +41,12 @@ describe("bundleWithLocalizedFonts (call-site integration)", () => {
});
describe("localizeWithProducer", () => {
it("loads the injector through the producer module bundled with the CLI", async () => {
const out = await localizeWithProducer("<html></html>");
expect(producerMocks.loadProducer).toHaveBeenCalledOnce();
expect(out).toBe("<html></html><!--bundled-producer-->");
});
it("embeds fonts when the injector is available", async () => {
const inject = vi.fn(async (html: string) => `${html}<!--fonts-->`);
const warn = vi.fn();