Files
dahyeon 664af15255 feat: refresh the home page and separate match event types
Add an inhouse hero, Hall of Fame, rankings, and event-specific schedules. Carry the event type through the API and admin tools, and improve results and player history displays.
2026-11-10 22:13:55 +09:00

99 lines
2.7 KiB
TypeScript

import assert from "node:assert/strict";
import { readFile } from "node:fs/promises";
import test from "node:test";
const stylesheet = await readFile(
new URL("../src/index.css", import.meta.url),
"utf8",
);
const BRAND_COLORS = {
coral: "oklch(70.8008% .234375 24)",
ink: "#22252e",
gold: "#f2b01e",
leaf: "#2f9e58",
} as const;
test("keeps literal colors in the primitive palette", () => {
const palette = stylesheet.match(/@theme static\s*\{[^}]*\}/)?.[0];
assert.ok(palette, "the primitive palette must be in @theme static");
for (const [name, value] of Object.entries(BRAND_COLORS)) {
assert.match(
palette,
new RegExp(`--color-brand-${name}: ${escapeRegExp(value)};`),
);
assert.equal(palette.split(`${value};`).length - 1, 1);
}
assert.doesNotMatch(
stylesheet.replace(palette, ""),
/#[\da-f]{3,8}\b|\b(?:rgba?|hsla?|oklch|oklab)\(/i,
);
});
test("keeps the layer order that lets LOLYMPUS tokens override Astryx", () => {
assert.match(
stylesheet,
/@layer reset, theme, base, astryx-base, astryx-theme, lolympus, components, utilities;/,
);
assert.doesNotMatch(stylesheet, /daisyui/);
});
test("derives Astryx action colors from the brand coral", () => {
assert.match(
stylesheet,
/--color-accent: var\(--color-brand-coral\);/,
);
assert.match(
stylesheet,
/--color-text-accent: light-dark\(\s*color-mix\(in oklab, var\(--color-brand-coral\) \d+%, var\(--color-palette-black\)\),\s*color-mix\(in oklab, var\(--color-brand-coral\) \d+%, var\(--color-palette-white\)\)\s*\);/,
);
});
test("separates fill and text colors for primary and result roles", () => {
const mappings = [
["--color-primary", "--color-accent"],
["--text-color-primary", "--color-text-accent"],
["--color-win", "--lts-win-fill"],
["--text-color-win", "--lts-win"],
["--color-loss", "--lts-loss-fill"],
["--text-color-loss", "--lts-loss"],
["--color-bracket-winner", "--color-text-accent"],
] as const;
for (const [utilityToken, roleToken] of mappings) {
assert.match(
stylesheet,
new RegExp(
`${escapeRegExp(utilityToken)}: var\\(${escapeRegExp(roleToken)}\\);`,
),
);
}
});
test("defines every role color for both light and dark", () => {
const roleTokens = [
"--lts-ink",
"--lts-win",
"--lts-win-tint",
"--lts-loss",
"--lts-loss-tint",
"--lts-gold",
"--lts-leaf",
"--lts-sunken",
];
for (const token of roleTokens) {
assert.match(
stylesheet,
new RegExp(`${escapeRegExp(token)}: light-dark\\(`),
`${token} should use light-dark()`,
);
}
});
function escapeRegExp(value: string): string {
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
}