Files
fusion/packages/dashboard/app/__tests__/index-html-theme-link.test.ts
Fusion (runfusion.ai) 007fb43da0 test(FN-4916): complete Step 3 — add theme link regression coverage
Fusion-Task-Id: FN-4916
Fusion-Task-Lineage: 80b56c97-04c6-4cd4-bb83-e3ef8faaa4ee
2026-05-17 10:37:54 -07:00

34 lines
1.4 KiB
TypeScript

import { readFileSync } from "node:fs";
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import { describe, expect, it } from "vitest";
const PACKAGE_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "../..");
describe("index.html theme-data boot contract", () => {
const indexHtml = readFileSync(resolve(PACKAGE_ROOT, "app/index.html"), "utf8");
const script = indexHtml.match(/<script>[\s\S]*?<\/script>/)?.[0] ?? "";
it("includes a static theme-data stylesheet link", () => {
expect(indexHtml).toMatch(/<link\s+[^>]*(id=["']theme-data["'][^>]*href=["']\/theme-data\.css["']|href=["']\/theme-data\.css["'][^>]*id=["']theme-data["'])[^>]*>/i);
});
it("does not dynamically create or append the theme-data link", () => {
expect(script).not.toMatch(/document\.createElement\(("|')link\1\)/);
expect(script).not.toContain("appendChild(");
});
it("still sets theme attributes and font size", () => {
expect(script).toContain("setAttribute('data-theme'");
expect(script).toContain("setAttribute('data-color-theme'");
expect(script).toContain("style.fontSize");
});
it("keeps themeDataUrl resolution branches", () => {
expect(script).toContain("http://");
expect(script).toContain("https://");
expect(script).toContain("file://");
expect(script).toContain("themeDataUrl = '/theme-data.css'");
});
});