Files
learnharness/tests/tooltip-mechanism.test.tsx
T
amosblomqvist 6b83d3248b Tooltip subtlety round: 500ms rest delay, quiet chip, parens suffixes, drops + trims
Owner round 2026-09-25, over 09c0f6e. The wave's tooltips read as
distracting; this round makes them quiet:

- Delay: TOOLTIP_DELAY_MS = 500 in the primitive — tooltips appear when
  you pause on a control, never in passing (Radix focus-opens stay
  instant by design; keyboard users don't wait).
- Vanish on leave: disableHoverableContent — the chip is un-hoverable,
  so the instant the cursor leaves the trigger it's gone, even mid-move
  onto the chip's own pixels.
- Look: bg-accent (#2a2a2a, the hover-chip tone) instead of the white
  bg-foreground slab; 11px; px-2 py-1; arrow culled (nothing purely
  decorative); text-foreground/85.
- Suffix: parentheses, not em-dash — "Dictate (⌘D)"; the registry
  source unchanged (still override-aware).
- Drops (owner-selected): send square, start square, stats summary —
  the icons/numbers describe themselves.
- Home logo kept but to the RIGHT with its real shortcut "Home (⌘G)"
  (jump-graph routes to /, the same destination).
- Trims: "Model selector (⌘K)", "Thinking level", "Graph costs —
  click for details", "How much of this session isn't mapped yet".
- Added: Import Notes gets "Import notes into the graph" — the one
  button whose destination wasn't obvious.

Pins: TOOLTIP_DELAY_MS=500; hintText parens expectations updated.
Live-verified on :3001 — 508ms hover delay measured, close within 10ms
of pointerout, chip styles probed (rgb(42,42,42), 11px, 4px/8px), arrow
gone, all new labels + sides confirmed, drops carry no tooltip and no
aria-describedby.
2026-09-25 02:26:37 +03:00

68 lines
3.0 KiB
TypeScript

/**
* Tooltip-wave mechanism pins (owner, 2026-09-25): the composition rule —
* icon/pill controls ride the styled Radix tooltip via Hint, the shortcut
* appended as an em-dash suffix off the LIVE registry (a rebind changes
* the suffix); truncation-reveals keep native title=; the copy carries no
* internal vocabulary. Node has no navigator → IS_MAC is false → the mod
* glyph renders "Ctrl+" here; the composition logic is the pin, not the
* platform glyph. (Node 26 ships navigator.platform — on this Mac the real
* ⌘/⇧ glyphs render, so they're pinned as-is.)
*/
import React from "react";
(globalThis as Record<string, unknown>).React = React;
import assert from "node:assert/strict";
import { describe, it } from "node:test";
import { createElement } from "react";
import { renderToStaticMarkup } from "react-dom/server";
import { Hint, hintText } from "../components/ui/hint.tsx";
import { TOOLTIP_DELAY_MS } from "../components/ui/tooltip.tsx";
import { AUTO_UPDATE_HINT } from "../components/settings/settings-dialog.tsx";
describe("hintText — the parenthesized composition", () => {
it("a registry action appends the LIVE binding (override-aware source)", () => {
assert.equal(hintText("Dictate", "toggle-dictation"), "Dictate (⌘D)");
assert.equal(hintText("Settings", "open-settings"), "Settings (⌘,)");
assert.equal(hintText("Search sessions", "sessions-search"), "Search sessions (⌘⇧F)");
});
it("surface-owned keys ride the binding prop (no registry entry)", () => {
assert.equal(hintText("Close", undefined, "escape"), "Close (Esc)");
assert.equal(hintText("Send", undefined, "enter"), "Send (↵)");
});
it("no shortcut = the label alone, no dangling dash", () => {
assert.equal(hintText("Home"), "Home");
assert.equal(hintText("Stop dictation (Esc)"), "Stop dictation (Esc)");
});
});
describe("subtlety round pins (owner 2026-09-25)", () => {
it("the rest delay is 500ms — tooltips appear on pause, never in passing", () => {
assert.equal(TOOLTIP_DELAY_MS, 500);
});
});
describe("spot-pins: the dev-speak cull (owner copy review at merge)", () => {
it("the auto-update hint is honest user language — no stream jargon", () => {
assert.equal(AUTO_UPDATE_HINT, "Automatic updates arrive in an upcoming release");
assert.ok(!AUTO_UPDATE_HINT.includes("wave"), "no stream vocabulary");
});
});
describe("Hint — the mechanism (SSR: the tooltip itself stays closed)", () => {
it("asChild: no wrapper DOM — the control keeps its own testid and classes", () => {
const html = renderToStaticMarkup(
createElement(Hint, {
label: "Dictate",
action: "toggle-dictation",
children: createElement("button", { "data-testid": "dictation-toggle", className: "the-quiet-chrome" }, "Dictate"),
}),
);
assert.match(html, /^<button/, "the trigger IS the button — nothing wraps it");
assert.ok(html.includes('data-testid="dictation-toggle"'));
assert.ok(html.includes("the-quiet-chrome"));
assert.ok(!html.includes("<span"), "no portal content renders while closed");
});
});