first commit
All checks were successful
Verify and publish Calio container / build-and-push (push) Successful in 1m4s

This commit is contained in:
Elijah 2026-10-20 19:04:12 -07:00
commit 6fc0a01c56
51 changed files with 11319 additions and 0 deletions

56
tests/theme.test.js Normal file
View file

@ -0,0 +1,56 @@
import test from "node:test";
import assert from "node:assert/strict";
import {
accentPalette,
accentPresets,
contrastText,
DEFAULT_ACCENT,
} from "../shared/theme.js";
import { recordSchema, defaultSettings } from "../shared/domain.js";
test("custom accents have matching derived colors in light and dark modes", () => {
const light = accentPalette("#d780a2", false);
const dark = accentPalette("#d780a2", true);
assert.equal(light["--accent"], "#d780a2");
assert.equal(dark["--accent"], "#d780a2");
assert.notEqual(light["--accent-soft"], dark["--accent-soft"]);
for (const color of Object.values(dark))
assert.match(color, /^#[a-f0-9]{6}$/i);
assert.equal(accentPalette("invalid", true)["--accent"], DEFAULT_ACCENT);
});
test("button text stays readable on extreme and preset accent colors", () => {
assert.equal(contrastText("#ffffff"), "#000000");
assert.equal(contrastText("#000000"), "#ffffff");
for (const color of [
...accentPresets.map((v) => v.color),
"#808080",
"#ff0000",
"#00ff00",
"#0000ff",
]) {
const palette = accentPalette(color, true);
assert.ok(["#000000", "#ffffff"].includes(palette["--on-accent"]));
}
});
test("accent preferences validate and older settings without an accent still load", () => {
const record = {
id: "settings",
type: "settings",
deleted: false,
updatedAt: new Date().toISOString(),
data: { ...defaultSettings, accentColor: "#12abcd" },
};
assert.equal(recordSchema.safeParse(record).success, true);
assert.equal(
recordSchema.safeParse({
...record,
data: { ...record.data, accentColor: "red;display:none" },
}).success,
false,
);
const { accentColor, ...older } = defaultSettings;
assert.equal(
recordSchema.safeParse({ ...record, data: older }).success,
true,
);
});