Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit f1c7d0eb7f56668df6c2f379aa94f45b8bf9e4ed
parent 145e0e2f0ff83fc9880401612273cb73ea54d49e
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Wed, 14 Oct 2026 02:53:23 -0400

umtool e2e: inbox.spec (from dashboard.spec) and redirects.spec

inbox.spec: the big count against the API's groups, group order, Quiet
folded, j and the lit action, Park/Undo/Show hidden/Reactivate, Mark done,
Mute, ?from=; the dashboard's panel tests on /settings/system. redirects.spec
requests every row of redirects.mjs with redirects off (307, Location, query
kept) and release 28's hand-written /browse links.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Diffstat:
Dumtool/e2e/dashboard.spec.ts | 141-------------------------------------------------------------------------------
Aumtool/e2e/inbox.spec.ts | 290+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aumtool/e2e/redirects.spec.ts | 88+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 378 insertions(+), 141 deletions(-)

diff --git a/umtool/e2e/dashboard.spec.ts b/umtool/e2e/dashboard.spec.ts @@ -1,141 +0,0 @@ -import { test, expect } from "@playwright/test"; -import { execFileSync } from "node:child_process"; -import path from "node:path"; -import { fileURLToPath } from "node:url"; - -// The front door. Everything on it is read from the index and the job -// registries; nothing on it shells out, and the tools panel proves that by -// saying "not checked" until somebody presses the button. - -const HERE = path.dirname(fileURLToPath(import.meta.url)); -const UMTOOL = path.join(HERE, ".."); -const FIXTURE = path.join(UMTOOL, ".e2e-song"); - -test("the projects panel says exactly what /browse's header says", async ({ page }) => { - await page.goto("/browse"); - const header = (await page.locator("header .micro").last().textContent())?.trim(); - expect(header).toMatch(/^\d+ projects · \d+ blocking · \d+ open$/); - - await page.goto("/"); - await expect(page.locator("[data-projects-note]")).toHaveText(header!); - // One row per kind, each with the six states as segments. - await expect(page.locator("[data-state-row]").first()).toBeVisible(); - const seg = page.locator("[data-state-seg]").first(); - await expect(seg).toHaveAttribute("href", /\/browse\?kind=.+&state=\w+/); -}); - -test("tools read 'not checked' until the button is pressed, and the stubs are found", async ({ page, request }) => { - const before = await (await request.get("/api/doctor")).json(); - // Runs first in this file, and nothing else in the suite probes. - expect(before.checked).toBe(false); - - await page.goto("/"); - await expect(page.locator("[data-tools-checked]")).toHaveAttribute("data-tools-checked", "never"); - await page.locator("[data-action=doctor]").click(); - // The fixture's YTDLP_BIN and QRENCODE_BIN are node stubs that answer - // --version, so both are PRESENT with a version -- proof the probe read the - // same env the pipeline does. - await expect(page.locator("[data-tool=yt-dlp]")).toHaveAttribute("data-present", "1"); - await expect(page.locator("[data-tool=qrencode]")).toHaveAttribute("data-present", "1"); - await expect(page.locator("[data-tool=ffmpeg]")).toHaveAttribute("data-present", "1"); - - const after = await (await request.get("/api/doctor")).json(); - expect(after.checked).toBe(true); - expect(after.tools.find((t: { id: string }) => t.id === "yt-dlp").version).toContain("fixture"); -}); - -test("umtool doctor reports a deliberately bad path as absent, and exits 1", () => { - let code = 0; - let stdout = ""; - try { - stdout = execFileSync("node", ["bin/umtool.mjs", "doctor", "--json"], { - cwd: UMTOOL, - encoding: "utf8", - env: { - ...process.env, - YTDLP_BIN: path.join(FIXTURE, "bin", "definitely-not-here"), - QRENCODE_BIN: path.join(FIXTURE, "bin", "qrencode"), - // The fixture's roots, never this shell's media root or cache (empty = unset). - UMTOOL_MEDIA_DIR: "", - UMTOOL_CACHE_DIR: path.join(FIXTURE, "cache"), - }, - }); - } catch (e) { - const err = e as { status: number; stdout: string }; - code = err.status; - stdout = err.stdout; - } - const j = JSON.parse(stdout); - const yt = j.tools.find((t: { id: string }) => t.id === "yt-dlp"); - expect(yt.present).toBe(false); - expect(yt.required).toBe(true); - expect(j.ok).toBe(false); - // A script can gate on it: the report pipeline cannot run without yt-dlp. - expect(code).toBe(1); - expect(j.tools.find((t: { id: string }) => t.id === "qrencode").present).toBe(true); -}); - -test("/api/jobs has one shape over both registries", async ({ request }) => { - const j = await (await request.get("/api/jobs")).json(); - expect(j).toHaveProperty("running"); - expect(Array.isArray(j.jobs)).toBe(true); - for (const it of j.jobs) { - expect(["chain", "render"]).toContain(it.source); - expect(["running", "done", "failed"]).toContain(it.state); - expect(typeof it.href).toBe("string"); - } -}); - -test("a build shows in Now, then in the activity list as done", async ({ page, request }) => { - const start = await request.post("/api/report/build", { - data: { project: "reports/dash-fixture", preset: "fast" }, - }); - expect(start.ok()).toBeTruthy(); - const { job } = (await start.json()) as { job: { id: string } }; - - // Poll /api/jobs rather than the page: the offline build is ~3 s, and a - // page load can land on either side of it. What must be true is that the - // job is visible through the ONE endpoint while it runs, with its step. - let seenRunning = false; - for (let i = 0; i < 100; i += 1) { - const j = (await (await request.get("/api/jobs")).json()) as { - running: { id: string; progress?: { step: number; of: number } } | null; - jobs: { id: string; state: string; href: string }[]; - }; - if (j.running?.id === job.id) { - seenRunning = true; - expect(j.running.progress?.of).toBeGreaterThan(0); - } - const mine = j.jobs.find((x) => x.id === job.id); - if (mine && mine.state !== "running") { - expect(mine.state).toBe("done"); - expect(mine.href).toBe("/browse/reports/dash-fixture"); - break; - } - await new Promise((r) => setTimeout(r, 200)); - } - expect(seenRunning).toBe(true); - - await page.goto("/"); - const row = page.locator(`[data-activity-id="${job.id}"]`); - await expect(row).toHaveAttribute("data-activity-state", "done"); - await expect(row.getByRole("link")).toHaveAttribute("href", "/browse/reports/dash-fixture"); - await expect(page.locator("[data-now=idle]")).toBeVisible(); -}); - -test("the sources panel counts never-checked projects from the index, not from a probe", async ({ page }) => { - await page.goto("/"); - const counts = await page.locator("[data-sources-counts]").getAttribute("data-sources-counts"); - const [never] = counts!.split("/").map(Number); - // The fixture has report projects nothing has preflighted (report-fixture, - // bench-fixture, the long-form ones); at least one is never-checked. - expect(never).toBeGreaterThan(0); - await expect(page.locator("[data-sources-list=never] [data-source-project='reports/longform-fixture']")).toBeVisible(); - await expect(page.locator("[data-action=check-sources]")).toBeEnabled(); -}); - -test("the dashboard opens the new-project menu prefilled from ?from=", async ({ page }) => { - await page.goto("/?from=testchan%2Fvid1"); - await expect(page.locator("[data-new-from]")).toHaveValue("testchan/vid1"); - await expect(page.locator("[data-new-seed]")).toBeVisible(); -}); diff --git a/umtool/e2e/inbox.spec.ts b/umtool/e2e/inbox.spec.ts @@ -0,0 +1,290 @@ +import { test, expect, type APIRequestContext, type Page } from "@playwright/test"; +import { execFileSync } from "node:child_process"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; +import * as urls from "./urls"; +import { warm, WARM_TIMEOUT } from "./warm"; + +// --------------------------------------------------------------------------- +// THE INBOX (plans/umtool-redesign.md, P3) at /, and the dashboard's panels +// where they went: /settings/system. The Inbox reads lib/inbox (P2a): one big +// number -- the calls waiting on active pieces -- then the cards, grouped and +// ranked, as one lit list, each with ONE primary action, Park and Mute. +// +// WRITES the fixture's REPORTS_ROOT/.umtool/lifecycle.json (zeta and +// polemic-alpha parked or done, then active again) and this browser's mutes. +// --------------------------------------------------------------------------- + +const HERE = path.dirname(fileURLToPath(import.meta.url)); +const UMTOOL = path.join(HERE, ".."); +const FIXTURE = path.join(UMTOOL, ".e2e-song"); + +const ZETA = "a:articles/zeta"; +const ALPHA = "a:priv/polemic-alpha"; +const CALL_GROUPS = ["your-call", "review", "blocking", "notes", "open"]; +const ORDER = ["your-call", "review", "blocking", "notes", "open", "ready-to-finish", "quiet"]; + +type Group = { id: string; decisions: number; hidden: number; cards: { piece: string | null; kind: string }[] }; +const groups = async (request: APIRequestContext): Promise<Group[]> => + ((await (await request.get("/api/browse/decisions")).json()) as { groups: Group[] }).groups; +const setLife = (request: APIRequestContext, piece: string, state: string) => + request.post("/api/pieces/lifecycle", { data: { piece, state } }); +const card = (page: Page, piece: string, kind: string) => page.locator(`[data-lit-line][data-piece='${piece}'][data-card='${kind}']`); + +test.beforeAll(async ({ playwright }) => { + test.setTimeout(WARM_TIMEOUT); + await warm(playwright, ["/", "/?hidden=1", "/api/browse/decisions", "/api/rail", "/settings/system", "/projects"]); +}); + +test("the big count is the cards in the five call groups; the groups come in their order; Quiet is folded", async ({ page, request }) => { + const g = await groups(request); + const calls = g.filter((x) => CALL_GROUPS.includes(x.id)).reduce((n, x) => n + x.cards.length, 0); + await page.goto(urls.homeHref()); + await expect(page.locator("[data-app-rail] [data-place=inbox]")).toHaveAttribute("aria-current", "page"); + // The machine's own calls (a required tool absent, a nearly full disk) are + // cards too; on the fixture with nothing probed there are none to count on. + const machine = await page.locator("[data-card^='machine-']").count(); + await expect(page.locator("[data-inbox-count]")).toHaveAttribute("data-inbox-count", String(calls + machine)); + await expect(page.locator("[data-rail-count=inbox]")).toHaveText(String(calls + machine)); + await expect(page.locator("[data-inbox-note]")).toContainText("quiet"); + + const shown = await page.locator("[data-lit-list] [data-group]").evaluateAll((els) => els.map((e) => e.getAttribute("data-group"))); + expect(shown.length).toBeGreaterThan(2); + expect(shown).toEqual(ORDER.filter((id) => shown.includes(id))); + + // Quiet is one folded line with its count; opening it shows its cards. + const quiet = page.locator("[data-group=quiet]"); + await expect(quiet).toHaveAttribute("data-collapsed", ""); + await expect(quiet.locator("[data-lit-line]")).toHaveCount(0); + await quiet.click(); + await expect(page.locator("[data-group=quiet] [data-lit-line]").first()).toBeVisible(); +}); + +test("j lights the next card, and only the lit card's action wears Signal", async ({ page }) => { + await page.goto(urls.homeHref()); + const list = page.locator("[data-lit-list]").first(); + await expect(list).toHaveAttribute("data-hydrated", ""); + const lines = list.locator("[data-lit-line]"); + await expect(lines.nth(0)).toHaveAttribute("data-lit", ""); + const bg = (i: number) => lines.nth(i).locator(".lit-go").evaluate((el) => getComputedStyle(el).backgroundColor); + const signal = await page.evaluate(() => { + const probe = document.createElement("i"); + probe.style.color = "var(--signal)"; + document.body.append(probe); + const c = getComputedStyle(probe).color; + probe.remove(); + return c; + }); + expect(await bg(0)).toBe(signal); + expect(await bg(1)).not.toBe(signal); + await page.locator("body").press("j"); + await expect(lines.nth(1)).toHaveAttribute("data-lit", ""); + await expect(lines.nth(1)).toBeFocused(); + expect(await bg(1)).toBe(signal); + expect(await bg(0)).not.toBe(signal); +}); + +test("Park hides a piece's calls, Undo brings them back; Show hidden lists them with Reactivate", async ({ page, request }) => { + try { + await page.goto(urls.homeHref()); + const ready = card(page, ZETA, "iteration-ready"); + await expect(ready).toBeVisible(); + const before = Number(await page.locator("[data-inbox-count]").getAttribute("data-inbox-count")); + + await ready.click(); + await ready.locator("[data-lifecycle-to=parked]").click(); + await expect(page.locator(`[data-undo='${ZETA}']`)).toContainText("Parked"); + await expect(page.locator(`[data-lit-line][data-piece='${ZETA}']`)).toHaveCount(0); + await expect(page.locator("[data-inbox-count]")).not.toHaveAttribute("data-inbox-count", String(before)); + await expect(page.locator("[data-show-hidden]")).toContainText(/^Show hidden \d+$/); + + await page.locator(`[data-undo='${ZETA}']`).getByRole("button", { name: "Undo" }).click(); + await expect(ready).toBeVisible(); + await expect(page.locator("[data-inbox-count]")).toHaveAttribute("data-inbox-count", String(before)); + + // Parked again, it is listed under Hidden, and Reactivate is its action. + expect((await setLife(request, ZETA, "parked")).status()).toBe(200); + await page.goto(urls.homeHref({ hidden: true })); + const hidden = page.locator(`[data-group=hidden] [data-lit-line][data-piece='${ZETA}']`).first(); + await expect(hidden).toBeVisible(); + await hidden.click(); + await hidden.locator("[data-lifecycle-to=active]").click(); + await expect(page.locator(`[data-group=hidden] [data-lit-line][data-piece='${ZETA}']`)).toHaveCount(0); + await expect(card(page, ZETA, "iteration-ready")).toBeVisible(); + } finally { + await setLife(request, ZETA, "active"); + } +}); + +test("Mark done on a piece that looks done takes it off the Inbox; Undo puts it back", async ({ page, request }) => { + try { + await page.goto(urls.homeHref()); + const done = page.locator(`[data-group=ready-to-finish] [data-piece='${ALPHA}'][data-card='looks-done']`); + await expect(done).toBeVisible(); + await done.click(); + await done.locator("[data-lifecycle-to=done]").click(); + await expect(page.locator(`[data-undo='${ALPHA}']`)).toContainText("Marked done"); + await expect(done).toHaveCount(0); + await page.locator(`[data-undo='${ALPHA}']`).getByRole("button", { name: "Undo" }).click(); + await expect(done).toBeVisible(); + } finally { + await setLife(request, ALPHA, "active"); + } +}); + +test("Mute is this browser's: a muted card leaves, Muted N shows it, Unmute brings it back", async ({ page }) => { + await page.goto(urls.homeHref()); + const ready = card(page, ZETA, "iteration-ready"); + await expect(ready).toBeVisible(); + await expect(page.locator("[data-lit-list]").first()).toHaveAttribute("data-hydrated", ""); + await ready.click(); + await ready.locator("[data-mute]").click(); + await expect(ready).toHaveCount(0); + // A reload keeps it muted: it is remembered here, not on the server. + await page.reload(); + await expect(card(page, ZETA, "iteration-ready")).toHaveCount(0); + await page.locator("[data-show-muted]").click(); + await expect(card(page, ZETA, "iteration-ready")).toBeVisible(); + await card(page, ZETA, "iteration-ready").locator("[data-mute]").click(); + await page.locator("[data-show-muted]").click(); + await expect(card(page, ZETA, "iteration-ready")).toBeVisible(); + await page.evaluate(() => localStorage.removeItem("umtool:inbox-muted")); +}); + +test("the Inbox opens the new-project form prefilled from ?from= (the editor's hand-off)", async ({ page }) => { + await page.goto(urls.homeHref({ from: "testchan/vid1" })); + await expect(page.locator("[data-new-from]")).toHaveValue("testchan/vid1"); + await expect(page.locator("[data-new-seed]")).toBeVisible(); +}); + +// --------------------------------------------------------------------------- +// /settings/system: the dashboard's panels. Everything on it is read from the +// index and the job registries; nothing on it shells out, and the tools panel +// proves that by saying "not checked" until somebody presses the button. +// --------------------------------------------------------------------------- + +test("the projects panel says exactly what /projects' header says", async ({ page }) => { + await page.goto(urls.projectsHref()); + const header = (await page.locator("header .micro").last().textContent())?.trim(); + expect(header).toMatch(/^\d+ projects · \d+ blocking · \d+ open$/); + + await page.goto(urls.systemHref()); + await expect(page.locator("[data-app-rail] [data-place=settings]")).toHaveAttribute("aria-current", "page"); + await expect(page.locator("[data-projects-note]")).toHaveText(header!); + // One row per kind, each with the six states as segments. + await expect(page.locator("[data-state-row]").first()).toBeVisible(); + const seg = page.locator("[data-state-seg]").first(); + await expect(seg).toHaveAttribute("href", /\/projects\?kind=.+&state=\w+/); + // The generation policy's current home is a link away. + await expect(page.locator("[data-policy-link]")).toHaveAttribute("href", urls.generationPolicyHref()); +}); + +test("tools read 'not checked' until the button is pressed, and the stubs are found", async ({ page, request }) => { + const before = await (await request.get("/api/doctor")).json(); + // Runs first in this file, and nothing else in the suite probes. + expect(before.checked).toBe(false); + + await page.goto(urls.systemHref()); + await expect(page.locator("[data-tools-checked]")).toHaveAttribute("data-tools-checked", "never"); + await page.locator("[data-action=doctor]").click(); + // The fixture's YTDLP_BIN and QRENCODE_BIN are node stubs that answer + // --version, so both are PRESENT with a version -- proof the probe read the + // same env the pipeline does. + await expect(page.locator("[data-tool=yt-dlp]")).toHaveAttribute("data-present", "1"); + await expect(page.locator("[data-tool=qrencode]")).toHaveAttribute("data-present", "1"); + await expect(page.locator("[data-tool=ffmpeg]")).toHaveAttribute("data-present", "1"); + + const after = await (await request.get("/api/doctor")).json(); + expect(after.checked).toBe(true); + expect(after.tools.find((t: { id: string }) => t.id === "yt-dlp").version).toContain("fixture"); +}); + +test("umtool doctor reports a deliberately bad path as absent, and exits 1", () => { + let code = 0; + let stdout = ""; + try { + stdout = execFileSync("node", ["bin/umtool.mjs", "doctor", "--json"], { + cwd: UMTOOL, + encoding: "utf8", + env: { + ...process.env, + YTDLP_BIN: path.join(FIXTURE, "bin", "definitely-not-here"), + QRENCODE_BIN: path.join(FIXTURE, "bin", "qrencode"), + // The fixture's roots, never this shell's media root or cache (empty = unset). + UMTOOL_MEDIA_DIR: "", + UMTOOL_CACHE_DIR: path.join(FIXTURE, "cache"), + }, + }); + } catch (e) { + const err = e as { status: number; stdout: string }; + code = err.status; + stdout = err.stdout; + } + const j = JSON.parse(stdout); + const yt = j.tools.find((t: { id: string }) => t.id === "yt-dlp"); + expect(yt.present).toBe(false); + expect(yt.required).toBe(true); + expect(j.ok).toBe(false); + // A script can gate on it: the report pipeline cannot run without yt-dlp. + expect(code).toBe(1); + expect(j.tools.find((t: { id: string }) => t.id === "qrencode").present).toBe(true); +}); + +test("/api/jobs has one shape over both registries", async ({ request }) => { + const j = await (await request.get("/api/jobs")).json(); + expect(j).toHaveProperty("running"); + expect(Array.isArray(j.jobs)).toBe(true); + for (const it of j.jobs) { + expect(["chain", "render"]).toContain(it.source); + expect(["running", "done", "failed"]).toContain(it.state); + expect(typeof it.href).toBe("string"); + } +}); + +test("a build shows in Now, then in the activity list as done", async ({ page, request }) => { + const start = await request.post("/api/report/build", { + data: { project: "reports/dash-fixture", preset: "fast" }, + }); + expect(start.ok()).toBeTruthy(); + const { job } = (await start.json()) as { job: { id: string } }; + + // Poll /api/jobs rather than the page: the offline build is ~3 s, and a + // page load can land on either side of it. What must be true is that the + // job is visible through the ONE endpoint while it runs, with its step. + let seenRunning = false; + for (let i = 0; i < 100; i += 1) { + const j = (await (await request.get("/api/jobs")).json()) as { + running: { id: string; progress?: { step: number; of: number } } | null; + jobs: { id: string; state: string; href: string }[]; + }; + if (j.running?.id === job.id) { + seenRunning = true; + expect(j.running.progress?.of).toBeGreaterThan(0); + } + const mine = j.jobs.find((x) => x.id === job.id); + if (mine && mine.state !== "running") { + expect(mine.state).toBe("done"); + expect(mine.href).toBe("/projects/reports/dash-fixture"); + break; + } + await new Promise((r) => setTimeout(r, 200)); + } + expect(seenRunning).toBe(true); + + await page.goto(urls.systemHref()); + const row = page.locator(`[data-activity-id="${job.id}"]`); + await expect(row).toHaveAttribute("data-activity-state", "done"); + await expect(row.getByRole("link")).toHaveAttribute("href", "/projects/reports/dash-fixture"); + await expect(page.locator("[data-now=idle]")).toBeVisible(); +}); + +test("the sources panel counts never-checked projects from the index, not from a probe", async ({ page }) => { + await page.goto(urls.systemHref()); + const counts = await page.locator("[data-sources-counts]").getAttribute("data-sources-counts"); + const [never] = counts!.split("/").map(Number); + // The fixture has report projects nothing has preflighted (report-fixture, + // bench-fixture, the long-form ones); at least one is never-checked. + expect(never).toBeGreaterThan(0); + await expect(page.locator("[data-sources-list=never] [data-source-project='reports/longform-fixture']")).toBeVisible(); + await expect(page.locator("[data-action=check-sources]")).toBeEnabled(); +}); diff --git a/umtool/e2e/redirects.spec.ts b/umtool/e2e/redirects.spec.ts @@ -0,0 +1,88 @@ +import { test, expect } from "@playwright/test"; +import { REDIRECTS } from "./urls"; + +// --------------------------------------------------------------------------- +// Every old page address (umtool/redirects.mjs, the table next.config.ts +// answers): requested with redirects OFF, each must be a 307 -- never a 308, +// which a browser caches forever, until P6 -- to the row's destination, with +// the query passed through. Then the destination itself must answer. +// +// The rows are read from the table, not copied here, so a new row is covered +// the day it is added. Parameters get a sample value; `:path*` gets two +// segments, the shape every project URL has. +// --------------------------------------------------------------------------- + +const SAMPLE: Record<string, string> = { + set: "mk-hooks", + path: "reports/report-fixture", + mode: "sort", +}; + +/** A row's source and destination with each `:param` given its sample. */ +function fill(pattern: string): string { + return pattern.replace(/:(\w+)(\([^)]*\))?\*?/g, (_m, name: string) => SAMPLE[name] ?? name); +} + +/** Next puts the request's query first, then the destination's own. */ +function expected(destination: string, query: string): string { + const dest = fill(destination); + if (!query) return dest; + const [path, own] = dest.split("?"); + return own ? `${path}?${query}&${own}` : `${path}?${query}`; +} + +/** An address as path + its parameters in order, so `+` and `%20` read alike. */ +function parts(href: string): [string, [string, string][]] { + const u = new URL(href, "http://x"); + return [u.pathname, [...u.searchParams.entries()]]; +} + +test("the table has the P3 rows, reserved /browse tools before the catch-all", () => { + const sources = REDIRECTS.map((r) => r.source); + const catchAll = sources.indexOf("/browse/:path*"); + expect(catchAll).toBeGreaterThan(0); + for (const s of ["/browse", "/browse/decisions", "/browse/find", "/browse/faces", "/browse/sources", "/browse/trim/:set", "/browse/at"]) { + expect(sources.indexOf(s), s).toBeGreaterThanOrEqual(0); + expect(sources.indexOf(s), `${s} must come before the catch-all`).toBeLessThan(catchAll); + } + for (const r of REDIRECTS) expect(r.permanent, r.source).toBe(false); +}); + +for (const row of REDIRECTS) { + const from = fill(row.source); + test(`${row.source} → ${row.destination} (307, query kept)`, async ({ request }) => { + for (const query of ["", "q=x+y&note=n1"]) { + const url = query ? `${from}?${query}` : from; + const res = await request.get(url, { maxRedirects: 0 }); + expect(res.status(), url).toBe(307); + expect(parts(res.headers()["location"]), url).toEqual(parts(expected(row.destination, query))); + } + // And where it lands answers (the escape hatch needs a project to open). + const landed = await request.get(row.source === "/browse/at" ? `${from}?path=find` : from); + expect(landed.status(), `${from} → ${landed.url()}`).toBe(200); + }); +} + +// Release 28's pages link the old addresses by hand (`/browse/${id}/review`, +// `…/narration`, `…/takes`, a clip bench); they ride the catch-all row. +for (const [old, now] of [ + ["/browse/reports/report-fixture/takes", "/projects/reports/report-fixture/takes"], + ["/browse/reports/report-fixture/clip/c01", "/projects/reports/report-fixture/clip/c01"], + ["/browse/reports/narration-review-fixture/narration", "/projects/reports/narration-review-fixture/narration"], + ["/browse/reports/draft-review-fixture/review", "/projects/reports/draft-review-fixture/review"], + ["/browse/reports/report-fixture?all=1&note=n1", "/projects/reports/report-fixture?all=1&note=n1"], +] as const) { + test(`${old} lands on ${now}`, async ({ request }) => { + const res = await request.get(old, { maxRedirects: 0 }); + expect(res.status()).toBe(307); + expect(parts(res.headers()["location"])).toEqual(parts(now)); + expect((await request.get(old)).status()).toBe(200); + }); +} + +test("a page that did not move is not redirected", async ({ request }) => { + for (const p of ["/", "/work", "/tools", "/projects", "/sites/priv", "/articles/delta", "/articles/new", "/settings/system"]) { + const res = await request.get(p, { maxRedirects: 0 }); + expect(res.status(), p).toBe(200); + } +});