commit 0982eeb0cc28f523c2f8646a29c4bedee59458e3
parent 6ea4a2f2ad3a498c84cb70c4ef8229430e40ac9a
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Wed, 14 Oct 2026 06:06:31 -0400
umtool: e2e/piece.spec — the frame, the stepper, the Next card's action, the tab as the URL, a note's tab, the lifecycle chip round trip, the keys, 1366×768; the stepper's lighting is pure and unit-tested
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
5 files changed, 218 insertions(+), 11 deletions(-)
diff --git a/umtool/components/piece/PieceFrame.tsx b/umtool/components/piece/PieceFrame.tsx
@@ -76,7 +76,7 @@ export default function PieceFrame({
</>
}
below={
- <div className="flex flex-wrap items-center gap-x-6 gap-y-2" data-piece={frame.pieceId} data-piece-stage={frame.stage} data-piece-lifecycle={frame.lifecycle}>
+ <div className="flex flex-wrap items-center gap-x-6 gap-y-2" data-piece-frame={frame.pieceId} data-piece-stage={frame.stage} data-piece-lifecycle={frame.lifecycle}>
<Stepper steps={frame.steps} />
{article && (
<span className="text-[12.5px] text-muted" data-piece-article={`${article.site}/${article.report}`}>
diff --git a/umtool/e2e/piece.spec.ts b/umtool/e2e/piece.spec.ts
@@ -0,0 +1,178 @@
+import { test, expect, type Page } from "@playwright/test";
+import * as urls from "./urls";
+
+// ---------------------------------------------------------------------------
+// The piece page (plans/umtool-redesign.md, P4a-1): a report video's project
+// page is a frame -- the head (title, lifecycle chip, ⋯), the stage stepper,
+// the Next card on the Overview, seven link tabs -- around ONE tab of its
+// sections. The tab is the URL's `?tab=`; `1`–`7` switch tabs and `n` runs the
+// Next card's action once the page has hydrated.
+// ---------------------------------------------------------------------------
+
+const PROJECT = "reports/report-fixture";
+const PIECE = `p:${PROJECT}`;
+
+const tab = (page: Page, id: string) => page.getByTestId(`piece-tab-${id}`);
+const keysReady = (page: Page) => expect(page.locator("[data-piece-keys=ready]")).toBeAttached();
+
+test("the frame: title, trail, stepper at Video, the Next card, seven tabs with the Overview lit", async ({ page }) => {
+ const res = await page.goto(urls.projectHref(PROJECT));
+ expect(res?.status()).toBe(200);
+ const crumbs = page.getByRole("navigation", { name: "Breadcrumb" });
+ await expect(crumbs.locator("h1")).toHaveText("The Report Fixture");
+ await expect(crumbs).toContainText(PROJECT);
+ // The status line is still the head's last .micro.
+ await expect(page.locator("header .micro").last()).toHaveText(/4 clips · 2 other · 0:12 · not built/i);
+
+ // A project no article claims is its own piece; unbuilt, it is at Video.
+ const frame = page.locator(`[data-piece-frame="${PIECE}"]`);
+ await expect(frame).toHaveAttribute("data-piece-stage", "video");
+ const steps = page.getByRole("list", { name: "Stage" }).locator("li");
+ await expect(steps).toHaveText(["Research", "Article", "Video", "Deliver"]);
+ await expect(steps.nth(2)).toHaveAttribute("aria-current", "step");
+ await expect(steps.nth(1)).toHaveAttribute("data-step", "done");
+ await expect(steps.nth(3)).toHaveAttribute("data-step", "todo");
+
+ const tabs = page.getByRole("navigation", { name: "Piece" }).getByRole("link");
+ await expect(tabs).toHaveText([/^Overview/, /^Cut/, /^Media/, /^Build/, /^Deliver/, /^Sources/, /^History/]);
+ await expect(tab(page, "overview")).toHaveAttribute("aria-current", "page");
+ await expect(tab(page, "cut")).toHaveText("Cut4");
+ await expect(tab(page, "sources")).toHaveText("Sources2");
+
+ // The Overview: the Next card, the project's decisions, its stats -- and none
+ // of the other tabs' sections.
+ await expect(page.locator("[data-next]")).toBeVisible();
+ await expect(page.locator(`[data-project="${PROJECT}"]`)).toBeVisible();
+ await expect(page.locator("[data-piece-stats]")).toContainText("4 clips");
+ await expect(page.locator("[data-entry][data-kind]")).toHaveCount(0);
+ await expect(page.locator("[data-sources]")).toHaveCount(0);
+ await expect(page.getByTestId("onscreen-section")).toHaveCount(0);
+});
+
+test("the Next card is the piece's top Inbox call, and its one action goes where the Inbox's does", async ({ page, request }) => {
+ const inbox = (await (await request.get("/api/browse/decisions")).json()) as {
+ groups: { id: string; cards: { piece: string | null; kind: string; action: { label: string; href: string } }[] }[];
+ };
+ const top = inbox.groups.filter((g) => g.id !== "quiet").flatMap((g) => g.cards).find((c) => c.piece === PIECE);
+ expect(top, "the fixture's report has a call waiting").toBeTruthy();
+
+ await page.goto(urls.projectHref(PROJECT));
+ const next = page.locator("[data-next]");
+ await expect(next.locator("[data-next-kind]")).toHaveAttribute("data-next-kind", top!.kind);
+ const action = next.locator("[data-next-action] > a");
+ await expect(action).toHaveText(top!.action.label);
+ await expect(action).toHaveAttribute("href", top!.action.href);
+ await action.click();
+ await expect(page).toHaveURL(new RegExp(`${top!.action.href.replace(/[?]/g, "\\?")}$`));
+});
+
+test("the tab is the URL: ?tab=, ?all=1 on the Cut, a bad tab the Overview, and the old address lands", async ({ page }) => {
+ await page.goto(urls.section(PROJECT, "sources"));
+ await expect(tab(page, "sources")).toHaveAttribute("aria-current", "page");
+ await expect(page.locator("[data-sources]")).toBeVisible();
+ await expect(page.locator("[data-next]")).toHaveCount(0);
+
+ await page.goto(urls.projectHref(PROJECT, { all: true }));
+ await expect(tab(page, "cut")).toHaveAttribute("aria-current", "page");
+ await expect(page.locator("[data-entry=c01][data-kind]")).toBeVisible();
+
+ await page.goto(`${urls.projectHref(PROJECT)}?tab=nonsense`);
+ await expect(tab(page, "overview")).toHaveAttribute("aria-current", "page");
+
+ // /browse/<project> (before P3) rides the redirect to the Overview.
+ await page.goto(`/browse/${PROJECT}`);
+ await expect(page).toHaveURL(new RegExp(`/projects/${PROJECT}$`));
+ await expect(tab(page, "overview")).toHaveAttribute("aria-current", "page");
+
+ // Clicking a tab is a link: the address changes, the section is there.
+ await tab(page, "history").click();
+ await expect(page).toHaveURL(new RegExp(`/projects/${PROJECT}\\?tab=history$`));
+ await expect(page.locator("[data-provenance]")).toBeVisible();
+});
+
+test("a note's link opens the tab its anchor is drawn on", async ({ page, request }) => {
+ const add = await request.post(`/api/notes?project=${PROJECT}`, {
+ data: { op: { op: "add", text: "this row is long", anchor: { kind: "entry", entry: "c02" } } },
+ });
+ expect(add.status()).toBe(200);
+ const id = ((await add.json()) as { note: { id: string } }).note.id;
+ try {
+ await page.goto(urls.projectHref(PROJECT, { note: id }));
+ await expect(tab(page, "cut")).toHaveAttribute("aria-current", "page");
+ await expect(page.locator("[data-anchored-notes='c02']")).toHaveAttribute("data-open-notes", "1");
+ } finally {
+ await request.post(`/api/notes?project=${PROJECT}`, { data: { op: { op: "delete", id } } });
+ }
+});
+
+test("the lifecycle chip: Park, then Reactivate, each a round trip through the store", async ({ page, request }) => {
+ const life = async () =>
+ ((await (await request.get("/api/pieces")).json()) as { pieces: { id: string; lifecycle: string }[] }).pieces.find((p) => p.id === PIECE)
+ ?.lifecycle;
+ try {
+ await page.goto(urls.projectHref(PROJECT));
+ const chip = page.locator("[data-lifecycle-chip]");
+ await expect(chip).toHaveAttribute("data-lifecycle-chip", "active");
+ await chip.getByRole("button", { name: "Lifecycle: Active" }).click();
+ await chip.getByRole("button", { name: "Park" }).click();
+ await expect(page.locator("[data-lifecycle-chip]")).toHaveAttribute("data-lifecycle-chip", "parked");
+ await expect(page.locator(`[data-undo="${PIECE}"]`)).toContainText("Parked");
+ expect(await life()).toBe("parked");
+ // Parked, the piece's calls are hidden: the Next card offers the way back.
+ await expect(page.locator("[data-next-kind=lifecycle]")).toContainText("Parked");
+ await expect(page.locator("[data-next-action] > button")).toHaveText("Reactivate");
+
+ const chip2 = page.locator("[data-lifecycle-chip]");
+ await chip2.getByRole("button", { name: "Lifecycle: Parked" }).click();
+ await chip2.getByRole("button", { name: "Reactivate" }).click();
+ await expect(page.locator("[data-lifecycle-chip]")).toHaveAttribute("data-lifecycle-chip", "active");
+ expect(await life()).toBe("active");
+ } finally {
+ await request.post("/api/pieces/lifecycle", { data: { piece: PIECE, state: "active" } });
+ }
+});
+
+test("keys: 1–7 open the tabs, n runs the Next card's action; typing in a field is left alone", async ({ page }) => {
+ await page.goto(urls.projectHref(PROJECT));
+ await keysReady(page);
+ await page.keyboard.press("2");
+ await expect(page).toHaveURL(/\?tab=cut$/);
+ await expect(tab(page, "cut")).toHaveAttribute("aria-current", "page");
+ await keysReady(page);
+ await page.keyboard.press("7");
+ await expect(page).toHaveURL(/\?tab=history$/);
+ await keysReady(page);
+ // The snapshot label is a field: a digit typed there is a digit.
+ const label = page.locator("[data-revisions] input").first();
+ await label.fill("");
+ await label.press("3");
+ await expect(label).toHaveValue("3");
+ await expect(page).toHaveURL(/\?tab=history$/);
+ await label.evaluate((el: HTMLElement) => el.blur());
+ await page.keyboard.press("1");
+ await expect(tab(page, "overview")).toHaveAttribute("aria-current", "page");
+
+ await keysReady(page);
+ const href = await page.locator("[data-next-action] > a").getAttribute("href");
+ await page.keyboard.press("n");
+ await expect(page).toHaveURL(new RegExp(`${href!.replace(/[?]/g, "\\?")}$`));
+});
+
+test("an article's video: the stepper and the lifecycle are the article's, and the head links it", async ({ page }) => {
+ await page.goto(urls.projectHref("gen-projects/zeta/i1"));
+ await expect(page.locator("[data-piece-frame='a:articles/zeta']")).toBeVisible();
+ const link = page.locator("[data-piece-article='articles/zeta'] a");
+ await expect(link).toHaveAttribute("href", urls.articleHref({ site: "articles", id: "zeta" }));
+ // Its iterations, summarised on the Overview, with a way to all of them.
+ await expect(page.locator("[data-piece-iterations]")).toBeVisible();
+ await expect(page.locator("[data-piece-linked-article='articles/zeta']")).toContainText("made by its iteration");
+});
+
+test("fits 1366×768: the head, the tabs and the Next card's action without a horizontal scroll", async ({ page }) => {
+ await page.setViewportSize({ width: 1366, height: 768 });
+ await page.goto(urls.projectHref(PROJECT));
+ await expect(page.locator("[data-next-action] > a")).toBeInViewport();
+ await expect(tab(page, "history")).toBeInViewport();
+ const overflow = await page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth);
+ expect(overflow).toBeLessThanOrEqual(0);
+});
diff --git a/umtool/lib/pieces/frame.ts b/umtool/lib/pieces/frame.ts
@@ -3,7 +3,8 @@ import { summarizeGroups } from "../inbox/groups.mjs";
import { whatOf } from "../inbox/what.mjs";
import { lifecycleOf, readLifecycle, type LifecycleState } from "../lifecycle";
import { projectPieceId, readPieceGraph, type Piece } from "../pieces";
-import { STAGES, stageOf } from "../work/facets.mjs";
+import { stageOf } from "../work/facets.mjs";
+import { stepsOf } from "./tabs.mjs";
import type { Decision } from "../decisions";
// ---------------------------------------------------------------------------
@@ -37,15 +38,9 @@ export type PieceFrame = {
stage: string;
};
-const STAGE_LABEL: Record<string, string> = { research: "Research", article: "Article", video: "Video", deliver: "Deliver" };
-
-/** The four stages, lit for one bucket. A piece marked done has walked them all. */
+/** The four stages, lit for one bucket (lib/pieces/tabs.mjs). */
export function stepsFor(bucket: string, lifecycle: LifecycleState): PieceFrame["steps"] {
- const at = STAGES.indexOf(bucket);
- return STAGES.map((s: string, i: number) => ({
- label: STAGE_LABEL[s] ?? s,
- state: lifecycle === "done" || i < at ? "done" : i === at ? "current" : "todo",
- }));
+ return stepsOf(bucket, lifecycle) as PieceFrame["steps"];
}
export async function readPieceFrame(project: { id: string; state?: string | null }): Promise<PieceFrame> {
diff --git a/umtool/lib/pieces/tabs.mjs b/umtool/lib/pieces/tabs.mjs
@@ -15,6 +15,30 @@
// quote") opens the Cut, and `?note=<id>` opens the tab its anchor is drawn on
// (a timeline row's note on the Cut, a timed note on the final video on Build).
+/** The stepper's four stages, by Work's buckets (lib/work/facets.mjs STAGES). */
+export const STAGE_STEPS = [
+ { id: "research", label: "Research" },
+ { id: "article", label: "Article" },
+ { id: "video", label: "Video" },
+ { id: "deliver", label: "Deliver" },
+];
+
+/**
+ * The stepper, lit for one bucket: the stages before it done, it current, the
+ * rest to do. A piece marked done has walked them all.
+ *
+ * @param {string} bucket research | article | video | deliver
+ * @param {string} lifecycle active | parked | done
+ * @returns {{ label: string, state: "done" | "current" | "todo" }[]}
+ */
+export function stepsOf(bucket, lifecycle) {
+ const at = STAGE_STEPS.findIndex((s) => s.id === bucket);
+ return STAGE_STEPS.map((s, i) => ({
+ label: s.label,
+ state: lifecycle === "done" || i < at ? "done" : i === at ? "current" : "todo",
+ }));
+}
+
/** The tabs of a report-video piece, in order; the key that opens each is its position. */
export const PIECE_TABS = [
{ id: "overview", label: "Overview" },
diff --git a/umtool/lib/pieces/tabs.test.mjs b/umtool/lib/pieces/tabs.test.mjs
@@ -1,7 +1,8 @@
// A piece page's tabs: the address decides the tab, every section has one.
import assert from "node:assert/strict";
import test from "node:test";
-import { PIECE_TABS, PIECE_TAB_IDS, SECTION_TAB, tabOf, tabOfKey, tabOfNoteAnchor, tabOfSection } from "./tabs.mjs";
+import { STAGES } from "../work/facets.mjs";
+import { PIECE_TABS, PIECE_TAB_IDS, SECTION_TAB, STAGE_STEPS, stepsOf, tabOf, tabOfKey, tabOfNoteAnchor, tabOfSection } from "./tabs.mjs";
test("seven tabs, in the canvas's order; keys 1–7 open them", () => {
assert.deepEqual(PIECE_TAB_IDS, ["overview", "cut", "media", "build", "deliver", "sources", "history"]);
@@ -35,3 +36,12 @@ test("every section is on a real tab; an unknown one throws", () => {
assert.equal(tabOfSection("deliver"), "deliver");
assert.throws(() => tabOfSection("nope"), /no section "nope"/);
});
+
+test("the stepper: before the bucket done, it current, after it to do; a done piece walked them all", () => {
+ assert.deepEqual(STAGE_STEPS.map((s) => s.id), STAGES);
+ assert.deepEqual(stepsOf("video", "active").map((s) => s.state), ["done", "done", "current", "todo"]);
+ assert.deepEqual(stepsOf("research", "parked").map((s) => s.state), ["current", "todo", "todo", "todo"]);
+ assert.deepEqual(stepsOf("deliver", "active").map((s) => s.state), ["done", "done", "done", "current"]);
+ assert.deepEqual(stepsOf("video", "done").map((s) => s.state), ["done", "done", "done", "done"]);
+ assert.deepEqual(stepsOf("video", "active").map((s) => s.label), ["Research", "Article", "Video", "Deliver"]);
+});