Watch
0
0
Fork
You've already forked hyperhive
0
hyperhive/frontend/packages/swarm-ui/test/hover-affordances.test.mjs
iris bcb432caf4 swarm-ui: three press targets show a hover state
The selection bar's link buttons, an expandable card's head and a toast all take
the pointer cursor and gave no other sign. The links underline on hover and
focus, the head tints its title, and the toast darkens its border.
2026-11-28 09:47:13 +01:00

31 lines
1.4 KiB
JavaScript

// Things that answer a press show it before it. Run by `npm test`: a control
// that takes the pointer cursor needs a hover state, or nothing says it is one.
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { test } from "node:test";
const read = (rel) => readFileSync(new URL(rel, import.meta.url), "utf8");
test("the selection bar's link buttons underline on hover and focus", () => {
assert.match(
read("../src/pages/agents/SelectionBar.css"),
/\.agents-selection-link:hover:not\(:disabled\),\s*\.agents-selection-link:focus-visible\s*\{\s*text-decoration:\s*underline/,
);
});
test("an expandable card's head tints its title on hover, unless static", () => {
assert.match(
read("../src/ui/expandable-card/ExpandableCard.css"),
/\.ui-expandable-head:not\(\.ui-expandable-head-static\):hover \.ui-expandable-title\s*\{\s*color:\s*var\(--purple\)/,
);
});
test("a toast, which dismisses on a click, darkens the sides that carry no tone", () => {
const css = read("../src/ui/toast/Toast.css");
const rule = /\.ui-toast:hover\s*\{([^}]*)\}/.exec(css);
assert.ok(rule, "no hover rule");
assert.match(rule[1], /border-top-color/);
assert.match(rule[1], /border-bottom-color/);
// The shorthand would repaint the left bar, which is the toast's tone.
assert.doesNotMatch(rule[1], /border-color|border-left/);
});