/** * The dashboard palette, checked. * * ponytail: a script rather than a suite, like `color.check.ts` beside it — * the frontend's only runner is Playwright and picking a palette slot does not * need a browser: * * cd frontend && bun run src/components/Dashboard/palette.check.ts * * Two properties, and it is worth being clear which is which. * * The one that must never move is **inertness**: a palette a dashboard wrote * down is drawn exactly as written, so shipping this mechanism could not * change the meaning of a single stored document. That is what made the * default safe to move afterwards. * * The one that is free to move is the **default** itself — where a chart that * named no palette lands. It started as a one-hue ramp in order, was spread * across that ramp, and is now the categorical `--chart-1…8` in order. That is * a design decision, pinned here so it changes on purpose rather than by * accident. */ import assert from "node:assert/strict" import { CHART_SLOTS, MAX_SERIES, NO_PALETTE, slotsFor, } from "@/components/Common/UplotChart" // --- the default: the shared palette, in order ---------------------------- assert.deepEqual( CHART_SLOTS, ["1", "2", "3", "4", "5", "6", "7", "8"], "eight slots, named as --chart-1…8 is", ) for (const stored of [undefined, NO_PALETTE]) { assert.deepEqual( slotsFor(stored), CHART_SLOTS, "naming no palette, however it is stored, takes the slots in order", ) } assert.ok( MAX_SERIES <= CHART_SLOTS.length, "a full chart never repeats a colour", ) // --- inertness: a named palette is drawn as written ----------------------- // A dashboard names colours now (`ui/core/theme.ts`), and a chart draws them // as they were written: not re-spread, not widened, not reordered. A chart // with more lines than it names cycles through them. const NAMED = ["#2a9d8f", "#e9c46a"] assert.deepEqual(slotsFor(NAMED), NAMED, "a named palette is drawn as written") console.log("palette: ok")