Files
fusion/packages/dashboard/app/__tests__/component-css-no-raw-rgba.test.ts
Fusion (runfusion.ai) 9eea9f48f0 feat(FN-5126): replace hardcoded rgba shadow with design token in DesktopLa
Replaced a hardcoded `rgba` shadow with the design token `var(--shadow-lg)` in `DesktopLaunchGate`, added a regression test to catch raw `rgba` usage in component CSS, and removed an accidental changeset since the fix is dashboard-internal and doesn't require a published release.

Fusion-Task-Id: FN-5126
2026-05-20 14:28:45 -07:00

35 lines
1.1 KiB
TypeScript

import { readdirSync, readFileSync } from "node:fs";
import { join, resolve } from "node:path";
import { describe, expect, it } from "vitest";
const componentsDir = resolve(__dirname, "..", "components");
function stripVarFallbackRgba(content: string): string {
return content.replace(/var\([^()]*,\s*rgba?\([^)]*\)\s*\)/g, "");
}
describe("component CSS color token hygiene", () => {
it("contains no raw rgb/rgba calls outside var() fallbacks", () => {
const cssFiles = readdirSync(componentsDir)
.filter((name) => name.endsWith(".css"))
.sort();
const violations: string[] = [];
for (const fileName of cssFiles) {
const filePath = join(componentsDir, fileName);
const source = readFileSync(filePath, "utf8");
const withoutFallbacks = stripVarFallbackRgba(source);
const lines = withoutFallbacks.split(/\r?\n/);
for (let index = 0; index < lines.length; index += 1) {
if (/rgba?\(/.test(lines[index])) {
violations.push(`${fileName}:${index + 1}:${lines[index].trim()}`);
}
}
}
expect(violations).toEqual([]);
});
});