2026-09-25 01:52:20 +03:00
|
|
|
/**
|
|
|
|
|
* 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
|
2026-10-11 10:41:30 +03:00
|
|
|
* internal vocabulary. Node 26 exposes the host platform through navigator,
|
|
|
|
|
* so expectations cover Mac glyphs AND Ctrl+/Shift+ elsewhere. Composition
|
|
|
|
|
* is the pin; running on a Mac must not be a test prerequisite.
|
2026-09-25 01:52:20 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
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";
|
2026-09-25 02:26:37 +03:00
|
|
|
import { TOOLTIP_DELAY_MS } from "../components/ui/tooltip.tsx";
|
2026-09-25 01:52:20 +03:00
|
|
|
import { AUTO_UPDATE_HINT } from "../components/settings/settings-dialog.tsx";
|
2026-10-11 10:41:30 +03:00
|
|
|
import { IS_MAC } from "../src/core/keyboard.ts";
|
2026-09-25 01:52:20 +03:00
|
|
|
|
2026-09-25 02:26:37 +03:00
|
|
|
describe("hintText — the parenthesized composition", () => {
|
2026-09-25 01:52:20 +03:00
|
|
|
it("a registry action appends the LIVE binding (override-aware source)", () => {
|
2026-10-11 10:41:30 +03:00
|
|
|
assert.equal(hintText("Dictate", "toggle-dictation"), IS_MAC ? "Dictate (⌘D)" : "Dictate (Ctrl+D)");
|
|
|
|
|
assert.equal(hintText("Settings", "open-settings"), IS_MAC ? "Settings (⌘,)" : "Settings (Ctrl+,)");
|
|
|
|
|
assert.equal(hintText("Search sessions", "sessions-search"), IS_MAC ? "Search sessions (⌘⇧F)" : "Search sessions (Ctrl+Shift+F)");
|
2026-09-25 01:52:20 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("surface-owned keys ride the binding prop (no registry entry)", () => {
|
2026-09-25 02:26:37 +03:00
|
|
|
assert.equal(hintText("Close", undefined, "escape"), "Close (Esc)");
|
|
|
|
|
assert.equal(hintText("Send", undefined, "enter"), "Send (↵)");
|
2026-09-25 01:52:20 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("no shortcut = the label alone, no dangling dash", () => {
|
|
|
|
|
assert.equal(hintText("Home"), "Home");
|
|
|
|
|
assert.equal(hintText("Stop dictation (Esc)"), "Stop dictation (Esc)");
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2026-09-25 02:26:37 +03:00
|
|
|
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);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2026-09-25 01:52:20 +03:00
|
|
|
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");
|
|
|
|
|
});
|
|
|
|
|
});
|