Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions tests/unit/workflow-contract.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -674,4 +674,28 @@ test("Pages is an explicit least-privilege add-on", () => {
assert.ok(existsSync(join(root, ".github", "scripts", "pages-report", assetName)), `missing report script ${assetName}`);
assert.match(pagesWorkflow, new RegExp(`\\.github/scripts/pages-report/${assetName.replace(".", "\\.")}`));
}
});

test("Pages report SVGs use theme colors in light and dark modes", () => {
const report = readFileSync(join(root, ".github", "scripts", "pages-report", "report.mjs"), "utf8");
const darkTheme = report.match(/:root \{([\s\S]*?)\n\}/)?.[1];
const lightTheme = report.match(/@media \(prefers-color-scheme: light\) \{\s*:root \{([\s\S]*?)\n \}/)?.[1];

assert.ok(darkTheme, "missing default dark theme");
assert.ok(lightTheme, "missing light theme");

for (const [name, svgClass] of [
["success", "chart-successful"],
["danger", "chart-failed"],
["cancelled", "chart-cancelled"],
]) {
const variable = new RegExp(`--${name}: #[0-9a-f]{6};`, "i");
assert.match(darkTheme, variable);
assert.match(lightTheme, variable);
assert.match(report, new RegExp(`\\.${svgClass}\\s*\\{\\s*stroke:\\s*var\\(--${name}\\)`));
}

assert.match(report, /<svg class="sidebar-brand-mark"[\s\S]*?fill="currentColor"/);
assert.match(darkTheme, /--fg: #[0-9a-f]{6};/i);
assert.match(lightTheme, /--fg: #[0-9a-f]{6};/i);
});
Loading