murashit_codex-panel/tests/styles.test.ts

37 lines
1.5 KiB
TypeScript
Raw Normal View History

2026-05-25 14:06:25 +00:00
import { readFileSync } from "node:fs";
import path from "node:path";
2026-05-25 14:06:25 +00:00
import { describe, expect, it } from "vitest";
const sourceDir = path.join("src", "styles");
2026-05-31 11:26:11 +00:00
const sourceFiles = JSON.parse(readFileSync(path.join(sourceDir, "order.json"), "utf8")) as string[];
const styles = `${sourceFiles.map((file) => readFileSync(path.join(sourceDir, file), "utf8").trimEnd()).join("\n\n")}\n`;
2026-05-25 14:06:25 +00:00
2026-07-04 10:05:14 +00:00
function ruleBody(selector: string): string {
const escapedSelector = selector.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
return new RegExp(`(?:^|\\n)${escapedSelector} \\{(?<body>[^}]+)\\}`).exec(styles)?.groups?.["body"] ?? "";
}
describe("panel CSS boundaries", () => {
2026-05-25 14:06:25 +00:00
it("defines design tokens on every standalone UI root", () => {
const tokenScopeEnd = styles.indexOf(" {");
expect(tokenScopeEnd).toBeGreaterThan(0);
const tokenScope = styles.slice(0, tokenScopeEnd);
2026-05-25 14:06:25 +00:00
expect(tokenScope).toContain(".codex-panel");
2026-06-27 12:49:26 +00:00
expect(tokenScope).toContain(".codex-panel-turn-diff");
2026-05-25 14:06:25 +00:00
expect(tokenScope).toContain(".codex-panel-settings");
expect(tokenScope).toContain(".codex-panel-threads");
expect(tokenScope).toContain(".codex-panel-selection-rewrite");
});
});
2026-05-28 01:29:21 +00:00
2026-07-04 10:05:14 +00:00
describe("panel CSS layout invariants", () => {
2026-07-08 21:52:19 +00:00
it("lets the thread stream scroll inside the shell grid", () => {
const threadStream = ruleBody(".codex-panel__thread-stream");
2026-07-08 21:52:19 +00:00
expect(threadStream).toContain("overflow-y: auto");
expect(threadStream).not.toMatch(/^\s+height:/m);
});
2026-05-28 01:29:21 +00:00
});