create-ailk 0.36.0 → 0.37.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/README.md +20 -2
  2. package/component-catalog.json +40 -1
  3. package/component-catalog.md +7 -5
  4. package/dist/add-route.d.ts +5 -0
  5. package/dist/add-route.js +10 -2
  6. package/dist/surfaces.js +60 -19
  7. package/dist/sync-routes.d.ts +15 -1
  8. package/dist/sync-routes.js +58 -6
  9. package/dist/template-record.d.ts +11 -0
  10. package/dist/template-record.js +18 -0
  11. package/dist/update.d.ts +33 -1
  12. package/dist/update.js +439 -56
  13. package/package.json +3 -3
  14. package/templates/.env.example +17 -0
  15. package/templates/apps/api/.env.example +38 -0
  16. package/templates/apps/api/CLAUDE.md +3 -0
  17. package/templates/apps/api/src/lib/__mocks__/prisma.ts +7 -0
  18. package/templates/apps/mcp/CLAUDE.md +1 -1
  19. package/templates/apps/web/CLAUDE.md +28 -1
  20. package/templates/apps/web/app/[locale]/(auth)/reset-password/__tests__/return.test.tsx +179 -0
  21. package/templates/apps/web/app/[locale]/(auth)/reset-password/page.tsx +22 -2
  22. package/templates/apps/web/app/[locale]/(auth)/reset-password/reset-password-card.tsx +9 -2
  23. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/billing.test.tsx +240 -76
  24. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/general.test.tsx +242 -28
  25. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/hub-mode.test.tsx +369 -196
  26. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/item.test.tsx +26 -1
  27. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout.test.tsx +17 -6
  28. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-menu.test.tsx +51 -12
  29. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-popups.test.tsx +17 -2
  30. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/notifications.test.tsx +153 -2
  31. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +206 -23
  32. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/popups.test.tsx +150 -188
  33. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/privacy.test.tsx +235 -177
  34. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/rich-translator.ts +63 -0
  35. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/security.test.tsx +0 -3
  36. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/thread.test.tsx +340 -0
  37. package/templates/apps/web/app/[locale]/(authed)/account/account-data.ts +7 -5
  38. package/templates/apps/web/app/[locale]/(authed)/account/account-frame.tsx +19 -3
  39. package/templates/apps/web/app/[locale]/(authed)/account/actions.ts +8 -4
  40. package/templates/apps/web/app/[locale]/(authed)/account/appointments/[slug]/page.tsx +161 -0
  41. package/templates/apps/web/app/[locale]/(authed)/account/appointments/__tests__/page.test.tsx +426 -0
  42. package/templates/apps/web/app/[locale]/(authed)/account/appointments/appointments-data.ts +76 -0
  43. package/templates/apps/web/app/[locale]/(authed)/account/appointments/page.tsx +139 -0
  44. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/page.tsx +92 -24
  45. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/versions/[version]/file/route.ts +32 -1
  46. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/file-route.test.ts +76 -3
  47. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/page.test.tsx +290 -41
  48. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-data.ts +109 -11
  49. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/page.tsx +43 -44
  50. package/templates/apps/web/app/[locale]/(authed)/account/billing/__tests__/offerings.test.ts +99 -0
  51. package/templates/apps/web/app/[locale]/(authed)/account/billing/offerings.ts +123 -0
  52. package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +309 -113
  53. package/templates/apps/web/app/[locale]/(authed)/account/billing-source.ts +192 -65
  54. package/templates/apps/web/app/[locale]/(authed)/account/components/request-quote.tsx +52 -7
  55. package/templates/apps/web/app/[locale]/(authed)/account/general/account-name.ts +36 -0
  56. package/templates/apps/web/app/[locale]/(authed)/account/general/contact-actions.ts +70 -2
  57. package/templates/apps/web/app/[locale]/(authed)/account/general/contact-details.tsx +42 -0
  58. package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +55 -58
  59. package/templates/apps/web/app/[locale]/(authed)/account/general/phone-verification.tsx +2 -1
  60. package/templates/apps/web/app/[locale]/(authed)/account/general/photo-actions.ts +73 -0
  61. package/templates/apps/web/app/[locale]/(authed)/account/general/profile-form.tsx +12 -9
  62. package/templates/apps/web/app/[locale]/(authed)/account/general/profile-source.ts +18 -4
  63. package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +20 -2
  64. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/member-thread-composer.tsx +43 -0
  65. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/page.tsx +125 -0
  66. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-data.ts +88 -0
  67. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-write.ts +31 -0
  68. package/templates/apps/web/app/[locale]/(authed)/account/layout.tsx +3 -2
  69. package/templates/apps/web/app/[locale]/(authed)/account/new-menu.tsx +33 -8
  70. package/templates/apps/web/app/[locale]/(authed)/account/new-popups.tsx +31 -52
  71. package/templates/apps/web/app/[locale]/(authed)/account/notifications/page.tsx +44 -4
  72. package/templates/apps/web/app/[locale]/(authed)/account/page.tsx +69 -49
  73. package/templates/apps/web/app/[locale]/(authed)/account/privacy/__tests__/export-route.test.ts +173 -0
  74. package/templates/apps/web/app/[locale]/(authed)/account/privacy/actions.ts +42 -4
  75. package/templates/apps/web/app/[locale]/(authed)/account/privacy/export/route.ts +102 -0
  76. package/templates/apps/web/app/[locale]/(authed)/account/privacy/page.tsx +147 -137
  77. package/templates/apps/web/app/[locale]/(authed)/account/security/__tests__/hub-variant.test.tsx +258 -0
  78. package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +18 -21
  79. package/templates/apps/web/app/[locale]/(authed)/account/security/security-panel.tsx +34 -6
  80. package/templates/apps/web/app/[locale]/(authed)/account/security/security-source.ts +37 -7
  81. package/templates/apps/web/app/[locale]/(authed)/account/settings/page.tsx +0 -2
  82. package/templates/apps/web/app/[locale]/(authed)/account/settings-frame.tsx +8 -5
  83. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsClient.tsx +3 -2
  84. package/templates/apps/web/app/api/auth/hub/password/__tests__/return.test.ts +86 -0
  85. package/templates/apps/web/app/api/auth/hub/password/__tests__/route.test.ts +368 -0
  86. package/templates/apps/web/app/api/auth/hub/password/return.ts +86 -0
  87. package/templates/apps/web/app/api/auth/hub/password/route.ts +171 -0
  88. package/templates/apps/web/app/api/hub-session/__tests__/routes.test.ts +263 -0
  89. package/templates/apps/web/app/api/hub-session/password/return/route.ts +69 -0
  90. package/templates/apps/web/app/api/hub-session/password/route.ts +106 -0
  91. package/templates/apps/web/lib/__tests__/account-config.test.ts +129 -1
  92. package/templates/apps/web/lib/__tests__/offerings-pricing.test.ts +33 -0
  93. package/templates/apps/web/lib/account-config.ts +132 -8
  94. package/templates/apps/web/lib/auth-routes.ts +11 -6
  95. package/templates/apps/web/lib/offerings-pricing.ts +4 -1
  96. package/templates/apps/web/messages/en.json +156 -80
  97. package/versions.json +48 -48
  98. package/templates/apps/web/app/[locale]/(authed)/account/components/schedule-service.tsx +0 -276
  99. package/templates/apps/web/app/[locale]/(authed)/account/components/send-message.tsx +0 -128
  100. package/templates/apps/web/app/[locale]/(authed)/account/settings/__tests__/theme-modes.test.ts +0 -42
  101. package/templates/apps/web/app/[locale]/(authed)/account/settings/theme-modes.ts +0 -40
@@ -7,16 +7,23 @@
7
7
  * RSCs they are, with the api-client's `member.artifacts` as the one mocked
8
8
  * read. Covers:
9
9
  * - the list renders `AccountListFrame`'s table in the read's order (newest
10
- * delivery first, never by title), each row's Latest/Delivered/Review
11
- * cells and caption reading the LATEST version's own number, its
12
- * delivery date and the review state — approval first, then the latest
13
- * version's review — and the facet nav's counts over every artifact;
10
+ * delivery first, never by title) with the columns Title · Type · Version
11
+ * · Status (#11161): Type the LATEST version's file type or Link, Version
12
+ * its number, Status the piece's STAGE as a tag with the review of the
13
+ * latest version (approval first, then that version's review) as a second
14
+ * tag — never one combined state; the facet nav reads "All Artifacts"
15
+ * then a "Status" group of the workspace's declared stages, every one in
16
+ * declared order and counted over every artifact; the lead line stays;
14
17
  * - a 404 (and a 401/403 while the email is unverified) is the empty line;
15
18
  * any other failure is the error row with Retry and no frame (7423 D12);
16
19
  * - the artifact page lists versions newest first, each with its number,
17
20
  * delivery date and note, and Download (this site's file route) or View
18
21
  * (an https link, new tab, noopener) — and nothing for a link that is not
19
- * https; no deliverer is shown;
22
+ * https; no deliverer is shown; its status is the stage, the review a tag
23
+ * beside it and on the reviewed version;
24
+ * - an image or a PDF version renders inline (#11161 AC-4) from the same
25
+ * route's preview mode with Download beside it; any other file keeps
26
+ * Download alone;
20
27
  * - the review form shows on the latest version only, only while the
21
28
  * artifact is not approved and that version has no review; after a
22
29
  * Request changes the page says the next version will appear there;
@@ -29,7 +36,7 @@
29
36
  * deliverable renders exactly as before.
30
37
  */
31
38
 
32
- import { fireEvent, render, screen, within } from "@testing-library/react";
39
+ import { act, fireEvent, render, screen, within } from "@testing-library/react";
33
40
 
34
41
  jest.mock("next-intl/server", () => {
35
42
  const msgs: unknown = require("../../../../../../messages/en.json");
@@ -50,13 +57,16 @@ jest.mock("next-intl/server", () => {
50
57
  ) => {
51
58
  const ns = typeof arg === "string" ? arg : (arg.namespace ?? "");
52
59
  const messages = dig(msgs, ns);
53
- return (key: string, values?: Record<string, unknown>): string => {
60
+ const t = (key: string, values?: Record<string, unknown>): string => {
54
61
  const value = dig(messages, key);
55
62
  if (typeof value !== "string") return `${ns}.${key}`;
56
63
  return value.replace(/\{(\w+)\}/g, (m, name: string) =>
57
64
  values && name in values ? String(values[name]) : m,
58
65
  );
59
66
  };
67
+ // #11175: the dated messages carry a `<date>` tag and render through `t.rich`.
68
+ const { withRich } = require("../../__tests__/rich-translator") as typeof import("../../__tests__/rich-translator");
69
+ return withRich(t, (key: string) => dig(messages, key), ns);
60
70
  },
61
71
  };
62
72
  });
@@ -154,8 +164,11 @@ function version(v: VersionFixture) {
154
164
  };
155
165
  }
156
166
 
157
- function ok(items: unknown[]) {
158
- return { ok: true, body: { items } };
167
+ const STAGES = ["requested", "in-progress", "in-review", "delivered"];
168
+ const STAGE_LABELS = ["Requested", "In progress", "In review", "Delivered"];
169
+
170
+ function ok(items: unknown[], stages: string[] = STAGES, stageLabels: string[] = STAGE_LABELS) {
171
+ return { ok: true, body: { items, stages, stageLabels } };
159
172
  }
160
173
 
161
174
  function refused(status: number, code = "x") {
@@ -173,12 +186,22 @@ const ZEBRA = {
173
186
  id: ID.zebra,
174
187
  title: "Zebra logo",
175
188
  approvedAt: "2026-09-25T09:00:00.000Z",
176
- versions: [version({ version: 3, deliveredAt: "2026-10-03T12:00:00.000Z" })],
189
+ stage: "delivered",
190
+ stageLabel: "Delivered",
191
+ versions: [
192
+ version({
193
+ version: 3,
194
+ file: { filename: "zebra.png", contentType: "image/png", byteSize: 10 },
195
+ deliveredAt: "2026-10-03T12:00:00.000Z",
196
+ }),
197
+ ],
177
198
  };
178
199
  const MANGO = {
179
200
  id: ID.mango,
180
201
  title: "Mango brief",
181
202
  approvedAt: null,
203
+ stage: "in-progress",
204
+ stageLabel: "In progress",
182
205
  versions: [
183
206
  version({
184
207
  version: 2,
@@ -193,7 +216,11 @@ const ALPHA = {
193
216
  id: ID.alpha,
194
217
  title: "Alpha deck",
195
218
  approvedAt: null,
196
- versions: [version({ version: 1, deliveredAt: "2026-09-18T12:00:00.000Z" })],
219
+ stage: "in-review",
220
+ stageLabel: "In review",
221
+ versions: [
222
+ version({ version: 1, link: "https://files.example.com/alpha", deliveredAt: "2026-09-18T12:00:00.000Z" }),
223
+ ],
197
224
  };
198
225
 
199
226
  beforeEach(() => {
@@ -224,12 +251,26 @@ async function renderArtifact(
224
251
  );
225
252
  }
226
253
 
227
- const medium = (iso: string): string =>
254
+ /** The zone `LocalTime` reads in this jsdom — jest's pinned UTC, until a case mocks the viewer's. */
255
+ const VIEWER_TIME_ZONE = Intl.DateTimeFormat().resolvedOptions().timeZone;
256
+ const MOUNTAIN = "America/Denver";
257
+
258
+ const medium = (iso: string, timeZone = VIEWER_TIME_ZONE): string =>
228
259
  new Intl.DateTimeFormat("en", {
229
260
  dateStyle: "medium",
230
- timeZone: "UTC",
261
+ timeZone,
231
262
  }).format(new Date(iso));
232
263
 
264
+ /** The browser's zone, as `LocalTime` reads it through `resolvedOptions()`. */
265
+ function viewerZone(timeZone: string): void {
266
+ const real = Intl.DateTimeFormat.prototype.resolvedOptions;
267
+ jest
268
+ .spyOn(Intl.DateTimeFormat.prototype, "resolvedOptions")
269
+ .mockImplementation(function resolvedOptions(this: Intl.DateTimeFormat) {
270
+ return { ...real.call(this), timeZone };
271
+ });
272
+ }
273
+
233
274
  function facetItems(): HTMLElement[] {
234
275
  return within(screen.getByTestId("artifacts-facets")).getAllByTestId(
235
276
  /^artifacts-facets-item-/,
@@ -237,13 +278,19 @@ function facetItems(): HTMLElement[] {
237
278
  }
238
279
 
239
280
  describe("/account/artifacts (D3, AC-3)", () => {
240
- it("renders the table in the read's order, each row's Latest/Delivered/Review and the nav's counts", async () => {
281
+ it("renders Title · Type · Version · Status in the read's order, the stage and review as tags, and the Status facets in declared order", async () => {
241
282
  await renderList();
242
283
  expect(screen.getByRole("heading", { level: 1 })).toHaveTextContent(
243
284
  "Artifacts",
244
285
  );
286
+ expect(screen.getByTestId("artifacts")).toHaveTextContent(
287
+ "Work delivered to you, newest first.",
288
+ );
245
289
 
246
290
  const table = screen.getByTestId("artifacts-table");
291
+ expect(
292
+ within(table).getAllByRole("columnheader").map((h) => h.textContent),
293
+ ).toEqual(["Title", "Type", "Version", "Status"]);
247
294
  const titles = within(table).getAllByTestId(/-title$/);
248
295
  expect(titles.map((t) => t.textContent)).toEqual([
249
296
  "Zebra logo",
@@ -256,49 +303,134 @@ describe("/account/artifacts (D3, AC-3)", () => {
256
303
  `/account/artifacts/${ID.alpha}`,
257
304
  ]);
258
305
 
306
+ // Zebra: a PNG, version 3, delivered + approved.
259
307
  const zebraRow = screen.getByTestId(`artifacts-table-row-${ID.zebra}`);
260
- expect(zebraRow).toHaveTextContent("Version 3");
261
- expect(zebraRow).toHaveTextContent(medium("2026-10-03T12:00:00.000Z"));
262
- expect(zebraRow).toHaveTextContent("Approved");
263
-
308
+ const zebraCells = within(zebraRow).getAllByRole("cell");
309
+ expect(zebraCells[1]).toHaveTextContent(/^PNG image$/);
310
+ expect(zebraCells[2]).toHaveTextContent(/^Version 3$/);
311
+ const zebraStatus = screen.getByTestId(`artifacts-table-row-${ID.zebra}-status`);
312
+ expect(within(zebraStatus).getByText("Delivered")).toBeInTheDocument();
313
+ expect(within(zebraStatus).getByText("Approved")).toBeInTheDocument();
314
+ // Never the delivery date as a column, never one combined state.
315
+ expect(zebraRow).not.toHaveTextContent(medium("2026-10-03T12:00:00.000Z"));
316
+
317
+ // Mango: a PDF, version 2 (never its older version), in progress + changes requested.
264
318
  const mangoRow = screen.getByTestId(`artifacts-table-row-${ID.mango}`);
265
- expect(mangoRow).toHaveTextContent(medium("2026-10-02T12:00:00.000Z"));
266
- expect(mangoRow).not.toHaveTextContent(medium("2026-09-20T12:00:00.000Z"));
267
- expect(mangoRow).toHaveTextContent("Changes requested");
268
-
319
+ const mangoCells = within(mangoRow).getAllByRole("cell");
320
+ expect(mangoCells[1]).toHaveTextContent(/^PDF$/);
321
+ expect(mangoCells[2]).toHaveTextContent(/^Version 2$/);
322
+ const mangoStatus = screen.getByTestId(`artifacts-table-row-${ID.mango}-status`);
323
+ expect(within(mangoStatus).getByText("In progress")).toBeInTheDocument();
324
+ expect(within(mangoStatus).getByText("Changes requested")).toBeInTheDocument();
325
+
326
+ // Alpha: a link, version 1, in review, unreviewed — the stage alone, no review tag.
269
327
  const alphaRow = screen.getByTestId(`artifacts-table-row-${ID.alpha}`);
270
- expect(alphaRow).toHaveTextContent("Ready for review");
328
+ expect(within(alphaRow).getAllByRole("cell")[1]).toHaveTextContent(/^Link$/);
329
+ const alphaStatus = screen.getByTestId(`artifacts-table-row-${ID.alpha}-status`);
330
+ expect(alphaStatus).toHaveTextContent(/^In review$/);
331
+ expect(screen.queryByText("Ready for review")).toBeNull();
271
332
 
272
333
  const captions = screen.getAllByTestId("artifacts-row");
273
334
  // The phone rows render the same read, so their captions exist in the DOM
274
335
  // even though only the table is visible at this (desktop) width.
275
336
  expect(captions.map((c) => c.textContent)).toEqual([
276
- expect.stringContaining("Version 3 · Approved"),
277
- expect.stringContaining("Version 2 · Changes requested"),
278
- expect.stringContaining("Version 1 · Ready for review"),
337
+ expect.stringContaining("Version 3 · Delivered · Approved"),
338
+ expect.stringContaining("Version 2 · In progress · Changes requested"),
339
+ expect.stringContaining("Version 1 · In review"),
279
340
  ]);
280
341
 
342
+ // "All Artifacts" first (Title Case), then the declared stages in order
343
+ // under the Status group, each counted over every artifact, zeros kept.
281
344
  const items = facetItems();
282
345
  expect(items.map((i) => i.getAttribute("data-testid"))).toEqual([
283
346
  "artifacts-facets-item-all",
284
- "artifacts-facets-item-ready",
285
- "artifacts-facets-item-changes-requested",
286
- "artifacts-facets-item-approved",
347
+ "artifacts-facets-item-requested",
348
+ "artifacts-facets-item-in-progress",
349
+ "artifacts-facets-item-in-review",
350
+ "artifacts-facets-item-delivered",
287
351
  ]);
288
- expect(items[0]).toHaveTextContent("All artifacts");
352
+ expect(items[0]).toHaveTextContent("All Artifacts");
289
353
  expect(items[0]).toHaveTextContent("3");
290
- expect(items[1]).toHaveTextContent("1");
354
+ expect(items[1]).toHaveTextContent("Requested");
355
+ expect(items[1]).toHaveTextContent("0");
356
+ expect(items[2]).toHaveTextContent("In progress");
291
357
  expect(items[2]).toHaveTextContent("1");
358
+ expect(items[3]).toHaveTextContent("In review");
292
359
  expect(items[3]).toHaveTextContent("1");
360
+ expect(items[4]).toHaveTextContent("Delivered");
361
+ expect(items[4]).toHaveTextContent("1");
362
+ expect(screen.getByTestId("artifacts-facets")).toHaveTextContent("Status");
363
+ expect(screen.getByTestId("artifacts-facets")).not.toHaveTextContent("Review");
293
364
  expect(screen.queryByTestId("inbox-error")).toBeNull();
294
365
  });
295
366
 
367
+ it("a workspace's own stage list drives the facets: every declared slug, in its order, read by its served label — never the slug", async () => {
368
+ mockArtifacts.mockResolvedValue(
369
+ ok(
370
+ [
371
+ { ...ALPHA, stage: "final-qa", stageLabel: "Final check" },
372
+ { ...MANGO, stage: "scoping", stageLabel: "Scoping" },
373
+ ],
374
+ ["scoping", "drafting", "final-qa", "done"],
375
+ ["Scoping", "Drafting", "Final check", "Done"],
376
+ ),
377
+ );
378
+ await renderList();
379
+ const items = facetItems();
380
+ expect(items.map((i) => i.getAttribute("data-testid"))).toEqual([
381
+ "artifacts-facets-item-all",
382
+ "artifacts-facets-item-scoping",
383
+ "artifacts-facets-item-drafting",
384
+ "artifacts-facets-item-final-qa",
385
+ "artifacts-facets-item-done",
386
+ ]);
387
+ expect(items[1]).toHaveTextContent("Scoping");
388
+ expect(items[2]).toHaveTextContent("Drafting");
389
+ expect(items[2]).toHaveTextContent("0");
390
+ expect(items[3]).toHaveTextContent("Final check");
391
+ expect(items[4]).toHaveTextContent("Done");
392
+ expect(screen.getByTestId("artifacts-facets")).not.toHaveTextContent("final-qa");
393
+ expect(screen.getByTestId(`artifacts-table-row-${ID.alpha}-status`)).toHaveTextContent(
394
+ /^Final check$/,
395
+ );
396
+ });
397
+
398
+ it("a hub older than the labels serves slugs alone: each reads as its default label (the four defaults' own, others title-cased)", async () => {
399
+ mockArtifacts.mockResolvedValue({
400
+ ok: true,
401
+ body: {
402
+ items: [{ ...ALPHA, stageLabel: undefined, stage: "final-qa" }],
403
+ stages: ["requested", "final-qa"],
404
+ },
405
+ });
406
+ await renderList();
407
+ const items = facetItems();
408
+ expect(items[1]).toHaveTextContent("Requested");
409
+ expect(items[2]).toHaveTextContent("Final Qa");
410
+ expect(screen.getByTestId(`artifacts-table-row-${ID.alpha}-status`)).toHaveTextContent(
411
+ /^Final Qa$/,
412
+ );
413
+ });
414
+
415
+ it("an older hub that serves no stages at all falls back to the four default facets", async () => {
416
+ mockArtifacts.mockResolvedValue({ ok: true, body: { items: [ALPHA] } });
417
+ await renderList();
418
+ expect(facetItems().map((i) => i.getAttribute("data-testid"))).toEqual([
419
+ "artifacts-facets-item-all",
420
+ "artifacts-facets-item-requested",
421
+ "artifacts-facets-item-in-progress",
422
+ "artifacts-facets-item-in-review",
423
+ "artifacts-facets-item-delivered",
424
+ ]);
425
+ });
426
+
296
427
  it("a 404 read shows the empty line and a nav at 0, not an error row", async () => {
297
428
  mockArtifacts.mockResolvedValue(refused(404, "not_found"));
298
429
  await renderList();
299
430
  expect(screen.getByTestId("artifacts-empty")).toHaveTextContent(
300
431
  "Nothing has been delivered to you yet.",
301
432
  );
433
+ expect(facetItems()).toHaveLength(5);
302
434
  for (const item of facetItems()) expect(item).toHaveTextContent("0");
303
435
  expect(screen.queryByTestId("inbox-error")).toBeNull();
304
436
  });
@@ -348,6 +480,8 @@ const VERSIONED = {
348
480
  id: ID.alpha,
349
481
  title: "Alpha deck",
350
482
  approvedAt: null,
483
+ stage: "in-review",
484
+ stageLabel: "In review",
351
485
  versions: [
352
486
  version({
353
487
  version: 3,
@@ -402,6 +536,8 @@ describe("/account/artifacts/[pieceId] (D4, AC-2)", () => {
402
536
  const block = screen.getByTestId(`artifact-version-${v.version}`);
403
537
  expect(block).toHaveTextContent(`Version ${v.version}`);
404
538
  expect(block).toHaveTextContent(`Delivered ${medium(v.deliveredAt)}`);
539
+ // #11175: the day is a <time> carrying the instant, read in the viewer's zone.
540
+ expect(within(block).getByText(medium(v.deliveredAt))).toHaveAttribute("dateTime", v.deliveredAt);
405
541
  expect(block).toHaveTextContent(v.note!.replace("\n", " "));
406
542
  }
407
543
  expect(
@@ -421,6 +557,14 @@ describe("/account/artifacts/[pieceId] (D4, AC-2)", () => {
421
557
  );
422
558
  expect(download).toHaveTextContent("Download brief-v3.pdf");
423
559
  expect(screen.queryByTestId("artifact-version-3-view")).toBeNull();
560
+ // The status is the stage; the unreviewed latest version adds no tag.
561
+ expect(screen.getByTestId("artifact-status")).toHaveTextContent("In review");
562
+ expect(screen.queryByTestId("artifact-tag-0")).toBeNull();
563
+ // Version 2's review is a tag on the version, beside its dated line.
564
+ expect(screen.getByTestId("artifact-version-2-review")).toHaveTextContent(
565
+ "Changes requested",
566
+ );
567
+ expect(screen.queryByTestId("artifact-version-3-review")).toBeNull();
424
568
 
425
569
  const view = screen.getByTestId("artifact-version-2-view");
426
570
  expect(view).toHaveAttribute("href", "https://files.example.com/v2");
@@ -434,6 +578,73 @@ describe("/account/artifacts/[pieceId] (D4, AC-2)", () => {
434
578
  expect(screen.queryByTestId("artifact-version-1-download")).toBeNull();
435
579
  });
436
580
 
581
+ it("a PDF version renders inline through the route's preview mode, with Download beside it (AC-4)", async () => {
582
+ await renderArtifact(ID.alpha);
583
+ const v3 = screen.getByTestId("artifact-version-3");
584
+ const preview = within(v3).getByTestId("artifact-version-3-preview-pdf");
585
+ expect(preview.querySelector('[data-testid="document-viewer"]')).toBeInTheDocument();
586
+ expect(within(v3).getByTestId("artifact-version-3-download")).toBeInTheDocument();
587
+ // Download is the page's own, not the reader's toolbar.
588
+ expect(screen.queryByTestId("document-viewer-download")).toBeNull();
589
+ expect(screen.queryByTestId("artifact-version-3-preview-image")).toBeNull();
590
+ // Link versions have no preview.
591
+ expect(screen.queryByTestId("artifact-version-2-preview-pdf")).toBeNull();
592
+ await act(async () => {
593
+ await new Promise((resolve) => setTimeout(resolve, 0));
594
+ });
595
+ });
596
+
597
+ it("an image version renders inline as the image, served through the preview mode, with Download beside it (AC-4)", async () => {
598
+ mockArtifacts.mockResolvedValue(
599
+ ok([
600
+ {
601
+ ...VERSIONED,
602
+ versions: [
603
+ version({
604
+ version: 1,
605
+ file: { filename: "mark.png", contentType: "image/png", byteSize: 2048 },
606
+ deliveredAt: "2026-09-12T10:00:00.000Z",
607
+ }),
608
+ ],
609
+ },
610
+ ]),
611
+ );
612
+ await renderArtifact(ID.alpha);
613
+ const v1 = screen.getByTestId("artifact-version-1");
614
+ const target = within(v1).getByTestId("artifact-version-1-preview-image");
615
+ expect(target).toHaveAttribute("aria-label", "Open mark.png full size");
616
+ expect(target.querySelector("img")).toHaveAttribute(
617
+ "src",
618
+ `/account/artifacts/${ID.alpha}/versions/1/file?inline=1`,
619
+ );
620
+ expect(within(v1).getByTestId("artifact-version-1-download")).toHaveAttribute(
621
+ "href",
622
+ `/account/artifacts/${ID.alpha}/versions/1/file`,
623
+ );
624
+ expect(screen.queryByTestId("artifact-version-1-preview-pdf")).toBeNull();
625
+ });
626
+
627
+ it("any other file type keeps Download alone — no preview", async () => {
628
+ mockArtifacts.mockResolvedValue(
629
+ ok([
630
+ {
631
+ ...VERSIONED,
632
+ versions: [
633
+ version({
634
+ version: 1,
635
+ file: { filename: "deck.zip", contentType: "application/zip", byteSize: 2048 },
636
+ deliveredAt: "2026-09-12T10:00:00.000Z",
637
+ }),
638
+ ],
639
+ },
640
+ ]),
641
+ );
642
+ await renderArtifact(ID.alpha);
643
+ expect(screen.getByTestId("artifact-version-1-download")).toBeInTheDocument();
644
+ expect(screen.queryByTestId("artifact-version-1-preview-image")).toBeNull();
645
+ expect(screen.queryByTestId("artifact-version-1-preview-pdf")).toBeNull();
646
+ });
647
+
437
648
  it("an encoded id segment still finds the artifact", async () => {
438
649
  await renderArtifact(encodeURIComponent(ID.alpha));
439
650
  expect(screen.getByRole("heading", { level: 1 })).toHaveTextContent(
@@ -477,24 +688,57 @@ describe("the review form's place (D4, C3, AC-4)", () => {
477
688
  within(screen.getByTestId("artifact-version-3")).getByTestId(id),
478
689
  ).toBeInTheDocument();
479
690
  }
480
- expect(screen.getByTestId("artifact-status")).toHaveTextContent(
481
- "Ready for review",
482
- );
691
+ expect(screen.getByTestId("artifact-status")).toHaveTextContent("In review");
692
+ expect(screen.queryByTestId("artifact-tag-0")).toBeNull();
483
693
  expect(screen.queryByTestId("artifact-review-waiting")).toBeNull();
484
694
  });
485
695
 
486
- it("is absent everywhere once the artifact is approved, which shows Approved and the date", async () => {
696
+ it("is absent everywhere once the artifact is approved, which shows the stage, an Approved tag and the date", async () => {
487
697
  const approvedAt = "2026-09-30T08:00:00.000Z";
488
- mockArtifacts.mockResolvedValue(ok([{ ...VERSIONED, approvedAt }]));
698
+ mockArtifacts.mockResolvedValue(
699
+ ok([{ ...VERSIONED, approvedAt, stage: "delivered", stageLabel: "Done" }]),
700
+ );
489
701
  await renderArtifact(ID.alpha);
490
702
  for (const id of FORM_IDS) expect(screen.queryByTestId(id)).toBeNull();
491
- expect(screen.getByTestId("artifact-status")).toHaveTextContent("Approved");
703
+ // The status reads the provider's label for the terminal stage — here renamed Done.
704
+ expect(screen.getByTestId("artifact-status")).toHaveTextContent("Done");
705
+ expect(screen.getByTestId("artifact-tag-0")).toHaveTextContent("Approved");
492
706
  expect(screen.getByTestId("artifact")).toHaveTextContent(
493
707
  `Approved ${medium(approvedAt)}`,
494
708
  );
495
709
  expect(screen.queryByTestId("artifact-review-waiting")).toBeNull();
496
710
  });
497
711
 
712
+ it("reads every dated line in the viewer's zone once the browser has one (#11175)", async () => {
713
+ viewerZone(MOUNTAIN);
714
+ // 03:30Z is still the evening before in Mountain time, so each day rolls back.
715
+ const approvedAt = "2026-09-30T03:30:00.000Z";
716
+ const [latest, ...rest] = VERSIONED.versions;
717
+ mockArtifacts.mockResolvedValue(
718
+ ok([
719
+ {
720
+ ...VERSIONED,
721
+ approvedAt,
722
+ stage: "delivered",
723
+ stageLabel: "Delivered",
724
+ versions: [
725
+ { ...latest!, deliveredAt: "2026-09-13T03:30:00.000Z", review: "approved", reviewedAt: approvedAt },
726
+ ...rest,
727
+ ],
728
+ },
729
+ ]),
730
+ );
731
+ await renderArtifact(ID.alpha);
732
+ expect(medium(approvedAt, MOUNTAIN)).toBe("Sep 29, 2026");
733
+ expect(screen.getByTestId("artifact")).toHaveTextContent(`Approved ${medium(approvedAt, MOUNTAIN)}`);
734
+ const v3 = screen.getByTestId("artifact-version-3");
735
+ expect(v3).toHaveTextContent(`Delivered ${medium("2026-09-13T03:30:00.000Z", MOUNTAIN)}`);
736
+ expect(v3).toHaveTextContent(`You approved this version on ${medium(approvedAt, MOUNTAIN)}.`);
737
+ const day = within(v3).getByText(medium("2026-09-13T03:30:00.000Z", MOUNTAIN));
738
+ expect(day.tagName).toBe("TIME");
739
+ expect(day).toHaveAttribute("title", "MDT");
740
+ });
741
+
498
742
  it("is absent on a latest version the member already asked changes on, which says the next version will appear here", async () => {
499
743
  const [latest, ...rest] = VERSIONED.versions;
500
744
  const reviewed = {
@@ -520,9 +764,11 @@ describe("the review form's place (D4, C3, AC-4)", () => {
520
764
  `You requested changes on ${medium("2026-09-13T10:00:00.000Z")}.`,
521
765
  );
522
766
  expect(within(v3).getByText("Tighten the logo")).toBeInTheDocument();
523
- expect(screen.getByTestId("artifact-status")).toHaveTextContent(
767
+ expect(within(v3).getByTestId("artifact-version-3-review")).toHaveTextContent(
524
768
  "Changes requested",
525
769
  );
770
+ expect(screen.getByTestId("artifact-status")).toHaveTextContent("In review");
771
+ expect(screen.getByTestId("artifact-tag-0")).toHaveTextContent("Changes requested");
526
772
  });
527
773
  });
528
774
 
@@ -532,6 +778,8 @@ const PROPOSAL = {
532
778
  id: PROPOSAL_ID,
533
779
  title: "Site redesign",
534
780
  approvedAt: null,
781
+ stage: "in-review",
782
+ stageLabel: "In review",
535
783
  kind: "proposal",
536
784
  price: { amount: 120000, currency: "usd" },
537
785
  payment: null,
@@ -633,7 +881,7 @@ describe("a proposal (#8516 D19, AC-3, AC-4)", () => {
633
881
  expect(screen.queryByTestId("artifact-review-approve")).toBeNull();
634
882
  expect(screen.queryByTestId("artifact-paid")).toBeNull();
635
883
  expect(screen.queryByTestId("artifact-paid-pending")).toBeNull();
636
- expect(screen.getByTestId("artifact-status")).toHaveTextContent("Approved");
884
+ expect(screen.getByTestId("artifact-tag-0")).toHaveTextContent("Approved");
637
885
  });
638
886
 
639
887
  it("once paid, the latest version says Paid <date> and offers no Pay now", async () => {
@@ -645,6 +893,7 @@ describe("a proposal (#8516 D19, AC-3, AC-4)", () => {
645
893
  expect(within(v1).getByTestId("artifact-paid")).toHaveTextContent(
646
894
  `Paid ${medium(PAID_AT)}`,
647
895
  );
896
+ expect(within(v1).getByText(medium(PAID_AT))).toHaveAttribute("dateTime", PAID_AT);
648
897
  for (const id of PAY_IDS) expect(screen.queryByTestId(id)).toBeNull();
649
898
  });
650
899
 
@@ -674,8 +923,8 @@ describe("a proposal (#8516 D19, AC-3, AC-4)", () => {
674
923
  await renderList();
675
924
  const captions = screen.getAllByTestId("artifacts-row");
676
925
  expect(captions.map((c) => c.textContent)).toEqual([
677
- expect.stringContaining("Proposal · Version 1 · Ready for review"),
678
- expect.stringContaining("Version 1 · Ready for review"),
926
+ expect.stringContaining("Proposal · Version 1 · In review"),
927
+ expect.stringContaining("Version 1 · In review"),
679
928
  ]);
680
929
  expect(captions[1]!.textContent).not.toContain("Proposal");
681
930
  const row = screen.getByTestId(`artifacts-table-row-${PROPOSAL_ID}`);