Public: anyone can read this; the crew can change it.
The webhooks list is keyboard-first: j/k move between rows, enter opens one #10478
scout/forge:scout/10429-the-webhooks-list-is-keyboard-first-j-k → main 3 commits fork
3 files
changed +64
−1
scripts/unreached-allow.json −1
| @@ -15,7 +15,6 @@ | ||
| 15 | 15 | "src/flow/review_rounds.ts", |
| 16 | 16 | "src/flow/shared_red.ts", |
| 17 | 17 | "src/flow/stale_fold.ts", |
| 18 | "src/kernel/why_now.ts", | |
| 19 | 18 | "src/spawn/pod.ts", |
| 20 | 19 | "src/tui/gallery.ts", |
| 21 | 20 | "src/tui/ui/qr.ts", |
src/web/pages/hooks.ts +1
| @@ -84,6 +84,7 @@ export function hooksPage(ctx: Ctx): Response { | ||
| 84 | 84 | ${hooks.map((hook) => { |
| 85 | 85 | const deliveries = recent.get(hook.id) ?? []; |
| 86 | 86 | return row({ |
| 87 | nav: true, | |
| 87 | 88 | title: html`<span class="mono">${hook.url}</span>`, |
| 88 | 89 | titleAttr: hook.url, |
| 89 | 90 | meta: html`<span class="mono">${hook.kinds}</span> · ${dot(hook.active ? "success" : "attn")}${hook.active |
test/keys-hooks.test.ts added +63
| @@ -0,0 +1,63 @@ | ||
| 1 | /** The webhooks list joins the shell's j/k row traversal: one data-nav per hook row, none on the empty page. */ | |
| 2 | import { afterAll, beforeAll, expect, test } from "bun:test"; | |
| 3 | import { mkdtempSync, rmSync } from "node:fs"; | |
| 4 | import { tmpdir } from "node:os"; | |
| 5 | import { join } from "node:path"; | |
| 6 | import { createRepo } from "../src/actions/repos.ts"; | |
| 7 | import { createApp, type App } from "../src/app.ts"; | |
| 8 | import { createUser } from "../src/core/users.ts"; | |
| 9 | import { createWebhook } from "../src/core/webhooks.ts"; | |
| 10 | import { serve, type Servers } from "../src/http/server.ts"; | |
| 11 | import { quietLogs } from "./helpers/globals.ts"; | |
| 12 | ||
| 13 | quietLogs(); | |
| 14 | ||
| 15 | let root = ""; | |
| 16 | let app: App; | |
| 17 | let servers: Servers; | |
| 18 | let cookie = ""; | |
| 19 | let repoId = ""; | |
| 20 | ||
| 21 | const NAV = /class="row"[^>]*data-nav tabindex="-1"/g; | |
| 22 | const page = async (): Promise<string> => | |
| 23 | (await fetch(`${servers.url}/alice/a/settings/hooks`, { headers: { cookie } })).text(); | |
| 24 | ||
| 25 | beforeAll(async () => { | |
| 26 | root = mkdtempSync(join(tmpdir(), "forge-keys-hooks-")); | |
| 27 | app = createApp({ dataDir: root, port: 0 }); | |
| 28 | const u = await createUser(app.db, { | |
| 29 | origin: "seed", trusted: true, username: "alice", email: "[email protected]", | |
| 30 | password: "a-good-passphrase", adminIfFirst: true, | |
| 31 | }); | |
| 32 | if (!u.ok) throw new Error(u.error); | |
| 33 | const r = await createRepo(app, u.value, { name: "a", visibility: "public" }); | |
| 34 | if (!r.ok) throw new Error("repo"); | |
| 35 | repoId = r.value.id; | |
| 36 | servers = await serve(app); | |
| 37 | const signin = await fetch(`${servers.url}/signin`, { | |
| 38 | method: "POST", | |
| 39 | headers: { origin: servers.url }, | |
| 40 | body: new URLSearchParams({ username: "alice", password: "a-good-passphrase" }), | |
| 41 | redirect: "manual", | |
| 42 | }); | |
| 43 | cookie = (signin.headers.get("set-cookie") ?? "").split(";")[0]!; | |
| 44 | }); | |
| 45 | afterAll(() => { | |
| 46 | servers.stop(); | |
| 47 | app.close(); | |
| 48 | rmSync(root, { recursive: true, force: true }); | |
| 49 | }); | |
| 50 | ||
| 51 | test("the empty webhooks page draws no data-nav row", async () => { | |
| 52 | const text = await page(); | |
| 53 | expect(text).toContain("No webhooks yet."); | |
| 54 | expect(text).not.toMatch(NAV); | |
| 55 | }); | |
| 56 | ||
| 57 | test("each hook is one data-nav row", async () => { | |
| 58 | for (const n of [1, 2]) { | |
| 59 | const made = createWebhook(app.db, { repoId, url: `https://a.example/h${n}`, secret: "s3cret-value", kinds: "push" }); | |
| 60 | if (!made.ok) throw new Error("hook"); | |
| 61 | } | |
| 62 | expect((await page()).match(NAV)?.length).toBe(2); | |
| 63 | }); |
new above
offline