Public: anyone can read this; the crew can change it.
A changelog wave opens in four steps: wave, its changes, its pulls, the conversation #15772
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/15752-a-changelog-wave-opens-in-four-steps-wav → main 0 commits fork 4 threads · 4 unresolved
3 files
changed +117
−1
docs/features/changelog.md +4
| @@ -105,3 +105,7 @@ When a chapter closes (for example one named `v1.1.0`), its wave is told on `/ch | ||
| 105 | 105 | ## Nothing live yet (#15355) |
| 106 | 106 | |
| 107 | 107 | A forge that has cut no release says so once. `/changelog` opens with "Nothing has gone live yet. Running <commit>. Work in progress shows in the open pulls." The terminal's Changelog screen shows the title "Nothing has gone live yet" over "Work in progress shows in the open pulls." `/changelog.atom` has no entry then, and its `updated` is the forge's first boot (the first account), never a fixed date. Tested in `test/changelog.test.ts`, `test/tui-changelog.test.ts` and `test/changelog-atom.test.ts`. |
| 108 | ||
| 109 | ## A wave opens in four steps (#15752) | |
| 110 | ||
| 111 | On `/changelog` a wave's row opens the wave's own page (`/<repo>/waves/<version>`): its headline, its changes, and each change's pull, whose page holds the conversation. A chapter with no wave still opens its chapter page. The terminal is not changed by this. Tested by following the links in `test/changelog-depth.test.ts`. | |
src/web/pages/changelog.ts +3 −1
| @@ -153,7 +153,9 @@ function chapterSection(g: Extract<Group, { kind: "chapter" }>, own: string | un | ||
| 153 | 153 | const listed = new Set(g.landings.filter((l) => l.repo === g.repo).map((l) => l.number)); |
| 154 | 154 | const more = (g.wave?.pulls ?? []).filter((p) => !listed.has(p.number)); |
| 155 | 155 | const head = row({ |
| 156 | href: `/${g.repo}/chapters/${c.name}`, | |
| 156 | // A wave opens on its own page (its changes, then their pulls); a chapter with none, on its | |
| 157 | // own. | |
| 158 | href: g.wave === undefined ? `/${g.repo}/chapters/${c.name}` : `/${g.repo}/waves/${encodeURIComponent(g.wave.version)}`, | |
The chapter-page fallback for a chapter with no wave is new behaviour and untested. Add a test for it. |
||
| 157 | 159 | nav: true, |
| 158 | 160 | title: c.name, |
| 159 | 161 | ...(g.wave !== undefined ? { meta: html`${g.wave.sentence}${g.wave.milestone === undefined || g.wave.milestone.total === 0 ? "" : html` <span data-wave-milestone>The milestone: ${g.wave.milestone.title}: ${doneWords(g.wave.milestone)}</span>`}` } : g.landings.length === 0 ? { meta: html`Nothing landed yet.` } : {}), |
test/changelog-depth.test.ts added +110
| @@ -0,0 +1,110 @@ | ||
| 1 | /** | |
| 2 | * A changelog wave opens in four steps: the wave, its changes, its pulls, the conversation | |
| 3 | * (#15752). | |
| 4 | */ | |
| 5 | import { expect, test } from "bun:test"; | |
| 6 | import { mkdtempSync } from "node:fs"; | |
| 7 | import { tmpdir } from "node:os"; | |
| 8 | import { join } from "node:path"; | |
| 9 | import { newApp } from "../src/actions/apps.ts"; | |
| 10 | import { close, draft, fill, open } from "../src/actions/chapters.ts"; | |
| 11 | import { createApp } from "../src/app.ts"; | |
| 12 | import { getRepo } from "../src/core/repos.ts"; | |
| 13 | import { createIssue } from "../src/core/issues.ts"; | |
| 14 | import { createUser } from "../src/core/users.ts"; | |
| 15 | import { repoDir } from "../src/git/repos.ts"; | |
| 16 | import { commitFiles } from "../src/git/write.ts"; | |
| 17 | import { serve } from "../src/http/server.ts"; | |
| 18 | import { quietLogs } from "./helpers/globals.ts"; | |
| 19 | ||
| 20 | quietLogs(); | |
| 21 | ||
| 22 | /** The first link in `page` under `prefix`. */ | |
| 23 | const linkUnder = (page: string, prefix: string): string => { | |
| 24 | const at = page.indexOf(`href="${prefix}`); | |
| 25 | if (at < 0) throw new Error(`no link under ${prefix}`); | |
| 26 | return page.slice(at + 6, page.indexOf('"', at + 6)).replaceAll("&", "&"); | |
| 27 | }; | |
| 28 | ||
| 29 | test("from /changelog each tap reaches the next step: wave, change, pull, conversation", async () => { | |
| 30 | const app = createApp({ dataDir: mkdtempSync(join(tmpdir(), "forge-depth-")), port: 0, host: "forge.test" }); | |
| 31 | const servers = await serve(app); | |
| 32 | try { | |
| 33 | const u = await createUser(app.db, { origin: "seed", trusted: true, username: "alice", email: "[email protected]", password: "a-good-passphrase", adminIfFirst: true }); | |
| 34 | if (!u.ok) throw new Error(u.error); | |
| 35 | const made = await newApp(app, u.value, { name: "shop", description: "Words", visibility: "public" }); | |
| 36 | if (!made.ok) throw new Error(String(made.error)); | |
| 37 | const repo = getRepo(app.db, "alice", "shop")!; | |
| 38 | const first = await commitFiles(repoDir(app.reposRoot, "alice", "shop"), { branch: repo.defaultBranch, message: "first", files: [{ path: "README.md", content: "hi" }], author: { name: "T", email: "[email protected]" } }); | |
| 39 | if (!first.ok) throw new Error("commit"); | |
| 40 | expect(draft(app, u.value, repo, { name: "v1.1.0" }).ok).toBe(true); | |
| 41 | for (let k = 1; k <= 3; k++) { | |
| 42 | const issue = createIssue(app.db, { repoId: repo.id, authorId: u.value.id, title: `Item ${k}`, body: "" }); | |
| 43 | if (!issue.ok) throw new Error(String(issue.error)); | |
| 44 | app.db.query("UPDATE issue SET state = 'closed', closed_at = ?2 WHERE id = ?1").run(issue.value.id, "2026-11-10T00:00:00.000Z"); | |
| 45 | const n = 7000 + k; | |
| 46 | app.db.query(`INSERT INTO issue (id, repo_id, number, kind, title, body, author_id, state) VALUES (?1, ?2, ?3, 'pull', ?4, ?5, ?6, 'closed')`).run(`p${n}`, repo.id, n, `Build ${k}`, `Closes #${issue.value.number}`, u.value.id); | |
| 47 | app.db.query(`INSERT INTO pull (issue_id, base_branch, head_branch, base_oid, head_oid, merged_at) VALUES (?1, 'main', ?2, 'a', 'b', '2026-11-10T00:00:00.000Z')`).run(`p${n}`, `b${n}`); | |
| 48 | app.db.query(`INSERT INTO release (sha, repo_id, pull_number, ok, line, created_at) VALUES ('abc', ?1, ?2, 1, 'ok', '2026-11-11T08:00:00.000Z')`).run(repo.id, n); | |
| 49 | expect(fill(app, u.value, repo, "v1.1.0", issue.value.number, true).ok).toBe(true); | |
| 50 | } | |
| 51 | expect(open(app, u.value, repo, "v1.1.0").ok).toBe(true); | |
| 52 | expect((await close(app, u.value, repo, "v1.1.0", false, new Date("2026-11-16T12:00:00.000Z"))).ok).toBe(true); | |
| 53 | ||
| 54 | // 1. The changelog: the wave's headline, one tap to the wave. | |
| 55 | const log = await fetch(`${servers.url}/changelog?repo=alice/shop`); | |
| 56 | expect(log.status).toBe(200); | |
| 57 | const waveHref = linkUnder(await log.text(), "/alice/shop/waves/"); | |
| 58 | expect(waveHref).toBe("/alice/shop/waves/1.1.0"); | |
| 59 | ||
| 60 | // 2. The wave: its headline, and its changes as rows. | |
| 61 | const wave = await fetch(`${servers.url}${waveHref}`); | |
| 62 | expect(wave.status).toBe(200); | |
| 63 | const waveHtml = await wave.text(); | |
| 64 | expect(/<h1>[^<]*shipped 3 changes[^<]*<\/h1>/.test(waveHtml)).toBe(true); | |
| 65 | ||
| 66 | // 3. A change links to its pull, which opens under its own title and number. | |
| 67 | const pullHref = linkUnder(waveHtml, "/alice/shop/pulls/"); | |
| 68 | const number = Number(/\/pulls\/(\d+)/.exec(pullHref)?.[1]); | |
outdated
|
||
| 69 | expect(number).toBeGreaterThanOrEqual(7001); | |
| 70 | expect(number).toBeLessThanOrEqual(7003); | |
| 71 | const pull = await fetch(`${servers.url}${pullHref}`); | |
| 72 | expect(pull.status).toBe(200); | |
| 73 | const pullHtml = await pull.text(); | |
| 74 | expect(pullHtml.replace(/\s+/g, "").includes(`<h1>Build${number - 7000}<spanclass="num">#${number}</span></h1>`)).toBe(true); | |
| 75 | ||
| 76 | // 4. The same page holds the conversation: its opening post, which the pull's body wrote. | |
outdated
This refetches the same URL as step 3, so it adds no step. Assert on |
||
| 77 | const at = pullHtml.indexOf('id="conversation"'); | |
| 78 | expect(at).toBeGreaterThan(0); | |
| 79 | const conversation = pullHtml.slice(at); | |
| 80 | expect(conversation).toContain("opened this"); | |
| 81 | expect(conversation).toMatch(/Closes #\d+/); | |
| 82 | } finally { | |
| 83 | servers.stop(); | |
| 84 | app.close(); | |
| 85 | } | |
| 86 | }, 60_000); | |
| 87 | ||
| 88 | test("a chapter with no wave on /changelog still links to its chapter page", async () => { | |
| 89 | const app = createApp({ dataDir: mkdtempSync(join(tmpdir(), "forge-depth-")), port: 0, host: "forge.test" }); | |
| 90 | const servers = await serve(app); | |
| 91 | try { | |
| 92 | const u = await createUser(app.db, { origin: "seed", trusted: true, username: "alice", email: "[email protected]", password: "a-good-passphrase", adminIfFirst: true }); | |
| 93 | if (!u.ok) throw new Error(u.error); | |
| 94 | const made = await newApp(app, u.value, { name: "shop", description: "Words", visibility: "public" }); | |
| 95 | if (!made.ok) throw new Error(String(made.error)); | |
| 96 | const repo = getRepo(app.db, "alice", "shop")!; | |
| 97 | // The changelog shows once something has gone live; the open chapter has no wave yet. | |
| 98 | app.db.query(`INSERT INTO issue (id, repo_id, number, kind, title, body, author_id, state) VALUES ('p9', ?1, 9, 'pull', 'Early', '', ?2, 'closed')`).run(repo.id, u.value.id); | |
| 99 | app.db.query(`INSERT INTO pull (issue_id, base_branch, head_branch, base_oid, head_oid, merged_at) VALUES ('p9', 'main', 'b9', 'a', 'b', '2026-11-10T00:00:00.000Z')`).run(); | |
| 100 | app.db.query(`INSERT INTO release (sha, repo_id, pull_number, ok, line, created_at) VALUES ('abc', ?1, 9, 1, 'ok', '2026-11-11T08:00:00.000Z')`).run(repo.id); | |
| 101 | expect(draft(app, u.value, repo, { name: "v2.0.0" }).ok).toBe(true); | |
| 102 | expect(open(app, u.value, repo, "v2.0.0").ok).toBe(true); | |
| 103 | const page = await (await fetch(`${servers.url}/changelog?repo=alice/shop`)).text(); | |
| 104 | expect(page).toContain('href="/alice/shop/chapters/v2.0.0"'); | |
| 105 | expect(page).not.toContain("/alice/shop/waves/"); | |
| 106 | } finally { | |
| 107 | servers.stop(); | |
| 108 | app.close(); | |
| 109 | } | |
| 110 | }, 60_000); |
new above
offline
The terminal sentence names no test. Name the test that covers the
wwalk, or remove the claim.