import test from "node:test"; import assert from "node:assert/strict"; import { readFile } from "node:fs/promises"; import postcss from "postcss"; import tailwindcss from "tailwindcss"; test("compiled application tokens are usable without native CSS scope support", async () => { const source = await readFile(new URL("../src/index.css", import.meta.url), "utf8"); const config = (await import("../postcss.config.js")).default; const plugins = Array.isArray(config.plugins) ? config.plugins : [tailwindcss()]; const result = await postcss(plugins).process(source, { from: "src/index.css" }); let tokens = 0; result.root.walkDecls("--background", declaration => { tokens++; let parent = declaration.parent; while (parent.type !== "root") { assert.notEqual(parent.name, "scope", "native @scope hides the theme on unsupported browsers"); assert.notEqual(parent.name, "thoth-base", "the build must expand the scoped reset"); parent = parent.parent; } }); assert.ok(tokens >= 2, "light and dark root tokens must be emitted"); let gutter = false; result.root.walkDecls("--thot-shell-gutter", () => { gutter = true; }); assert.ok(gutter, "full shell gutter must survive Tailwind content pruning"); let nestedGridTheme = false; result.root.walkDecls("--ag-background-color", declaration => { const selector = declaration.parent.selector; if (selector.includes(".thot-database-grid") && selector.includes(".ag-theme-alpine")) nestedGridTheme = true; }); assert.ok(nestedGridTheme, "AG Grid nested theme roots must receive shell colors directly"); result.root.walkDecls("box-sizing", declaration => { assert.match(declaration.parent.selector, /#root|data-base-ui-portal/, "reset must not change the host portal"); }); });