b673363351
Adds a working Dark/Light toggle (next to the language switcher, same row
as EN/VI) and re-themes the whole dashboard, not just the handful of
components that already used semantic tokens.
- Tailwind darkMode:"class" + CSS-variable color tokens (client/src/index.css,
tailwind.config.js): surface.0-5, border/border-light, accent/accent-hover,
fg.primary/secondary/muted, status.success/danger/warning. One class flip
on <html> re-themes everything — no per-element dark: variant pairs.
- useTheme() hook: localStorage-persisted, defaults to dark, no
prefers-color-scheme fallback (client/src/hooks/useTheme.ts).
- Mechanical, table-driven migration (scripts/migrate-color-tokens.mjs,
scripts/tokenize-status-colors.mjs, scripts/darken-status-colors.mjs) of
every raw neutral/gray/slate + emerald/red/amber Tailwind utility across
client/src onto the new tokens, so every badge/button/component pulls the
same shade per status/role instead of each picking its own.
- Palette values are the literal Radix Colors (radix-ui.com/colors) scale
constants — slate/blue/green/red/amber steps 1-12 — adopted after three
rounds of hand-picked values that kept overshooting (flat, then too dark,
then glaring); see docs/superpowers/specs/2026-07-31-color-redesign-
dark-light-mode-design.md for the full history and role mapping.
- PipelineMap: done/current/failed/passed-no-evidence/detected share one
visual language (border + text + translucent wash of the same status
color); `current` alone stays a solid accent fill, the one state that
gets to look bolder ("you are here").
- LaneCard: removed the stage/kind/auto-stage chips that duplicated the
Workspace lane-detail header already showing them.
Categorical/decorative hues (violet, indigo, cyan, teal, sky, rose, pink,
orange, yellow, and blue where it plays a role-coloring part e.g. message
bubbles) are deliberately out of scope — collapsing those onto shared
tokens would erase the distinction between different kinds of thing, not
a status.
108 lines
5.1 KiB
TypeScript
108 lines
5.1 KiB
TypeScript
/**
|
|
* @file Rendering tests for the lane pipeline map: every node renders with a
|
|
* state-specific class so "done", "current" and "passed without evidence" stay
|
|
* visually distinguishable, and the amber state is never conflated with done.
|
|
* @author Nguyễn Ngọc Trí Vĩ <vinnt@smartgift.vn>
|
|
*/
|
|
|
|
import { describe, it, expect } from "vitest";
|
|
import { render, screen } from "@testing-library/react";
|
|
import PipelineMap from "../PipelineMap";
|
|
import type { LaneNode } from "../../../lib/types";
|
|
|
|
const nodes: LaneNode[] = [
|
|
{ id: "plan", label: "plan", icon: "🧭", gate: false, state: "done" },
|
|
{ id: "implement", label: "implement", icon: "🛠", gate: false, state: "passed-no-evidence" },
|
|
{ id: "review", label: "review", icon: "👀", gate: true, state: "current" },
|
|
{ id: "gate", label: "gate", icon: "🚦", gate: true, state: "failed" },
|
|
{ id: "done", label: "done", icon: "✅", gate: false, state: "pending" },
|
|
];
|
|
|
|
describe("PipelineMap", () => {
|
|
it("renders one element per node, labelled by state", () => {
|
|
render(<PipelineMap nodes={nodes} />);
|
|
expect(screen.getAllByTestId(/^pipeline-node-/)).toHaveLength(5);
|
|
expect(screen.getByTestId("pipeline-node-plan")).toHaveAttribute("data-state", "done");
|
|
expect(screen.getByTestId("pipeline-node-implement")).toHaveAttribute(
|
|
"data-state",
|
|
"passed-no-evidence"
|
|
);
|
|
expect(screen.getByTestId("pipeline-node-review")).toHaveAttribute("data-state", "current");
|
|
expect(screen.getByTestId("pipeline-node-gate")).toHaveAttribute("data-state", "failed");
|
|
expect(screen.getByTestId("pipeline-node-done")).toHaveAttribute("data-state", "pending");
|
|
});
|
|
|
|
it("gives amber nodes a different class from done nodes", () => {
|
|
render(<PipelineMap nodes={nodes} />);
|
|
const done = screen.getByTestId("pipeline-node-plan").className;
|
|
const amber = screen.getByTestId("pipeline-node-implement").className;
|
|
// The done node must contain the success status token and the amber node
|
|
// must contain the warning status token.
|
|
expect(done).toContain("status-success");
|
|
expect(amber).toContain("status-warning");
|
|
expect(done).not.toEqual(amber);
|
|
});
|
|
|
|
it("renders nothing but an empty hint when there are no nodes", () => {
|
|
render(<PipelineMap nodes={[]} />);
|
|
expect(screen.queryAllByTestId(/^pipeline-node-/)).toHaveLength(0);
|
|
});
|
|
|
|
describe("detected (inferred) nodes", () => {
|
|
const detectedNodes: LaneNode[] = [
|
|
{ id: "intake", label: "intake", icon: "📥", gate: false, state: "pending", detected: true },
|
|
{ id: "tests", label: "tests", icon: "🧪", gate: false, state: "pending", detected: true },
|
|
{ id: "plan", label: "plan", icon: "🧭", gate: false, state: "done" },
|
|
{
|
|
id: "implement",
|
|
label: "implement",
|
|
icon: "🛠",
|
|
gate: false,
|
|
state: "passed-no-evidence",
|
|
},
|
|
];
|
|
|
|
it("marks a detected node with data-detected and a dashed-border class token", () => {
|
|
render(<PipelineMap nodes={detectedNodes} detectedSignal="npm run test:server" />);
|
|
const node = screen.getByTestId("pipeline-node-tests");
|
|
expect(node).toHaveAttribute("data-detected", "true");
|
|
expect(node.className).toContain("border-dashed");
|
|
});
|
|
|
|
it("gives a detected node a class different from both done and plain passed-no-evidence", () => {
|
|
render(<PipelineMap nodes={detectedNodes} detectedSignal="npm run test:server" />);
|
|
const detected = screen.getByTestId("pipeline-node-tests").className;
|
|
const done = screen.getByTestId("pipeline-node-plan").className;
|
|
const amber = screen.getByTestId("pipeline-node-implement").className;
|
|
expect(detected).not.toEqual(done);
|
|
expect(detected).not.toEqual(amber);
|
|
});
|
|
|
|
it("names the signal in the detected node's tooltip", () => {
|
|
render(<PipelineMap nodes={detectedNodes} detectedSignal="npm run test:server" />);
|
|
const node = screen.getByTestId("pipeline-node-tests");
|
|
expect(node).toHaveAttribute("title", "tests ← npm run test:server");
|
|
});
|
|
|
|
it("PREMISE GUARD: detected wins over state=done — dashed amber, never emerald", () => {
|
|
// The server never emits this pair, and this is the guard that says the
|
|
// component would not paint an inference green even if it did. Asserting
|
|
// against a fixture whose detected nodes are already `pending` would only
|
|
// re-assert the fixture.
|
|
const impossible: LaneNode[] = [
|
|
{ id: "tests", label: "tests", icon: "🧪", gate: false, state: "done", detected: true },
|
|
];
|
|
render(<PipelineMap nodes={impossible} detectedSignal="npm run test:server" />);
|
|
const node = screen.getByTestId("pipeline-node-tests");
|
|
expect(node.className).toContain("border-dashed");
|
|
expect(node.className).toContain("status-warning");
|
|
expect(node.className).not.toContain("status-success");
|
|
});
|
|
|
|
it("non-detected nodes carry no data-detected attribute", () => {
|
|
render(<PipelineMap nodes={detectedNodes} detectedSignal="npm run test:server" />);
|
|
expect(screen.getByTestId("pipeline-node-plan")).not.toHaveAttribute("data-detected");
|
|
});
|
|
});
|
|
});
|