@blackbelt-technology/pi-dashboard-client-utils 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,215 +0,0 @@
1
- import { describe, it, expect, afterEach, vi } from "vitest";
2
- import { render, cleanup, fireEvent } from "@testing-library/react";
3
- import React from "react";
4
- import { mdiAlert } from "@mdi/js";
5
- import { Dialog } from "../Dialog.js";
6
-
7
- afterEach(() => cleanup());
8
-
9
- describe("Dialog", () => {
10
- it("renders nothing when closed", () => {
11
- const { baseElement } = render(
12
- <Dialog open={false} onClose={() => {}} testId="d">
13
- <p>hi</p>
14
- </Dialog>,
15
- );
16
- expect(baseElement.querySelector("[data-testid='d']")).toBeNull();
17
- });
18
-
19
- it("renders at document.body via portal when open", () => {
20
- const { baseElement } = render(
21
- <Dialog open onClose={() => {}} testId="d">
22
- <p>body</p>
23
- </Dialog>,
24
- );
25
- const container = baseElement.querySelector("[data-testid='d']");
26
- expect(container).toBeTruthy();
27
- expect(container!.getAttribute("role")).toBe("dialog");
28
- expect(container!.getAttribute("aria-modal")).toBe("true");
29
- });
30
-
31
- it("calls onClose on Esc", () => {
32
- const onClose = vi.fn();
33
- render(
34
- <Dialog open onClose={onClose} testId="d">
35
- <p>x</p>
36
- </Dialog>,
37
- );
38
- // Escape now routes through the shared escape-stack (document-bubble listener).
39
- fireEvent.keyDown(document, { key: "Escape" });
40
- expect(onClose).toHaveBeenCalledTimes(1);
41
- });
42
-
43
- it("calls onClose on overlay click", () => {
44
- const onClose = vi.fn();
45
- const { baseElement } = render(
46
- <Dialog open onClose={onClose} testId="d">
47
- <p>x</p>
48
- </Dialog>,
49
- );
50
- fireEvent.click(baseElement.querySelector("[data-testid='d-overlay']")!);
51
- expect(onClose).toHaveBeenCalledTimes(1);
52
- });
53
-
54
- it("does not call onClose when clicking inside the container", () => {
55
- const onClose = vi.fn();
56
- const { getByText } = render(
57
- <Dialog open onClose={onClose} testId="d">
58
- <p>inside</p>
59
- </Dialog>,
60
- );
61
- fireEvent.click(getByText("inside"));
62
- expect(onClose).not.toHaveBeenCalled();
63
- });
64
-
65
- it("sets aria-labelledby when title is given", () => {
66
- const { baseElement } = render(
67
- <Dialog open onClose={() => {}} title="Hello" testId="d">
68
- <p>x</p>
69
- </Dialog>,
70
- );
71
- const container = baseElement.querySelector("[data-testid='d']")!;
72
- const labelledBy = container.getAttribute("aria-labelledby");
73
- expect(labelledBy).toBeTruthy();
74
- expect(document.getElementById(labelledBy!)!.textContent).toBe("Hello");
75
- });
76
-
77
- it("omits aria-labelledby and header without title/icon", () => {
78
- const { baseElement } = render(
79
- <Dialog open onClose={() => {}} testId="d">
80
- <p>x</p>
81
- </Dialog>,
82
- );
83
- const container = baseElement.querySelector("[data-testid='d']")!;
84
- expect(container.getAttribute("aria-labelledby")).toBeNull();
85
- expect(container.querySelector("h3")).toBeNull();
86
- });
87
-
88
- it("renders header icon + title", () => {
89
- const { baseElement } = render(
90
- <Dialog open onClose={() => {}} title="T" icon={mdiAlert} testId="d">
91
- <p>x</p>
92
- </Dialog>,
93
- );
94
- const container = baseElement.querySelector("[data-testid='d']")!;
95
- expect(container.querySelector("h3")!.textContent).toBe("T");
96
- expect(container.querySelector("svg")).toBeTruthy();
97
- });
98
-
99
- it("applies overlay tint and z-index chrome", () => {
100
- const { baseElement } = render(
101
- <Dialog open onClose={() => {}} testId="d">
102
- <p>x</p>
103
- </Dialog>,
104
- );
105
- const overlay = baseElement.querySelector("[data-testid='d-overlay']")!;
106
- expect(overlay.className).toContain("bg-black/60");
107
- const root = overlay.parentElement!;
108
- expect(root.className).toContain("z-[60]");
109
- const container = baseElement.querySelector("[data-testid='d']")!;
110
- expect(container.className).toContain("bg-[var(--bg-primary)]");
111
- expect(container.className).toContain("border-[var(--border-primary)]");
112
- });
113
-
114
- it.each([
115
- ["sm", "max-w-sm"],
116
- ["md", "max-w-md"],
117
- ["lg", "max-w-lg"],
118
- ["full", "max-w-[95vw]"],
119
- ] as const)("applies %s size class %s", (size, cls) => {
120
- const { baseElement } = render(
121
- <Dialog open onClose={() => {}} size={size} testId="d">
122
- <p>x</p>
123
- </Dialog>,
124
- );
125
- expect(baseElement.querySelector("[data-testid='d']")!.className).toContain(cls);
126
- });
127
-
128
- it.each([
129
- ["sm", "max-h-[80vh]"],
130
- ["md", "max-h-[80vh]"],
131
- ["lg", "max-h-[80vh]"],
132
- ["full", "max-h-[92vh]"],
133
- ] as const)("applies %s height cap %s", (size, cls) => {
134
- const { baseElement } = render(
135
- <Dialog open onClose={() => {}} size={size} testId="d">
136
- <p>x</p>
137
- </Dialog>,
138
- );
139
- expect(baseElement.querySelector("[data-testid='d']")!.className).toContain(cls);
140
- });
141
-
142
- it("flush drops padding and clips overflow (edge-to-edge body)", () => {
143
- const { baseElement } = render(
144
- <Dialog open onClose={() => {}} flush testId="d">
145
- <p>x</p>
146
- </Dialog>,
147
- );
148
- const cls = baseElement.querySelector("[data-testid='d']")!.className;
149
- expect(cls).toContain("overflow-hidden");
150
- expect(cls).not.toContain("p-5");
151
- });
152
-
153
- it("non-flush keeps padding + scroll", () => {
154
- const { baseElement } = render(
155
- <Dialog open onClose={() => {}} testId="d">
156
- <p>x</p>
157
- </Dialog>,
158
- );
159
- const cls = baseElement.querySelector("[data-testid='d']")!.className;
160
- expect(cls).toContain("p-5");
161
- expect(cls).toContain("overflow-y-auto");
162
- });
163
-
164
- it("defaults to max-w-md", () => {
165
- const { baseElement } = render(
166
- <Dialog open onClose={() => {}} testId="d">
167
- <p>x</p>
168
- </Dialog>,
169
- );
170
- expect(baseElement.querySelector("[data-testid='d']")!.className).toContain(
171
- "max-w-md",
172
- );
173
- });
174
-
175
- it("maps action intents to classes and derives testIds", () => {
176
- const onAction = vi.fn();
177
- const onCancel = vi.fn();
178
- const { baseElement } = render(
179
- <Dialog open onClose={() => {}} testId="d">
180
- <Dialog.Footer>
181
- <Dialog.Cancel onClick={onCancel} testId="d-cancel" />
182
- <Dialog.Action onClick={onAction} intent="danger" testId="d-action">
183
- Go
184
- </Dialog.Action>
185
- </Dialog.Footer>
186
- </Dialog>,
187
- );
188
- const action = baseElement.querySelector("[data-testid='d-action']")!;
189
- expect(action.className).toContain("bg-red-600");
190
- const cancel = baseElement.querySelector("[data-testid='d-cancel']")!;
191
- fireEvent.click(cancel);
192
- fireEvent.click(action);
193
- expect(onCancel).toHaveBeenCalledTimes(1);
194
- expect(onAction).toHaveBeenCalledTimes(1);
195
- });
196
-
197
- it("primary intent uses accent, neutral uses border", () => {
198
- const { baseElement } = render(
199
- <Dialog open onClose={() => {}} testId="d">
200
- <Dialog.Action onClick={() => {}} testId="p">
201
- P
202
- </Dialog.Action>
203
- <Dialog.Action onClick={() => {}} intent="neutral" testId="n">
204
- N
205
- </Dialog.Action>
206
- </Dialog>,
207
- );
208
- expect(baseElement.querySelector("[data-testid='p']")!.className).toContain(
209
- "bg-[var(--accent-primary)]",
210
- );
211
- expect(baseElement.querySelector("[data-testid='n']")!.className).toContain(
212
- "border-[var(--border-primary)]",
213
- );
214
- });
215
- });
@@ -1,58 +0,0 @@
1
- import { describe, it, expect, afterEach } from "vitest";
2
- import { render, cleanup } from "@testing-library/react";
3
- import React from "react";
4
- import { DialogPortal } from "../DialogPortal.js";
5
-
6
- afterEach(() => cleanup());
7
-
8
- describe("DialogPortal", () => {
9
- it("renders children at document.body", () => {
10
- const { baseElement } = render(
11
- <div id="app-root">
12
- <DialogPortal>
13
- <div data-testid="dialog-content">Hello</div>
14
- </DialogPortal>
15
- </div>
16
- );
17
- // Child should be in body, not inside #app-root
18
- const content = baseElement.querySelector("[data-testid='dialog-content']");
19
- expect(content).toBeTruthy();
20
- expect(content!.textContent).toBe("Hello");
21
- // Should NOT be inside #app-root
22
- const appRoot = baseElement.querySelector("#app-root");
23
- expect(appRoot!.querySelector("[data-testid='dialog-content']")).toBeNull();
24
- });
25
-
26
- it("sets document.body overflow to hidden on mount", () => {
27
- document.body.style.overflow = "";
28
- render(
29
- <DialogPortal>
30
- <div>Dialog</div>
31
- </DialogPortal>
32
- );
33
- expect(document.body.style.overflow).toBe("hidden");
34
- });
35
-
36
- it("restores document.body overflow on unmount", () => {
37
- document.body.style.overflow = "auto";
38
- const { unmount } = render(
39
- <DialogPortal>
40
- <div>Dialog</div>
41
- </DialogPortal>
42
- );
43
- expect(document.body.style.overflow).toBe("hidden");
44
- unmount();
45
- expect(document.body.style.overflow).toBe("auto");
46
- });
47
-
48
- it("restores empty overflow on unmount when originally empty", () => {
49
- document.body.style.overflow = "";
50
- const { unmount } = render(
51
- <DialogPortal>
52
- <div>Dialog</div>
53
- </DialogPortal>
54
- );
55
- unmount();
56
- expect(document.body.style.overflow).toBe("");
57
- });
58
- });
@@ -1,44 +0,0 @@
1
- import { cleanup, fireEvent, render } from "@testing-library/react";
2
- import React from "react";
3
- import { afterEach, describe, expect, it, vi } from "vitest";
4
- import { EmptyState } from "../EmptyState.js";
5
-
6
- afterEach(() => cleanup());
7
-
8
- describe("EmptyState", () => {
9
- it("renders title, body, and a single primary CTA", () => {
10
- const onClick = vi.fn();
11
- const { getByText, getAllByRole, container } = render(
12
- <EmptyState
13
- title="No sessions yet"
14
- body="Spawn a pi session to see it here."
15
- action={{ label: "Spawn session", onClick }}
16
- />,
17
- );
18
- expect(getByText("No sessions yet")).toBeDefined();
19
- expect(getByText("Spawn a pi session to see it here.")).toBeDefined();
20
- const primaries = container.querySelectorAll('[data-empty-state-action="primary"]');
21
- expect(primaries).toHaveLength(1);
22
- fireEvent.click(getAllByRole("button")[0]);
23
- expect(onClick).toHaveBeenCalledTimes(1);
24
- });
25
-
26
- it("allows at most one primary action (single `action` prop)", () => {
27
- const { container } = render(
28
- <EmptyState
29
- title="Empty"
30
- action={{ label: "Primary", onClick: () => {} }}
31
- secondaryAction={{ label: "Escape", onClick: () => {} }}
32
- />,
33
- );
34
- // The contract: exactly one primary, at most one secondary — never >1 primary.
35
- expect(container.querySelectorAll('[data-empty-state-action="primary"]')).toHaveLength(1);
36
- expect(container.querySelectorAll('[data-empty-state-action="secondary"]')).toHaveLength(1);
37
- });
38
-
39
- it("renders without any actions", () => {
40
- const { container, getByText } = render(<EmptyState title="Nothing here" />);
41
- expect(getByText("Nothing here")).toBeDefined();
42
- expect(container.querySelectorAll("button")).toHaveLength(0);
43
- });
44
- });
@@ -1,51 +0,0 @@
1
- import { cleanup, render } from "@testing-library/react";
2
- import React from "react";
3
- import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
4
- import { Skeleton } from "../Skeleton.js";
5
-
6
- afterEach(() => cleanup());
7
-
8
- function mockReducedMotion(reduce: boolean) {
9
- vi.stubGlobal(
10
- "matchMedia",
11
- (query: string) =>
12
- ({
13
- matches: query.includes("prefers-reduced-motion") ? reduce : false,
14
- media: query,
15
- addEventListener: () => {},
16
- removeEventListener: () => {},
17
- addListener: () => {},
18
- removeListener: () => {},
19
- dispatchEvent: () => false,
20
- onchange: null,
21
- }) as unknown as MediaQueryList,
22
- );
23
- // jsdom attaches matchMedia to window; mirror the stub there too.
24
- (window as unknown as { matchMedia: typeof window.matchMedia }).matchMedia =
25
- globalThis.matchMedia;
26
- }
27
-
28
- describe("Skeleton", () => {
29
- beforeEach(() => mockReducedMotion(false));
30
-
31
- it("renders `count` shaped placeholder rows", () => {
32
- const { container } = render(<Skeleton variant="bubble" count={3} />);
33
- expect(container.querySelectorAll("[data-skeleton-item]")).toHaveLength(3);
34
- expect(container.querySelector("[data-skeleton='bubble']")).toBeTruthy();
35
- });
36
-
37
- it("animates (shimmer) when reduced motion is off", () => {
38
- mockReducedMotion(false);
39
- const { container } = render(<Skeleton variant="row" />);
40
- const item = container.querySelector("[data-skeleton-item]");
41
- expect(item?.className).toContain("animate-pulse");
42
- });
43
-
44
- it("renders static (no shimmer) under prefers-reduced-motion: reduce", () => {
45
- mockReducedMotion(true);
46
- const { container } = render(<Skeleton variant="row" />);
47
- expect(container.querySelector("[data-skeleton][data-static='true']")).toBeTruthy();
48
- const item = container.querySelector("[data-skeleton-item]");
49
- expect(item?.className).not.toContain("animate-pulse");
50
- });
51
- });
@@ -1,63 +0,0 @@
1
- import React from "react";
2
- import { describe, it, expect, afterEach } from "vitest";
3
- import { render, cleanup } from "@testing-library/react";
4
- import { StatusPill } from "../StatusPill.js";
5
-
6
- afterEach(() => cleanup());
7
-
8
- describe("StatusPill", () => {
9
- it("renders the text", () => {
10
- const { getByText } = render(<StatusPill state="running" text="Working" />);
11
- expect(getByText("Working")).toBeDefined();
12
- });
13
-
14
- it("sets data-status-pill attribute to state", () => {
15
- const { container } = render(<StatusPill state="error" text="Failed" />);
16
- expect(container.firstChild).toHaveProperty("dataset");
17
- const el = container.querySelector("[data-status-pill]");
18
- expect(el?.getAttribute("data-status-pill")).toBe("error");
19
- });
20
-
21
- it("each state renders with state-specific styling", () => {
22
- const states: Array<"running" | "success" | "error" | "info" | "warn" | "muted"> = [
23
- "running",
24
- "success",
25
- "error",
26
- "info",
27
- "warn",
28
- "muted",
29
- ];
30
- for (const state of states) {
31
- const { container, unmount } = render(<StatusPill state={state} text={state} />);
32
- const el = container.querySelector(`[data-status-pill="${state}"]`);
33
- expect(el).toBeTruthy();
34
- unmount();
35
- }
36
- });
37
-
38
- it("tooltip is set from `tooltip` prop", () => {
39
- const { container } = render(
40
- <StatusPill state="running" text="X" tooltip="Currently running" />,
41
- );
42
- expect(container.firstChild?.parentElement?.getAttribute("title") ?? container.querySelector("[title]")?.getAttribute("title")).toBe("Currently running");
43
- });
44
-
45
- // Post static-conversion (change: shrink-client-index-chunk): mdi[key] is a
46
- // synchronous lookup, so the icon path renders immediately with no useEffect.
47
- it("renders the icon <path> synchronously for a valid mdi key (test-plan #S3)", () => {
48
- const { container } = render(
49
- <StatusPill state="running" text="Working" icon="mdiRefresh" />,
50
- );
51
- const p = container.querySelector("svg path");
52
- expect(p).toBeTruthy();
53
- expect(p?.getAttribute("d") ?? "").not.toBe("");
54
- });
55
-
56
- it("renders no icon and does not throw for an unknown mdi key (test-plan #S3)", () => {
57
- const { container } = render(
58
- <StatusPill state="error" text="Failed" icon="mdiNotAReal" />,
59
- );
60
- expect(container.querySelector("svg path")).toBeNull();
61
- expect(container.querySelector("[data-status-pill]")?.textContent).toContain("Failed");
62
- });
63
- });
@@ -1,166 +0,0 @@
1
- import { describe, it, expect, afterEach, vi } from "vitest";
2
- import { createElement, StrictMode } from "react";
3
- import { render, cleanup } from "@testing-library/react";
4
- import {
5
- registerEscapeLayer,
6
- unregisterEscapeLayer,
7
- useEscapeDismiss,
8
- __resetEscapeStack,
9
- } from "../escape-stack.js";
10
-
11
- afterEach(() => {
12
- cleanup();
13
- __resetEscapeStack();
14
- });
15
-
16
- function pressEscape(init: KeyboardEventInit = {}): KeyboardEvent {
17
- const ev = new KeyboardEvent("keydown", {
18
- key: "Escape",
19
- bubbles: true,
20
- cancelable: true,
21
- ...init,
22
- });
23
- document.dispatchEvent(ev);
24
- return ev;
25
- }
26
-
27
- describe("escape-stack — topmost-only dispatch", () => {
28
- it("E1 topmost-only: only the top layer's onEscape fires", () => {
29
- const a = vi.fn();
30
- const b = vi.fn();
31
- registerEscapeLayer("A", a);
32
- registerEscapeLayer("B", b);
33
- pressEscape();
34
- expect(b).toHaveBeenCalledTimes(1);
35
- expect(a).not.toHaveBeenCalled();
36
- });
37
-
38
- it("E2 successive peel: three Escapes dismiss C, B, A in order", () => {
39
- const order: string[] = [];
40
- registerEscapeLayer("A", () => {
41
- order.push("A");
42
- unregisterEscapeLayer("A");
43
- });
44
- registerEscapeLayer("B", () => {
45
- order.push("B");
46
- unregisterEscapeLayer("B");
47
- });
48
- registerEscapeLayer("C", () => {
49
- order.push("C");
50
- unregisterEscapeLayer("C");
51
- });
52
- pressEscape();
53
- pressEscape();
54
- pressEscape();
55
- expect(order).toEqual(["C", "B", "A"]);
56
- });
57
-
58
- it("E3 lone layer: single layer still dismisses", () => {
59
- const a = vi.fn();
60
- registerEscapeLayer("A", a);
61
- pressEscape();
62
- expect(a).toHaveBeenCalledTimes(1);
63
- });
64
- });
65
-
66
- describe("escape-stack — lifecycle", () => {
67
- it("E4 order-independent unregister: removing A by id leaves B live", () => {
68
- const a = vi.fn();
69
- const b = vi.fn();
70
- registerEscapeLayer("A", a);
71
- registerEscapeLayer("B", b);
72
- unregisterEscapeLayer("A");
73
- pressEscape();
74
- expect(b).toHaveBeenCalledTimes(1);
75
- expect(a).not.toHaveBeenCalled();
76
- });
77
-
78
- it("E11 latest handler without re-registration: re-register same id uses cb2", () => {
79
- const cb1 = vi.fn();
80
- const cb2 = vi.fn();
81
- registerEscapeLayer("A", cb1);
82
- registerEscapeLayer("A", cb2); // same id → refresh, not a second entry
83
- pressEscape();
84
- expect(cb2).toHaveBeenCalledTimes(1);
85
- expect(cb1).not.toHaveBeenCalled();
86
- });
87
- });
88
-
89
- describe("escape-stack — consume + passthrough", () => {
90
- it("E5 empty passthrough: no layers → event not consumed, window spy fires", () => {
91
- const spy = vi.fn();
92
- window.addEventListener("keydown", spy);
93
- const ev = pressEscape();
94
- expect(spy).toHaveBeenCalledTimes(1);
95
- expect(ev.defaultPrevented).toBe(false);
96
- window.removeEventListener("keydown", spy);
97
- });
98
-
99
- it("E6 consume blocks window: layer dismisses, window spy does not fire", () => {
100
- const a = vi.fn();
101
- const spy = vi.fn();
102
- window.addEventListener("keydown", spy);
103
- registerEscapeLayer("A", a);
104
- const ev = pressEscape();
105
- expect(a).toHaveBeenCalledTimes(1);
106
- expect(spy).not.toHaveBeenCalled();
107
- expect(ev.defaultPrevented).toBe(true);
108
- window.removeEventListener("keydown", spy);
109
- });
110
- });
111
-
112
- describe("escape-stack — guards", () => {
113
- it("E7 key-repeat guard: repeat dismisses nothing, non-repeat dismisses B", () => {
114
- const a = vi.fn();
115
- const b = vi.fn();
116
- registerEscapeLayer("A", a);
117
- registerEscapeLayer("B", b);
118
- pressEscape({ repeat: true });
119
- expect(a).not.toHaveBeenCalled();
120
- expect(b).not.toHaveBeenCalled();
121
- pressEscape({ repeat: false });
122
- expect(b).toHaveBeenCalledTimes(1);
123
- expect(a).not.toHaveBeenCalled();
124
- });
125
-
126
- it("E8 defaultPrevented opt-out: layer stays, onEscape not called", () => {
127
- const a = vi.fn();
128
- registerEscapeLayer("A", a);
129
- // A focused input already handled Escape (defaultPrevented) before it bubbles
130
- // to document — simulate via a capture-phase listener that preventDefaults.
131
- const pre = (e: KeyboardEvent) => e.preventDefault();
132
- document.addEventListener("keydown", pre, { capture: true });
133
- pressEscape();
134
- expect(a).not.toHaveBeenCalled();
135
- document.removeEventListener("keydown", pre, { capture: true });
136
- // A is still registered → a clean Escape now dismisses it.
137
- pressEscape();
138
- expect(a).toHaveBeenCalledTimes(1);
139
- });
140
- });
141
-
142
- describe("escape-stack — hook lifecycle", () => {
143
- it("E9 StrictMode id stability: one entry, fires once, no leak/drop", () => {
144
- const onEscape = vi.fn();
145
- function Layer() {
146
- useEscapeDismiss(true, onEscape);
147
- return null;
148
- }
149
- render(createElement(StrictMode, null, createElement(Layer)));
150
- pressEscape();
151
- expect(onEscape).toHaveBeenCalledTimes(1);
152
- });
153
- });
154
-
155
- describe("escape-stack — attach-once / never-detach", () => {
156
- it("E10 attaches document keydown once, no duplicate across empty→refill", () => {
157
- __resetEscapeStack(); // clean module state: detached
158
- const addSpy = vi.spyOn(document, "addEventListener");
159
- registerEscapeLayer("A", vi.fn()); // first registration attaches
160
- unregisterEscapeLayer("A"); // stack empty, listener stays attached
161
- registerEscapeLayer("B", vi.fn()); // already attached → no new listener
162
- const keydownAdds = addSpy.mock.calls.filter((c) => c[0] === "keydown");
163
- expect(keydownAdds).toHaveLength(1);
164
- addSpy.mockRestore();
165
- });
166
- });
@@ -1,34 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import {
3
- type StatusKind,
4
- statusAriaLabel,
5
- statusPresentation,
6
- } from "../statusPresentation.js";
7
-
8
- describe("statusPresentation", () => {
9
- const kinds: StatusKind[] = ["done", "current", "todo", "error"];
10
-
11
- it("provides a non-color glyph indicator for every state", () => {
12
- for (const kind of kinds) {
13
- expect(statusPresentation(kind).glyph.trim().length).toBeGreaterThan(0);
14
- }
15
- });
16
-
17
- it("renders a distinct glyph per state (distinguishable without color)", () => {
18
- const glyphs = kinds.map((k) => statusPresentation(k).glyph);
19
- expect(new Set(glyphs).size).toBe(kinds.length);
20
- });
21
-
22
- it("done is distinguishable from todo by glyph alone", () => {
23
- expect(statusPresentation("done").glyph).not.toBe(statusPresentation("todo").glyph);
24
- });
25
-
26
- it("maps each state to a semantic --status / token var", () => {
27
- expect(statusPresentation("done").tokenVar).toContain("var(--");
28
- expect(statusPresentation("error").tokenVar).toContain("var(--status-error)");
29
- });
30
-
31
- it("statusAriaLabel names the item and its state", () => {
32
- expect(statusAriaLabel("Proposal", "done")).toBe("Proposal, done");
33
- });
34
- });