Public: anyone can read this; the crew can change it.
The subscriptions list is keyboard-first: j/k move between rows, enter opens one #10649
Check · Review · Land · Live done — Landed and live in production.
mason/forge:mason/10432-the-subscriptions-list-is-keyboard-first → main 2 commits fork
2 files
changed +52
−0
src/web/pages/subscriptions.ts +1
| @@ -159,6 +159,7 @@ export function subscriptionsPage(ctx: Ctx): Response { | ||
| 159 | 159 | ? undefined |
| 160 | 160 | : getUserById(ctx.app.db, s.createdBy); |
| 161 | 161 | return row({ |
| 162 | nav: true, | |
| 162 | 163 | lead: icon("key"), |
| 163 | 164 | title: html`${s.name} |
| 164 | 165 | ${when(rests, () => |
test/keys-subscriptions.test.ts added +51
| @@ -0,0 +1,51 @@ | ||
| 1 | /** The subscriptions list joins the shell's j/k row traversal: one data-nav per account row. */ | |
| 2 | import { afterAll, beforeAll, expect, test } from "bun:test"; | |
| 3 | import { mkdtemp, rm } from "node:fs/promises"; | |
| 4 | import { tmpdir } from "node:os"; | |
| 5 | import { join } from "node:path"; | |
| 6 | import { createApp, type App } from "../src/app.ts"; | |
| 7 | import { addSubscription } from "../src/core/subscriptions.ts"; | |
| 8 | import { createUser } from "../src/core/users.ts"; | |
| 9 | import { serve, type Servers } from "../src/http/server.ts"; | |
| 10 | ||
| 11 | let dataDir: string; | |
| 12 | let app: App; | |
| 13 | let servers: Servers; | |
| 14 | let cookie = ""; | |
| 15 | ||
| 16 | beforeAll(async () => { | |
| 17 | dataDir = await mkdtemp(join(tmpdir(), "forge-keys-subs-")); | |
| 18 | app = createApp({ dataDir, port: 0 }); | |
| 19 | servers = await serve(app); | |
| 20 | const made = await createUser(app.db, { | |
| 21 | origin: "seed", trusted: true, username: "alice", email: "[email protected]", | |
| 22 | password: "a-good-passphrase", adminIfFirst: true, | |
| 23 | }); | |
| 24 | if (!made.ok) throw new Error(made.error); | |
| 25 | const res = await fetch(`${servers.url}/signin`, { | |
| 26 | method: "POST", | |
| 27 | redirect: "manual", | |
| 28 | headers: { "content-type": "application/x-www-form-urlencoded", origin: servers.url }, | |
| 29 | body: new URLSearchParams({ username: "alice", password: "a-good-passphrase" }), | |
| 30 | }); | |
| 31 | cookie = (res.headers.get("set-cookie") ?? "").split(";")[0] ?? ""; | |
| 32 | }); | |
| 33 | ||
| 34 | afterAll(async () => { | |
| 35 | await servers.stop(); | |
| 36 | app.close(); | |
| 37 | await rm(dataDir, { recursive: true, force: true }); | |
| 38 | }); | |
| 39 | ||
| 40 | const get = async () => | |
| 41 | (await fetch(`${servers.url}/settings/subscriptions`, { headers: { cookie } })).text(); | |
| 42 | const NAV = /class="row"[^>]*data-nav tabindex="-1"/g; | |
| 43 | ||
| 44 | test("each account row is one data-nav row", async () => { | |
| 45 | const before = (await get()).match(NAV)?.length ?? 0; | |
| 46 | for (const name of ["work", "home"]) | |
| 47 | expect(addSubscription(app.db, dataDir, { name, token: `sk-ant-${name}-token-0123456789` }).ok).toBe(true); | |
| 48 | const text = await get(); | |
| 49 | expect(text).toContain("work"); | |
| 50 | expect(text.match(NAV)?.length).toBe(before + 2); | |
| 51 | }); |