Public: anyone can read this; the crew can change it.
A wave's changelog line for each landed pull is that pull's own first sentence, grouped by pillar #16811
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/16312-a-wave-s-changelog-line-for-each-landed → main 0 commits fork 2 threads · 2 unresolved
7 files
changed +283
−6
docs/features/wave-changelog.md added +13
| @@ -0,0 +1,13 @@ | ||
| 1 | --- | |
| 2 | topic: When something is wrong | |
| 3 | row: A wave's changelog, by pillar | |
| 4 | --- | |
| 5 | # A wave's changelog, by pillar | |
| 6 | ||
| 7 | Open a wave, e.g. `/trevato/forge/waves/<version>`: its **Pulls** are grouped under the pillar each served, one list, each pull said once with its first sentence (its title when the description is empty). Pulls serving no pillar go under **Other**, last. A wave whose repository has no pillars shows the one list with no heads. | |
| 8 | ||
| 9 | - The sentence is the first of the description's first line, cut at a word at 160 characters; plain text, escaped on the page. | |
| 10 | - Pillars come in plan order (`P0`, `P1`, …, then `Later`), as `src/core/pillars.ts` reads them. | |
| 11 | - The terminal's wave screen (`waves`, then open a wave) shows the same groups under "Changelog". | |
| 12 | ||
| 13 | Both doors take it from `waveChangelog` in `src/story/wave_changelog.ts`. |
src/story/wave_changelog.ts added +110
| @@ -0,0 +1,110 @@ | ||
| 1 | /** | |
| 2 | * A wave's changelog: each landed pull's own first sentence, grouped under the pillar it served. | |
| 3 | * The grouping is plain data in, plain data out; `pillarsOfPulls` is the one reader that finds | |
| 4 | * which pillar each pull served (the first it, or an issue it closes, is placed under, as the | |
| 5 | * dataset reads it). Text comes back unescaped: the doors escape it. | |
| 6 | */ | |
| 7 | ||
| 8 | import type { Database } from "bun:sqlite"; | |
| 9 | import { closesFromBody } from "../core/pulls.ts"; | |
| 10 | import { pillarNames, pillarsOf, servedBy } from "../core/pillars.ts"; | |
| 11 | import { getRepo, type Repo } from "../core/repos.ts"; | |
| 12 | import { wordClip } from "../text/word_clip.ts"; | |
| 13 | import { pullPath, SENTENCE_CAP, type CarriedPull } from "./wave_pulls.ts"; | |
| 14 | ||
| 15 | /** The heading for a pull that serves no pillar. */ | |
| 16 | export const OTHER = "Other"; | |
| 17 | ||
| 18 | export interface ChangelogEntry { | |
| 19 | number: number; | |
| 20 | /** Local path of the pull. */ | |
| 21 | href: string; | |
| 22 | /** The pull's first sentence (its title when it has no description), clipped. */ | |
| 23 | text: string; | |
| 24 | } | |
| 25 | export interface ChangelogGroup { | |
| 26 | pillar: string; | |
| 27 | entries: ChangelogEntry[]; | |
| 28 | } | |
| 29 | ||
| 30 | /** The first sentence of a line: up to the first `.`, `!` or `?` followed by a space or the end. */ | |
| 31 | export function firstSentence(line: string): string { | |
| 32 | // `e.g.` and `i.e.` end no sentence: a stop after them is passed over. | |
| 33 | const m = /^(?:.*?(?<!\b(?:e\.g|i\.e)))[.!?](?=\s|$)/i.exec(line.trim()); | |
| 34 | return (m?.[0] ?? line).trim(); | |
| 35 | } | |
| 36 | ||
| 37 | /** The pillar name each pull served by `owner/name#number`; a pull serving none has no entry. */ | |
| 38 | export function pillarsOfPulls(db: Database, pulls: readonly Pick<CarriedPull, "owner" | "name" | "number">[]): Map<string, string> { | |
| 39 | const out = new Map<string, string>(); | |
| 40 | const byRepo = new Map<string, number[]>(); | |
| 41 | for (const p of pulls) byRepo.set(`${p.owner}/${p.name}`, [...(byRepo.get(`${p.owner}/${p.name}`) ?? []), p.number]); | |
| 42 | for (const [key, numbers] of byRepo) { | |
| 43 | const [owner, name] = key.split("/") as [string, string]; | |
| 44 | const repo = getRepo(db, owner, name); | |
| 45 | if (!repo) continue; | |
| 46 | const served = servedBy(db, pillarsOf(db, repo)); | |
| 47 | if (served.size === 0) continue; | |
| 48 | const q = (ns: readonly number[]) => | |
| 49 | db | |
| 50 | .query<{ id: string; number: number; body: string }, (string | number)[]>( | |
| 51 | `SELECT id, number, body FROM issue WHERE repo_id = ? AND number IN (${ns.map(() => "?").join(",")})`, | |
| 52 | ) | |
| 53 | .all(repo.id, ...ns); | |
| 54 | const rows = q(numbers); | |
| 55 | const closes = new Map(rows.map((r) => [r.number, closesFromBody(r.body ?? "")])); | |
| 56 | const wanted = [...new Set([...closes.values()].flat())]; | |
| 57 | const closed = new Map((wanted.length === 0 ? [] : q(wanted)).map((r) => [r.number, r.id])); | |
| 58 | for (const r of rows) { | |
| 59 | const ids = [r.id, ...(closes.get(r.number) ?? []).flatMap((n) => closed.get(n) ?? [])]; | |
| 60 | const pillar = ids.map((id) => served.get(id)).find((x) => x !== undefined); | |
| 61 | if (pillar !== undefined) out.set(`${key}#${r.number}`, pillar); | |
| 62 | } | |
| 63 | } | |
| 64 | return out; | |
| 65 | } | |
| 66 | ||
| 67 | /** | |
| 68 | * `items` grouped by the pillar of each (`Other` when none): `order` first, then others, `Other` | |
| 69 | * last. | |
| 70 | */ | |
| 71 | export function byPillar<T extends Pick<CarriedPull, "owner" | "name" | "number">>( | |
| 72 | items: readonly T[], | |
| 73 | pillarOf: ReadonlyMap<string, string>, | |
| 74 | order: readonly string[] = [], | |
| 75 | ): { pillar: string; items: T[] }[] { | |
| 76 | const groups = new Map<string, T[]>(); | |
| 77 | for (const p of items) { | |
| 78 | const pillar = pillarOf.get(`${p.owner}/${p.name}#${p.number}`) ?? OTHER; | |
| 79 | groups.set(pillar, [...(groups.get(pillar) ?? []), p]); | |
| 80 | } | |
| 81 | const rank = (n: string): number => (n === OTHER ? Infinity : order.indexOf(n) < 0 ? order.length : order.indexOf(n)); | |
| 82 | return [...groups].sort(([a], [b]) => rank(a) - rank(b) || a.localeCompare(b)).map(([pillar, items]) => ({ pillar, items })); | |
| 83 | } | |
| 84 | ||
| 85 | /** The pillar of each pull, and the pillars in plan order: what `byPillar` takes. */ | |
| 86 | export function wavePillars(db: Database, repo: Repo, pulls: readonly CarriedPull[]): { pillarOf: Map<string, string>; order: string[] } { | |
| 87 | return { pillarOf: pillarsOfPulls(db, pulls), order: pillarNames(pillarsOf(db, repo)) }; | |
| 88 | } | |
| 89 | ||
| 90 | /** | |
| 91 | * The landed pulls grouped by pillar: pillars in `order` first, then any other named pillar, then | |
| 92 | * `Other` last; entries in the order given. Unlanded pulls are left out. | |
| 93 | */ | |
| 94 | export function changelogGroups( | |
| 95 | pulls: readonly CarriedPull[], | |
| 96 | pillarOf: ReadonlyMap<string, string>, | |
| 97 | order: readonly string[] = [], | |
| 98 | ): ChangelogGroup[] { | |
| 99 | return byPillar(pulls.filter((p) => p.mergedAt !== null), pillarOf, order).map((g) => ({ | |
| 100 | pillar: g.pillar, | |
| 101 | entries: g.items.map((p) => ({ number: p.number, href: pullPath(p), text: wordClip(firstSentence(p.sentence ?? p.title), SENTENCE_CAP) })), | |
| 102 | })); | |
| 103 | } | |
| 104 | ||
| 105 | /** The wave's changelog for `repo`'s pillars, over the pulls the viewer may see. */ | |
| 106 | export function waveChangelog(db: Database, repo: Repo, pulls: readonly CarriedPull[]): ChangelogGroup[] { | |
| 107 | if (!pulls.some((p) => p.mergedAt !== null)) return []; | |
| 108 | const { pillarOf, order } = wavePillars(db, repo, pulls); | |
| 109 | return changelogGroups(pulls, pillarOf, order); | |
| 110 | } |
src/tui/screens/waves.ts +7 −2
| @@ -16,6 +16,7 @@ import { milestonePath, planNow } from "../../story/wave_plan.ts"; | ||
| 16 | 16 | import { repoBase } from "../../web/chrome.ts"; |
| 17 | 17 | import { waitingKeys } from "../../release/landings.ts"; |
| 18 | 18 | import { agoWords } from "../../kernel/ago.ts"; |
| 19 | import { waveChangelog, type ChangelogGroup } from "../../story/wave_changelog.ts"; | |
| 19 | 20 | import { carriedPulls, inStoryOrder, PAGE_PULLS, pullPath, type CarriedPull } from "../../story/wave_pulls.ts"; |
| 20 | 21 | import { pullRefs, readWave, readWaves, waveNeighbours, type WaveNeighbours, sizeWords, waveLine, waveSize, appsOf, wavesInApp, type WaveEntry } from "../../story/waves.ts"; |
| 21 | 22 | import { EMPTY_WORDS } from "../../core/empty_words.ts"; |
| @@ -83,6 +84,8 @@ export function waveLines( | ||
| 83 | 84 | duration = "", |
| 84 | 85 | /** The waves either side, named at the foot; none when both are null. */ |
| 85 | 86 | near: WaveNeighbours = { earlier: null, later: null }, |
| 87 | /** The changelog by pillar, as the page says it; none when empty. */ | |
| 88 | changelog: readonly ChangelogGroup[] = [], | |
| 86 | 89 | ): string[] { |
| 87 | 90 | if (!entry.ok) return [plain(entry.file), "", `Not a wave: ${plain(entry.reason)}`]; |
| 88 | 91 | const w = entry.wave; |
| @@ -97,6 +100,7 @@ export function waveLines( | ||
| 97 | 100 | "Highlights", |
| 98 | 101 | ...w.highlights.map((h) => ` ${plain(h.title)} - ${plain(h.why)}`), |
| 99 | 102 | "", |
| 103 | ...(changelog.length === 0 ? [] : ["Changelog", ...changelog.flatMap((g) => [` ${plain(g.pillar)}`, ...g.entries.map((e) => ` #${e.number} ${plain(e.text)}`)]), ""]), | |
| 100 | 104 | ...(moved.length === 0 |
| 101 | 105 | ? [] |
| 102 | 106 | : [ |
| @@ -137,11 +141,12 @@ function waveScreen( | ||
| 137 | 141 | near: WaveNeighbours = { earlier: null, later: null }, |
| 138 | 142 | /** Swaps this screen for the wave of `version`, so Esc still returns to the list. */ |
| 139 | 143 | step: (version: string) => void = () => {}, |
| 144 | changelog: readonly ChangelogGroup[] = [], | |
| 140 | 145 | ): Screen { |
| 141 | 146 | const scroll = new Scroll(); |
| 142 | 147 | let picked = 0; |
| 143 | 148 | /** Where the wave's pulls start in the text, so the pick is scrolled into view. */ |
| 144 | const linesFor = (): string[] => waveLines(entry, pulls, moved, pulls.length === 0 ? null : picked, standing, duration, near); | |
| 149 | const linesFor = (): string[] => waveLines(entry, pulls, moved, pulls.length === 0 ? null : picked, standing, duration, near, changelog); | |
| 145 | 150 | const open = (): void => { |
| 146 | 151 | const p = pulls[picked]; |
| 147 | 152 | if (p === undefined) return; |
| @@ -260,7 +265,7 @@ export function wavesScreen(f: Session, ctx: Ctx, src: RepoSource): Screen { | ||
| 260 | 265 | // The page's neighbours, from the same function: a file that is no wave is skipped. |
| 261 | 266 | const near = one.ok ? await waveNeighbours(f.dir(repo), repo.defaultBranch, one.wave.version) : { earlier: null, later: null }; |
| 262 | 267 | const step = (version: string): void => openEntry({ ok: true, file: `${version}.md`, wave: near.earlier?.version === version ? near.earlier : near.later! }, true); |
| 263 | const screen = waveScreen(f, ctx, one, pulls, moved, src, standing, one.ok ? waveDuration(f.db, pulls, new Date()) : "", near, step); | |
| 268 | const screen = waveScreen(f, ctx, one, pulls, moved, src, standing, one.ok ? waveDuration(f.db, pulls, new Date()) : "", near, step, one.ok ? waveChangelog(f.db, repo, pulls) : []); | |
| 264 | 269 | if (replace) ctx.replace(screen); |
| 265 | 270 | else ctx.push(screen); |
| 266 | 271 | }); |
src/web/pages/waves.ts +9 −4
| @@ -18,6 +18,7 @@ import type { Ctx } from "../../http/context.ts"; | ||
| 18 | 18 | import { VERSION, type Wave } from "../../story/wave.ts"; |
| 19 | 19 | import { movedWithPulls, type MovedMilestone, shippedOf, shippedWords, waveProgress, widestMoved } from "../../story/wave_moved.ts"; |
| 20 | 20 | import { waveDays, waveDuration } from "../../story/wave_duration.ts"; |
| 21 | import { byPillar, OTHER, wavePillars } from "../../story/wave_changelog.ts"; | |
| 21 | 22 | import { carriedPulls, inLandingOrder, inStoryOrder, PAGE_PULLS, pullPath } from "../../story/wave_pulls.ts"; |
| 22 | 23 | import { appsOf, fromWave, inApp, parseAppFilter, pullRefs, readWave, readWaves, sizeWords, waveNeighbours, wavePath, waveSize } from "../../story/waves.ts"; |
| 23 | 24 | import { FIRST_WAVE_TELL, landedSentence, waveSentence } from "../../story/words.ts"; |
| @@ -283,6 +284,11 @@ export async function wavePage(ctx: Ctx): Promise<Response> { | ||
| 283 | 284 | */ |
| 284 | 285 | const landed = carried.length === 0 ? "" : progress(carried.filter((p) => p.mergedAt !== null).length, carried.length, "Share landed"); |
| 285 | 286 | const duration = entry.ok ? waveDuration(ctx.app.db, carried, new Date()) : ""; |
| 287 | // The pulls, grouped under the pillar each served: one list, said once. Under no pillar it stays | |
| 288 | // a single list with no heads. | |
| 289 | const { pillarOf, order } = entry.ok ? wavePillars(ctx.app.db, repo, unfolded) : { pillarOf: new Map<string, string>(), order: [] }; | |
| 290 | const groups = byPillar(unfolded, pillarOf, order); | |
| 291 | const headed = groups.some((g) => g.pillar !== OTHER); | |
| 286 | 292 | const content = entry.ok |
| 287 | 293 | ? html`<h1>${entry.wave.headline}</h1> |
| 288 | 294 | <p data-wave-sentence>${waveSentence(carried.filter((p) => p.mergedAt !== null).map((p) => p.title))}</p> |
| @@ -316,10 +322,9 @@ export async function wavePage(ctx: Ctx): Promise<Response> { | ||
| 316 | 322 | ? html`<p class="muted" data-pulls-none>No pulls to show here.</p>` |
| 317 | 323 | : unfolded.length === 0 |
| 318 | 324 | ? "" |
| 319 | : listCard( | |
| 320 | unfolded.map(pullRow), | |
| 321 | { head: html`<h2>Pulls</h2>` }, | |
| 322 | )} | |
| 325 | : !headed | |
| 326 | ? listCard(unfolded.map(pullRow), { head: html`<h2>Pulls</h2>` }) | |
| 327 | : html`<h2>Pulls</h2>${groups.map((g) => listCard(g.items.map(pullRow), { head: html`<h3 data-changelog-pillar>${g.pillar}</h3>` }))}`} | |
| 323 | 328 | ${hidden > 0 ? html`<p class="muted" data-pulls-more>and ${hidden} more · <a href="?all=1">Show them all</a></p>` : ""}` |
| 324 | 329 | : html`<h1>${entry.file}</h1> |
| 325 | 330 | <p class="muted">Not a wave: ${entry.reason}</p>`; |
test/wave-changelog-pillars.test.ts added +93
| @@ -0,0 +1,93 @@ | ||
| 1 | /** | |
| 2 | * Which pillar a landed pull is under, read from a real database: umbrellas, links and `Closes #N`. | |
| 3 | */ | |
| 4 | import { afterAll, beforeAll, expect, test } from "bun:test"; | |
| 5 | import { mkdtemp, rm } from "node:fs/promises"; | |
| 6 | import { tmpdir } from "node:os"; | |
| 7 | import { join } from "node:path"; | |
| 8 | import { createApp, type App } from "../src/app.ts"; | |
| 9 | import { linkIssue } from "../src/actions/dependencies.ts"; | |
| 10 | import { openIssue } from "../src/actions/issues.ts"; | |
| 11 | import { openPull } from "../src/actions/pulls.ts"; | |
| 12 | import { commitToBranch, createRepo } from "../src/actions/repos.ts"; | |
| 13 | import { getIssueById, type Issue } from "../src/core/issues.ts"; | |
| 14 | import { getRepoById, type Repo } from "../src/core/repos.ts"; | |
| 15 | import { createUser, getUserByName, type User } from "../src/core/users.ts"; | |
| 16 | import { changelogGroups, OTHER, pillarsOfPulls, waveChangelog } from "../src/story/wave_changelog.ts"; | |
| 17 | import type { CarriedPull } from "../src/story/wave_pulls.ts"; | |
| 18 | ||
| 19 | let dir: string; | |
| 20 | let app: App; | |
| 21 | let alice: User; | |
| 22 | let repo: Repo; | |
| 23 | let pulls: CarriedPull[]; | |
| 24 | ||
| 25 | const fresh = () => getRepoById(app.db, repo.id)!; | |
| 26 | const issue = (title: string): Issue => { | |
| 27 | const r = openIssue(app, alice, fresh(), { title }); | |
| 28 | if (!r.ok) throw new Error(String(r.error)); | |
| 29 | return r.value; | |
| 30 | }; | |
| 31 | const wait = (waiter: Issue, on: Issue) => { | |
| 32 | const r = linkIssue(app, alice, fresh(), getIssueById(app.db, waiter.id)!, getIssueById(app.db, on.id)!); | |
| 33 | if (!r.ok) throw new Error(JSON.stringify(r.error)); | |
| 34 | }; | |
| 35 | const pull = async (name: string, body: string): Promise<Issue> => { | |
| 36 | const c = await commitToBranch(app, alice, fresh(), { branch: `b-${name}`, message: name, files: [{ path: `${name}.md`, content: name }] }); | |
| 37 | if (!c.ok) throw new Error(JSON.stringify(c.error)); | |
| 38 | const r = await openPull(app, alice, fresh(), { title: `Pull ${name}`, body, baseBranch: "main", headBranch: `b-${name}` }); | |
| 39 | if (!r.ok) throw new Error(String(r.error)); | |
| 40 | app.db.query("UPDATE pull SET merged_at = ? WHERE issue_id = ?").run("2026-03-01T00:00:00.000Z", r.value.id); | |
| 41 | return r.value; | |
| 42 | }; | |
| 43 | ||
| 44 | beforeAll(async () => { | |
| 45 | dir = await mkdtemp(join(tmpdir(), "forge-wcp-")); | |
| 46 | app = createApp({ dataDir: dir, port: 0 }); | |
| 47 | const made = await createUser(app.db, { origin: "seed", trusted: true, username: "alice", email: "[email protected]", password: "a-good-passphrase", adminIfFirst: true }); | |
| 48 | if (!made.ok) throw new Error(made.error); | |
| 49 | alice = getUserByName(app.db, "alice")!; | |
| 50 | const r = await createRepo(app, alice, { name: "eng", visibility: "public" }); | |
| 51 | if (!r.ok) throw new Error(String(r.error)); | |
| 52 | repo = r.value; | |
| 53 | const seeded = await commitToBranch(app, alice, repo, { message: "Start", files: [{ path: "README.md", content: "# eng\n" }] }); | |
| 54 | if (!seeded.ok) throw new Error(JSON.stringify(seeded.error)); | |
| 55 | ||
| 56 | const trust = issue("P0 Trust: be safe"); | |
| 57 | const feed = issue("P1 Feed: be fresh"); | |
| 58 | const keepSafe = issue("Keep it safe"); | |
| 59 | const freshen = issue("Freshen the feed"); | |
| 60 | wait(trust, keepSafe); | |
| 61 | wait(feed, freshen); | |
| 62 | const closesTrust = await pull("one", `Closes #${keepSafe.number}`); | |
| 63 | const closesFeed = await pull("two", `Closes #${freshen.number}`); | |
| 64 | const itselfFeed = await pull("three", `Closes #${freshen.number}`); | |
| 65 | const none = await pull("four", "Serves nothing."); | |
| 66 | const refs = [closesTrust, closesFeed, itselfFeed, none]; | |
| 67 | pulls = refs.map((p) => ({ owner: "alice", name: "eng", number: p.number, title: p.title, mergedAt: "2026-03-01T00:00:00.000Z", mergedBy: null, state: "closed" })); | |
| 68 | }, 60_000); | |
| 69 | afterAll(async () => { | |
| 70 | app.close(); | |
| 71 | await rm(dir, { recursive: true, force: true }); | |
| 72 | }); | |
| 73 | ||
| 74 | test("a pull is under the pillar it, or the issue it closes, serves", () => { | |
| 75 | const of = pillarsOfPulls(app.db, pulls); | |
| 76 | const at = (i: number) => of.get(`alice/eng#${pulls[i]!.number}`); | |
| 77 | expect(at(0)).toBe("P0 Trust"); | |
| 78 | expect(at(1)).toBe("P1 Feed"); | |
| 79 | expect(at(2)).toBe("P1 Feed"); | |
| 80 | expect(at(3)).toBeUndefined(); | |
| 81 | }); | |
| 82 | ||
| 83 | test("the groups come out in pillar order with the unserved pull under Other", () => { | |
| 84 | const g = waveChangelog(app.db, fresh(), pulls); | |
| 85 | expect(g.map((x) => x.pillar)).toEqual(["P0 Trust", "P1 Feed", OTHER]); | |
| 86 | expect(g[0]!.entries.map((e) => e.number)).toEqual([pulls[0]!.number]); | |
| 87 | expect(g[1]!.entries.map((e) => e.number)).toEqual([pulls[1]!.number, pulls[2]!.number]); | |
| 88 | expect(g[2]!.entries.map((e) => e.number)).toEqual([pulls[3]!.number]); | |
| 89 | }); | |
| 90 | ||
| 91 | test("a repository with no pillars puts every pull under Other", () => { | |
| 92 | expect(changelogGroups(pulls, new Map()).map((x) => x.pillar)).toEqual([OTHER]); | |
| 93 | }); |
test/wave-changelog.test.ts added +45
| @@ -0,0 +1,45 @@ | ||
| 1 | /** A wave's changelog groups landed pulls by pillar, one escaped first sentence each. */ | |
| 2 | import { expect, test } from "bun:test"; | |
| 3 | import { changelogGroups, firstSentence, OTHER } from "../src/story/wave_changelog.ts"; | |
| 4 | import { waveLines } from "../src/tui/screens/waves.ts"; | |
| 5 | import type { CarriedPull } from "../src/story/wave_pulls.ts"; | |
| 6 | ||
| 7 | const pull = (number: number, title: string, sentence?: string, merged = true): CarriedPull => ({ | |
| 8 | owner: "a", name: "r", number, title, mergedAt: merged ? "2026-03-01T00:00:00.000Z" : null, mergedBy: null, state: "open", | |
| 9 | ...(sentence === undefined ? {} : { sentence }), | |
| 10 | }); | |
| 11 | ||
| 12 | test("three pillars, Other last, in pillar order", () => { | |
| 13 | const pillars = new Map([["a/r#1", "P1 Feed"], ["a/r#2", "P0 Trust"], ["a/r#3", "P2 Explorer"], ["a/r#4", "P0 Trust"]]); | |
| 14 | const g = changelogGroups( | |
| 15 | [pull(1, "t1", "Feed first. More."), pull(2, "t2", "Trust one!"), pull(3, "t3"), pull(4, "t4", "Trust two"), pull(5, "t5", "Nobody's"), pull(6, "t6", "Open", false)], | |
| 16 | pillars, | |
| 17 | ["P0 Trust", "P1 Feed", "P2 Explorer"], | |
| 18 | ); | |
| 19 | expect(g.map((x) => x.pillar)).toEqual(["P0 Trust", "P1 Feed", "P2 Explorer", OTHER]); | |
| 20 | expect(g[0]!.entries.map((e) => e.number)).toEqual([2, 4]); | |
| 21 | expect(g[1]!.entries[0]!.text).toBe("Feed first."); | |
| 22 | expect(g[2]!.entries[0]!.text).toBe("t3"); | |
| 23 | expect(g[3]!.entries.map((e) => e.number)).toEqual([5]); | |
| 24 | expect(g[0]!.entries[0]!.href).toBe("/a/r/pulls/2"); | |
| 25 | }); | |
| 26 | ||
| 27 | test("a long first sentence is clipped at a word", () => { | |
| 28 | const long = `${"word ".repeat(80)}end.`; | |
| 29 | const e = changelogGroups([pull(1, "t", long)], new Map())[0]!.entries[0]!; | |
| 30 | expect(e.text.length).toBeLessThanOrEqual(160); | |
| 31 | expect(e.text.endsWith("…")).toBe(true); | |
| 32 | }); | |
| 33 | ||
| 34 | test("firstSentence stops at the first full stop followed by space, not at e.g. or i.e.", () => { | |
| 35 | expect(firstSentence("Uses v1.2 now. Then more")).toBe("Uses v1.2 now."); | |
| 36 | expect(firstSentence("e.g. a tag, i.e. a label. Then more")).toBe("e.g. a tag, i.e. a label."); | |
| 37 | }); | |
| 38 | ||
| 39 | test("the terminal says the same changelog", () => { | |
| 40 | const entry = { ok: true as const, file: "0.1.0.md", wave: { version: "0.1.0", date: "2026-03-05", headline: "H", highlights: [], pulls: [] } }; | |
| 41 | const g = changelogGroups([pull(1, "t", "Said.")], new Map([["a/r#1", "P0 Trust"]])); | |
| 42 | const lines = waveLines(entry, [pull(1, "t", "Said.")], [], null, "", "", { earlier: null, later: null }, g); | |
| 43 | expect(lines).toContain(" P0 Trust"); | |
| 44 | expect(lines).toContain(" #1 Said."); | |
| 45 | }); |
test/wave-page-pulls.test.ts +6
| @@ -85,3 +85,9 @@ test("distill skips blank lines, cleans control characters and caps the length", | ||
| 85 | 85 | expect(distill("a\u0007b")).toBe("a b"); |
| 86 | 86 | expect(distill("x".repeat(500))!.length).toBeLessThanOrEqual(160); |
| 87 | 87 | }); |
| 88 | ||
| 89 | test("a wave under no pillar has one Pulls list: no pillar heads and no second Changelog list", () => { | |
| 90 | expect(html).not.toContain("data-changelog-pillar"); | |
| 91 | expect(html).not.toContain("data-wave-changelog"); | |
| 92 | expect(html.split("Old sentence").length - 1).toBe(1); | |
| 93 | }); |
new above
offline
This is the one function that resolves a pull's pillar from the database, and no test covers it. Add a db-backed test: an umbrella with pillar issues, a pull that closes one, a pull with none. Assert the pillar names and Other.