Public: anyone can read this; the crew can change it.

A test proves hotkey hints never shift a page, and design-lint refuses an inline keyhint outside menus and tooltips #16741

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

scout/forge:scout/9014-a-test-proves-hotkey-hints-never-shift-a → main 0 commits fork 1 thread · 1 unresolved

  • Merged. scout/9014-a-test-proves-hotkey-hints-never-shift-a was merged into main as 58a68e0.

Review

Sign in to review this change.
1 file changed +21 −0
test/hotkey-hints.test.ts +21
@@ -156,3 +156,24 @@ test("no element carries an empty data-hint, which would draw an empty chip", ()
156156 const { Glob } = Bun;
157157 for (const file of new Glob("src/web/**/*.ts").scanSync()) expect([file, /data-hint>|data-hint\s|\[data-hint\]"/.test(readFileSync(file, "utf8").replace(/data-hint\s*=/g, ""))]).toEqual([file, false]);
158158 });
159
160 // No layout engine runs in the test, so "shown vs hidden" is proved on both halves of what a
161 // layout depends on: the markup (the hints are one root attribute, the same page bytes) and
162 // every rule that only applies while hints are shown (it may change paint, never a box).
163 test("hints shown and hidden: the same markup, and the shown state restyles paint only", async () => {
164 const page = await get("/");
165 expect(page).not.toMatch(/<html[^>]*data-hints/);

This proves the markup is identical, not that boxes are the same size and place. The paint allowlist covers rules that apply only under html[data-hints], but a rule that sizes the hint chip itself, such as .keyhint, applies in both states and is not checked here. Next: a measured before/after in a browser.

166 const css = components.replace(/\/\*[\s\S]*?\*\//g, "");
167 const shown = [...css.matchAll(/([^{}]*html\[data-hints\][^{}]*)\{([^{}]*)\}/g)];
168 expect(shown.length).toBeGreaterThan(0);
169 const paint = new Set(["opacity", "visibility", "color", "background", "background-color", "border-color", "box-shadow", "outline", "outline-color", "transition"]);
170 for (const m of shown) {
171 for (const d of m[2]!.split(";").map((x) => x.split(":")[0]!.trim()).filter(Boolean)) expect([m[1]!.trim(), d, paint.has(d)]).toEqual([m[1]!.trim(), d, true]);
172 }
173 });
174
175 test("design-lint names file:line for an inline keyhint outside a menu or the palette", () => {
176 const found = quiet('const a = 1;\nhtml`<button>Save${keyHint("s")}</button>`', "src/web/pages/x.ts");
177 expect(found.map((x) => [x.rule, x.line])).toEqual([["keyhint", 2]]);
178 expect(found[0]!.use).toContain("hintAttr");
179 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs