Public: anyone can read this; the crew can change it.
Activity wording for build.shots events #9280
Check · Review · Land · Live done — Landed and live in production.
mason/forge:mason/9220-activity-wording-for-build-shots-events → main 1 commit fork
2 files
changed +32
−0
src/design/activity.ts +14
| @@ -73,6 +73,17 @@ export function eventVerb(event: ForgeEvent): string { | ||
| 73 | 73 | if (kind === "app.domain.verified") return `verified the domain ${which}`; |
| 74 | 74 | return `removed the domain ${which}`; |
| 75 | 75 | } |
| 76 | if (kind === "build.shots") { | |
| 77 | const label = payload["label"]; | |
| 78 | const pin = typeof label === "string" && label !== "" ? `the pin ${label}` : "a pin"; | |
| 79 | const change = payload["change"]; | |
| 80 | if (change === "added") return `added a screenshot to ${pin}`; | |
| 81 | if (change === "picked") return `picked screenshots from the deploy for ${pin}`; | |
| 82 | if (change === "moved") return `reordered the screenshots of ${pin}`; | |
| 83 | if (change === "captioned") return `captioned a screenshot of ${pin}`; | |
| 84 | if (change === "removed") return `removed a screenshot from ${pin}`; | |
| 85 | return `changed the screenshots of ${pin}`; | |
| 86 | } | |
| 76 | 87 | if (kind === "prompt.told") { |
| 77 | 88 | const issue = payload["issue"]; |
| 78 | 89 | return typeof issue === "number" |
| @@ -167,6 +178,9 @@ const WORDS: Record<string, string> = { | ||
| 167 | 178 | "origin.disconnected": "disconnected an origin", |
| 168 | 179 | "origin.needs_reauth": "needs to reconnect an origin", |
| 169 | 180 | "origin.mirror_reattached": "reconnected a frozen mirror to its origin", |
| 181 | "build.pinned": "pinned a build", | |
| 182 | "build.deleted": "removed a build pin", | |
| 183 | "build.noted": "noted a pinned build", | |
| 170 | 184 | "run.queued": "queued a run", |
| 171 | 185 | "run.started": "started a run", |
| 172 | 186 | "app.created": "made it an app", |
test/build-shots.test.ts +18
| @@ -24,6 +24,7 @@ import { createUser, getUserByName, type User } from "../src/core/users.ts"; | ||
| 24 | 24 | import { repoDir } from "../src/git/repos.ts"; |
| 25 | 25 | import { readShots, SHOT_MAX } from "../src/git/shots.ts"; |
| 26 | 26 | import { serve, type Servers } from "../src/http/server.ts"; |
| 27 | import { eventVerb } from "../src/design/activity.ts"; | |
| 27 | 28 | import { gitClientEnv } from "./helpers/git-client.ts"; |
| 28 | 29 | |
| 29 | 30 | const PNG = (n: number) => new Uint8Array([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, n, n]); |
| @@ -296,3 +297,20 @@ describe("pin screenshots", () => { | ||
| 296 | 297 | expect((await shots()).items).toEqual([]); |
| 297 | 298 | }); |
| 298 | 299 | }); |
| 300 | ||
| 301 | describe("activity wording for build events", () => { | |
| 302 | const say = (kind: string, payload: Record<string, unknown>) => | |
| 303 | eventVerb({ id: "e", kind, repoId: null, actorId: null, payload, createdAt: "" }); | |
| 304 | ||
| 305 | test("every shots change and every build kind has a line", () => { | |
| 306 | expect(say("build.shots", { label: "v1", change: "added" })).toBe("added a screenshot to the pin v1"); | |
| 307 | expect(say("build.shots", { label: "v1", change: "picked" })).toBe("picked screenshots from the deploy for the pin v1"); | |
| 308 | expect(say("build.shots", { label: "v1", change: "moved" })).toBe("reordered the screenshots of the pin v1"); | |
| 309 | expect(say("build.shots", { label: "v1", change: "captioned" })).toBe("captioned a screenshot of the pin v1"); | |
| 310 | expect(say("build.shots", { label: "v1", change: "removed" })).toBe("removed a screenshot from the pin v1"); | |
| 311 | expect(say("build.shots", {})).toBe("changed the screenshots of a pin"); | |
| 312 | expect(say("build.pinned", {})).toBe("pinned a build"); | |
| 313 | expect(say("build.deleted", {})).toBe("removed a build pin"); | |
| 314 | expect(say("build.noted", {})).toBe("noted a pinned build"); | |
| 315 | }); | |
| 316 | }); |
new above
offline