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

j/k, enter, esc and ? on settings/devices, with test/keys-<page>.test.ts #10808

Merged opened this

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

Merged

This adds `test/keys-devices.test.ts` and changes nothing in `src/`, because `/settings/devices` already had the keys on its section list. The new test passes, `bun scripts/gate.ts` and `bun x tsc --noEmit` are clean, and I ran no other tests.

shipped production is serving it deploy 951be3d

opened this

This adds test/keys-devices.test.ts and changes nothing in src/, because /settings/devices already had the keys on its section list. The new test passes, bun scripts/gate.ts and bun x tsc --noEmit are clean, and I ran no other tests.

What the page already had. The settings sidebar, drawn by settingsLayout, makes every settings section a data-nav row. On /settings/devices, j/k already walk those sections and Enter already opens one. ? and the field guard come from the shared shell, so no new JS was needed. Only the test was missing.

What the test drives. It renders the real page as an admin with a declared printer, then runs the shell script over the markup in happy-dom:

  • Focus: j steps away from the current section (Devices) and k steps back.
  • Enter: it clicks the focused section's link and records where it came from.
  • Field guard: j and Enter do nothing inside an input.
  • Esc: the page itself carries data-nav rows, so Esc has nowhere to return to and does nothing. I asserted that rather than a return.
  • ?: it is handled and prevented.

What I left out. I did not make the printer cards rows. A card holds only forms (Remove, Grant, Set limit, Revoke) and has no page to open. A data-nav row there would take j/k focus and then do nothing on Enter. The test asserts the cards carry no data-nav, so this choice is pinned.

To try it: bun test test/keys-devices.test.ts.

🤖 Generated with Claude Code

Closes #10797

commented

This adds test/keys-devices.test.ts and changes nothing in src/, because /settings/devices already had the keys on its section list. The new test passes, bun scripts/gate.ts and bun x tsc --noEmit are clean, and I ran no other tests.

What the page already had. The settings sidebar, drawn by settingsLayout, makes every settings section a data-nav row. On /settings/devices, j/k already walk those sections and Enter already opens one. ? and the field guard come from the shared shell, so no new JS was needed. Only the test was missing.

What the test drives. It renders the real page as an admin with a declared printer, then runs the shell script over the markup in happy-dom:

  • Focus: j steps away from the current section (Devices) and k steps back.
  • Enter: it clicks the focused section's link and records where it came from.
  • Field guard: j and Enter do nothing inside an input.
  • Esc: the page itself carries data-nav rows, so Esc has nowhere to return to and does nothing. I asserted that rather than a return.
  • ?: it is handled and prevented.

What I left out. I did not make the printer cards rows. A card holds only forms (Remove, Grant, Set limit, Revoke) and has no page to open. A data-nav row there would take j/k focus and then do nothing on Enter. The test asserts the cards carry no data-nav, so this choice is pinned.

To try it: bun test test/keys-devices.test.ts.

🤖 Generated with Claude Code

Approved

Test-only pull; /settings/devices already had j/k/Enter/Esc/? through the settings sidebar rows, and the test pins that honestly (including that Esc does nothing on a page that is itself a list, and that printer cards are not rows). No src, README or dependency change; the preview answers (303 to sign-in without a session, as expected). Two things I would do next: (1) in the first test, assert indexOf("class=\"list setting-list\"") >= 0 before slicing, so a markup rename cannot make the not-a-row check pass vacuously (slice(-1) would); (2) pair the Esc case with one where nav-from names a different list, to pin that Esc does return there from this page.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs