Public: anyone can read this; the crew can change it.
small: the frozen mirrors on the origins page are keyboard-first: j/k move between them, enter opens the repository #10668
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/10542-small-the-frozen-mirrors-on-the-origins → main 2 commits fork
2 files
changed +72
−0
src/web/pages/origins.ts +1
| @@ -896,6 +896,7 @@ function frozenCard({ frozen, repos }: ReturnType<typeof readFrozen>): Html | nu | ||
| 896 | 896 | return [ |
| 897 | 897 | row({ |
| 898 | 898 | href: `/${repo.ownerName}/${repo.name}#frozen`, |
| 899 | nav: true, | |
| 899 | 900 | lead: icon("repo"), |
| 900 | 901 | title: `${repo.ownerName}/${repo.name}`, |
| 901 | 902 | meta: html`mirrors <span class="mono">${m.fullName}</span>${host === "" |
test/keys-origins.test.ts added +71
| @@ -0,0 +1,71 @@ | ||
| 1 | /** The origins page joins the shell's j/k row traversal (#10542): only the frozen-mirror rows are data-nav. */ | |
| 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 { getUserByName } from "../src/core/users.ts"; | |
| 8 | import { createSession } from "../src/core/sessions.ts"; | |
| 9 | import { createOrigin } from "../src/core/origins.ts"; | |
| 10 | import { createRepo } from "../src/core/repos.ts"; | |
| 11 | import { serve, type Servers } from "../src/http/server.ts"; | |
| 12 | import { seedAdmin } from "./helpers/admin.ts"; | |
| 13 | ||
| 14 | let dataDir = ""; | |
| 15 | let app: App, servers: Servers; | |
| 16 | let cookie = ""; | |
| 17 | let ownerId = ""; | |
| 18 | ||
| 19 | beforeAll(async () => { | |
| 20 | dataDir = await mkdtemp(join(tmpdir(), "forge-keys-origins-")); | |
| 21 | app = createApp({ dataDir, port: 0 }); | |
| 22 | servers = await serve(app); | |
| 23 | const a = await seedAdmin(app, { username: "alice", email: "[email protected]", password: "correct-horse-battery" }); | |
| 24 | if (!a.ok) throw new Error(a.error); | |
| 25 | const alice = getUserByName(app.db, "alice")!; | |
| 26 | ownerId = alice.id; | |
| 27 | cookie = `forge_session=${createSession(app.db, alice.id).token}`; | |
| 28 | createOrigin(app.db, dataDir, { | |
| 29 | userId: alice.id, kind: "forgejo", apiUrl: "https://codeberg.org/api/v1", | |
| 30 | webUrl: "https://codeberg.org", login: "alice-cb", token: "tok", | |
| 31 | }); | |
| 32 | }); | |
| 33 | afterAll(async () => { | |
| 34 | servers.stop(); | |
| 35 | app.close(); | |
| 36 | await rm(dataDir, { recursive: true, force: true }); | |
| 37 | }); | |
| 38 | ||
| 39 | const get = async () => (await fetch(`${servers.url}/settings/origins`, { headers: { cookie } })).text(); | |
| 40 | const NAV = /class="row"[^>]*data-nav tabindex="-1"/; | |
| 41 | const frozenSection = (t: string) => { | |
| 42 | const at = t.indexOf("<h2>Frozen mirrors</h2>"); | |
| 43 | return at < 0 ? "" : t.slice(at, t.indexOf("</section>", at)); | |
| 44 | }; | |
| 45 | ||
| 46 | test("no frozen mirrors: no section and no origin-card data-nav row", async () => { | |
| 47 | const text = await get(); | |
| 48 | expect(text).toContain("alice-cb"); | |
| 49 | expect(frozenSection(text)).toBe(""); | |
| 50 | const main = text.slice(text.indexOf("<main"), text.indexOf("</main>")); | |
| 51 | expect(main).not.toMatch(NAV); | |
| 52 | }); | |
| 53 | ||
| 54 | test("each frozen mirror is one data-nav row; the origin card has none", async () => { | |
| 55 | for (const name of ["one", "two"]) { | |
| 56 | const made = await createRepo(app.db, join(dataDir, "repos"), { ownerId, name, visibility: "public" }); | |
| 57 | if (!made.ok) throw new Error(made.error); | |
| 58 | app.db.query( | |
| 59 | "UPDATE repo SET origin_full_name = ?2, origin_html_url = ?3, origin_detached_at = '2026-10-11T00:00:00.000Z' WHERE id = ?1", | |
| 60 | ).run(made.value.id, `octo/${name}`, `https://codeberg.org/octo/${name}`); | |
| 61 | } | |
| 62 | const text = await get(); | |
| 63 | const section = frozenSection(text); | |
| 64 | expect(section).toContain("octo/one"); | |
| 65 | const rows = section.split("<li").filter((li) => NAV.test(li)); | |
| 66 | expect(rows.length).toBe(2); | |
| 67 | expect(rows[0]).toContain('href="/alice/one#frozen"'); | |
| 68 | expect(rows[1]).toContain('href="/alice/two#frozen"'); | |
| 69 | const main = text.slice(text.indexOf("<main"), text.indexOf("</main>")); | |
| 70 | expect(main.split("<li").filter((li) => NAV.test(li)).length).toBe(2); | |
| 71 | }); |