Public: anyone can read this; the crew can change it.
The forge-wide map leaves archived repositories out #5744
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/3481-the-forge-wide-map-leaves-archived-repos → main 1 commit fork 1 thread · 1 unresolved
2 files
changed +81
−1
src/web/pages/map.ts +1 −1
| @@ -1633,7 +1633,7 @@ export function globalLanes( | ||
| 1633 | 1633 | const db = app.db; |
| 1634 | 1634 | const now = new Date(); |
| 1635 | 1635 | // Access first, every request, and into the key (docs/CACHING.md rule 1). |
| 1636 | const repos = listReposVisibleTo(db, viewer, { limit: 200 }); | |
| 1636 | const repos = listReposVisibleTo(db, viewer, { limit: 200, withoutArchived: true }); | |
| 1637 | 1637 | const heads = repoHeads( |
| 1638 | 1638 | db, |
| 1639 | 1639 | repos.map((r) => r.id), |
test/map-archived.test.ts added +80
| @@ -0,0 +1,80 @@ | ||
| 1 | /** | |
| 2 | * Archive puts a repository away (#1838): the forge-wide map leaves its | |
| 3 | * lane out, waking it brings the lane back, and its own page still answers. | |
| 4 | */ | |
| 5 | import { afterAll, beforeAll, describe, expect, test } from "bun:test"; | |
| 6 | import { mkdtemp, rm } from "node:fs/promises"; | |
| 7 | import { tmpdir } from "node:os"; | |
| 8 | import { join } from "node:path"; | |
| 9 | import { createApp, type App } from "../src/app.ts"; | |
| 10 | import { openIssue } from "../src/actions/issues.ts"; | |
| 11 | import { createRepo } from "../src/actions/repos.ts"; | |
| 12 | import { moveArchived, type Repo } from "../src/core/repos.ts"; | |
| 13 | import { createUser } from "../src/core/users.ts"; | |
| 14 | import { serve, type Servers } from "../src/http/server.ts"; | |
| 15 | ||
| 16 | describe("the forge-wide map and archived repositories", () => { | |
| 17 | let dataDir: string; | |
| 18 | let app: App; | |
| 19 | let servers: Servers; | |
| 20 | let base: string; | |
| 21 | let cookie: string; | |
| 22 | let keep: Repo; | |
| 23 | let shelve: Repo; | |
| 24 | ||
| 25 | const page = async (path: string): Promise<Response> => | |
| 26 | fetch(`${base}${path}`, { headers: { cookie } }); | |
| 27 | ||
| 28 | beforeAll(async () => { | |
| 29 | dataDir = await mkdtemp(join(tmpdir(), "forge-map-archived-")); | |
| 30 | app = createApp({ dataDir, port: 0 }); | |
| 31 | servers = await serve(app); | |
| 32 | base = `http://127.0.0.1:${servers.port}`; | |
| 33 | const made = await createUser(app.db, { | |
| 34 | origin: "seed", | |
| 35 | trusted: true, | |
| 36 | username: "alice", | |
| 37 | email: "[email protected]", | |
| 38 | password: "a-good-passphrase", | |
| 39 | adminIfFirst: true, | |
| 40 | }); | |
| 41 | if (!made.ok) throw new Error(made.error); | |
| 42 | const alice = made.value; | |
| 43 | const a = await createRepo(app, alice, { name: "keep", visibility: "private" }); | |
| 44 | const b = await createRepo(app, alice, { name: "shelve", visibility: "private" }); | |
| 45 | if (!a.ok || !b.ok) throw new Error("repo"); | |
| 46 | keep = a.value; | |
| 47 | shelve = b.value; | |
| 48 | for (const r of [keep, shelve]) await openIssue(app, alice, r, { title: "Something to draw" }); | |
| 49 | const res = await fetch(`${base}/signin`, { | |
| 50 | method: "POST", | |
| 51 | body: new URLSearchParams({ username: "alice", password: "a-good-passphrase" }), | |
| 52 | redirect: "manual", | |
| 53 | }); | |
| 54 | cookie = (res.headers.get("set-cookie") ?? "").split(";")[0]!; | |
| 55 | }); | |
| 56 | ||
| 57 | afterAll(async () => { | |
| 58 | await servers.stop(); | |
| 59 | await rm(dataDir, { recursive: true, force: true }); | |
| 60 | }); | |
| 61 | ||
| 62 | test("an archived repository leaves /map, and waking it brings it back", async () => { | |
| 63 | const lane = (html: string, name: string) => html.includes(`id="lane-alice-${name}"`); | |
| 64 | let html = await (await page("/map")).text(); | |
| 65 | expect(lane(html, "keep")).toBe(true); | |
| 66 | expect(lane(html, "shelve")).toBe(true); | |
| 67 | ||
| 68 | expect(moveArchived(app.db, shelve.id, true)).toBe(true); | |
| 69 | html = await (await page("/map")).text(); | |
| 70 | expect(lane(html, "keep")).toBe(true); | |
| 71 | expect(lane(html, "shelve")).toBe(false); | |
| 72 | // Archived, not gone: its own page still answers. | |
| 73 | expect((await page("/alice/shelve")).status).toBe(200); | |
| 74 | ||
| 75 | expect(moveArchived(app.db, shelve.id, false)).toBe(true); | |
| 76 | html = await (await page("/map")).text(); | |
| 77 | expect(lane(html, "shelve")).toBe(true); | |
| 78 | expect(keep.name).toBe("keep"); | |
| 79 | }); | |
| 80 | }); |
new above
offline
This assertion checks nothing about archiving; remove it (and
keepcan be used only for the lane check above).