diff --git a/packages/cli/src/cloud/fontPreflight.test.ts b/packages/cli/src/cloud/fontPreflight.test.ts
new file mode 100644
index 0000000000..e3c3c9a35c
--- /dev/null
+++ b/packages/cli/src/cloud/fontPreflight.test.ts
@@ -0,0 +1,71 @@
+import { mkdtempSync, writeFileSync } from "node:fs";
+import { tmpdir } from "node:os";
+import { join } from "node:path";
+import { describe, expect, it } from "vitest";
+import { describeUnresolvedFonts, embedSystemFonts } from "./fontPreflight.js";
+
+const PAGE = `
x
`;
+
+function setup() {
+ const dir = mkdtempSync(join(tmpdir(), "hf-font-pre-"));
+ writeFileSync(join(dir, "index.html"), PAGE);
+ return { dir, entryPath: "index.html", fileMap: new Map([["index.html", Buffer.from(PAGE)]]) };
+}
+
+const missing = (families: string[]) =>
+ Object.assign(new Error("x"), { code: "FONT_FETCH_FAILED", unresolvedFamilies: families });
+
+describe("embedSystemFonts", () => {
+ it("puts a system font the cloud lacks into the entry page as an inline @font-face", async () => {
+ const s = setup();
+ const calls: Record[] = [];
+ const probes: string[] = [];
+ const left = await embedSystemFonts(s, async (html, options) => {
+ calls.push(options as Record);
+ probes.push(html);
+ if ((options as { allowSystemFontCapture: boolean }).allowSystemFontCapture)
+ return `${html}`;
+ throw missing(["PingFang SC"]);
+ });
+ expect(left).toEqual([]);
+ expect(calls.map((c) => c.allowSystemFontCapture)).toEqual([false, true]);
+ expect(calls.map((c) => c.systemFontsByInnerName)).toEqual([undefined, true]);
+ // The resolver only injects into a full document, so the probe for the capture pass must be one.
+ expect(probes[1]).toContain("");
+ const entry = s.fileMap.get("index.html")!.toString();
+ expect(entry).toContain('