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
@@ -12,6 +12,8 @@
12
12
  * 4. A message whose `action` is `onboarding` has an Open onboarding
13
13
  * action to the locale's `/account/onboarding`; a message with no
14
14
  * action has none (#8515 D6, AC-4).
15
+ * 5. #11152 — a conversation kind's item page links to the member thread
16
+ * page (Open conversation); a stacked kind's does not.
15
17
  *
16
18
  * The `purchase` kind reads `member.purchases` (#8231 D5); the `message`
17
19
  * kind reads `member.messages`.
@@ -132,7 +134,8 @@ describe("one Inbox item", () => {
132
134
  await renderItem("purchase", "fc_done");
133
135
  expect(screen.getByRole("heading", { level: 1 })).toHaveTextContent("pro");
134
136
  expect(screen.getByText("Inbox").closest("a")).toHaveAttribute("href", "/account");
135
- expect(screen.getAllByText("My purchases").length).toBeGreaterThan(0);
137
+ // #11149 — the records read Orders on both sides of the seam.
138
+ expect(screen.getAllByText("My orders").length).toBeGreaterThan(0);
136
139
  const fields = screen.getByTestId("account-item-fields");
137
140
  expect(within(fields).getByText("Amount")).toBeInTheDocument();
138
141
  expect(within(fields).getByText("Period")).toBeInTheDocument();
@@ -169,6 +172,28 @@ describe("one Inbox item", () => {
169
172
  });
170
173
  });
171
174
 
175
+ describe("#11152 AC-1 — the message kind's item page links to the thread", () => {
176
+ it("a message carries Open conversation to the locale's /account/inbox/thread, before its own actions", async () => {
177
+ await renderItem("message", "int_onboarding", "fr");
178
+ const desk = screen.getByTestId("account-item-head-actions");
179
+ const actions = within(desk).getAllByRole("link");
180
+ expect(actions.map((a) => a.textContent)).toEqual(["Open conversation", "Open onboarding"]);
181
+ expect(within(desk).getByTestId("account-item-action-thread-desk")).toHaveAttribute(
182
+ "href",
183
+ "/fr/account/inbox/thread",
184
+ );
185
+ expect(screen.getByTestId("account-item-action-thread-mobile")).toHaveAttribute(
186
+ "href",
187
+ "/fr/account/inbox/thread",
188
+ );
189
+ });
190
+
191
+ it("a stacked kind's item page carries no thread link", async () => {
192
+ await renderItem("purchase", "fc_done");
193
+ expect(screen.queryByTestId("account-item-action-thread-desk")).not.toBeInTheDocument();
194
+ });
195
+ });
196
+
172
197
  describe("#11007 AC-3a-9 — a message renders through the chat layout", () => {
173
198
  it("the message is a start-side MessageBubble under RecordHeader, captioned with when it was sent", async () => {
174
199
  await renderItem("message", "int_plain");
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * Covers:
6
6
  * 1. The rail: the site logo as the top tile (a link home), then Inbox and
7
- * a Library group holding Artifacts — each selected on its own paths,
7
+ * a Library group holding Artifacts and Appointments (#11154) — each selected on its own paths,
8
8
  * no row on a Settings page — and a footer of the avatar and ? only.
9
9
  * No Settings row (#8334: Settings lives in the avatar menu, as on the
10
10
  * Admin).
@@ -47,13 +47,17 @@ jest.mock("next-intl/server", () => {
47
47
  getTranslations: async (arg: string | { namespace?: string; locale?: string }) => {
48
48
  const ns = typeof arg === "string" ? arg : (arg.namespace ?? "");
49
49
  const messages = dig(msgs, ns);
50
- return (key: string, values?: Record<string, unknown>): string => {
50
+ const t = (key: string, values?: Record<string, unknown>): string => {
51
51
  const value = dig(messages, key);
52
52
  if (typeof value !== "string") return `${ns}.${key}`;
53
53
  return value.replace(/\{(\w+)\}/g, (m, name: string) =>
54
54
  values && name in values ? String(values[name]) : m,
55
55
  );
56
56
  };
57
+ // #11164: the one-main-landmark cases render the real Privacy page,
58
+ // whose lead is a `t.rich` message with a `<policy>` tag.
59
+ const { withRich } = require("./rich-translator") as typeof import("./rich-translator");
60
+ return withRich(t, (key: string) => dig(messages, key), ns);
57
61
  },
58
62
  };
59
63
  });
@@ -88,6 +92,8 @@ jest.mock("@working-theory/api-client", () => ({
88
92
  // #8441 — the Inbox page's New-menu availability reads, for § one main landmark.
89
93
  meetingTypes: (...args: unknown[]) => mockMemberNotFound(...args),
90
94
  requestForm: (...args: unknown[]) => mockMemberNotFound(...args),
95
+ // #11150 — the onboarding-steps read.
96
+ welcome: (...args: unknown[]) => mockMemberNotFound(...args),
91
97
  },
92
98
  hubSignIn: { me: jest.fn() },
93
99
  // #8765 D7 — the interstitial's read; `complete: true` unless a case says otherwise.
@@ -241,19 +247,21 @@ describe("the account rail (D13, AC-17)", () => {
241
247
  .filter((link) => link.getAttribute("data-testid") !== "account-site-logo");
242
248
  }
243
249
 
244
- it("the rows are Inbox, then Artifacts under Library — no Settings row (#8231 D1, #8334)", async () => {
250
+ it("the rows are Inbox, then Artifacts and Appointments under Library — no Settings row (#8231 D1, #8334, #11154)", async () => {
245
251
  await renderLayout();
246
252
  const rows = railRows();
247
253
  expect(rows.map((row) => [row.textContent, row.getAttribute("href")])).toEqual([
248
254
  ["Inbox", "/account"],
249
255
  ["Artifacts", "/account/artifacts"],
256
+ ["Appointments", "/account/appointments"],
250
257
  ]);
251
258
  expect(rows[0]).toHaveAttribute("aria-current", "page");
252
- // Artifacts sits in the Library group.
259
+ // Artifacts and Appointments sit in the Library group.
253
260
  const heading = screen.getByTestId("sidebar-group-heading-library");
254
261
  expect(heading).toHaveTextContent("Library");
255
262
  const library = heading.parentElement as HTMLElement;
256
263
  expect(within(library).getByText("Artifacts")).toBeInTheDocument();
264
+ expect(within(library).getByText("Appointments")).toBeInTheDocument();
257
265
  // #8334 — Settings is nowhere in the rail, at any viewport: not a row, not
258
266
  // a tab. The avatar menu is its one route (the next describe).
259
267
  expect(within(screen.getByTestId("sidebar-desktop")).queryByText("Settings")).not.toBeInTheDocument();
@@ -265,7 +273,9 @@ describe("the account rail (D13, AC-17)", () => {
265
273
  ["/account/inbox/purchase/x", "Inbox"],
266
274
  ["/account/artifacts", "Artifacts"],
267
275
  ["/account/artifacts/p1", "Artifacts"],
268
- ])("on %s only %s is selected (#8231 D1)", async (path, selected) => {
276
+ ["/account/appointments", "Appointments"],
277
+ ["/account/appointments/intro", "Appointments"],
278
+ ])("on %s only %s is selected (#8231 D1, #11154)", async (path, selected) => {
269
279
  mockPathname = path;
270
280
  await renderLayout();
271
281
  const current = railRows().filter((row) => row.getAttribute("aria-current") === "page");
@@ -283,7 +293,7 @@ describe("the account rail (D13, AC-17)", () => {
283
293
  mockPathname = path;
284
294
  await renderLayout(path.startsWith("/fr/") ? "fr" : "en");
285
295
  const rows = railRows();
286
- expect(rows).toHaveLength(2);
296
+ expect(rows).toHaveLength(3);
287
297
  expect(rows.some((row) => row.hasAttribute("aria-current"))).toBe(false);
288
298
  });
289
299
 
@@ -294,6 +304,7 @@ describe("the account rail (D13, AC-17)", () => {
294
304
  expect(rows.map((row) => row.getAttribute("href"))).toEqual([
295
305
  "/fr/account",
296
306
  "/fr/account/artifacts",
307
+ "/fr/account/appointments",
297
308
  ]);
298
309
  expect(rows[1]).toHaveAttribute("aria-current", "page");
299
310
  });
@@ -3,10 +3,12 @@
3
3
  * docs/specs/8233-member-new-menu-the-new-spec.md D1–D4; AC-1, AC-2, AC-6).
4
4
  *
5
5
  * Covers:
6
- * 1. New over the Inbox offers exactly Schedule service · Request quote ·
7
- * Send message, in that order, as menu items that are not links; each
8
- * opens a popup over the Inbox titled with its label, and nothing
9
- * navigates (AC-1).
6
+ * 1. New over the Inbox offers exactly Schedule appointment · Request quote
7
+ * · Send message, in that order, as menu items; Request quote opens a
8
+ * popup over the Inbox titled with its label and nothing navigates
9
+ * (AC-1), while Schedule appointment navigates to /account/appointments
10
+ * (#11154) and Send message to the member thread page,
11
+ * /account/inbox/thread (#11152) — neither opens a popup.
10
12
  * 2. Each row is offered only while its member read answers: a 404, or a
11
13
  * switched-off request form, leaves it out; every read 404 (a Free
12
14
  * build) leaves no New button and no error row; a failed read drops
@@ -79,8 +81,22 @@ jest.mock("@working-theory/api-client", () => ({
79
81
  status: 404,
80
82
  body: { ok: false, error: { code: "not_found", message: "Not found" } },
81
83
  }),
84
+ // #11150 — the onboarding-steps read; 404 here (no workspace module).
85
+ welcome: () =>
86
+ Promise.resolve({
87
+ ok: false,
88
+ status: 404,
89
+ body: { ok: false, error: { code: "not_found", message: "Not found" } },
90
+ }),
82
91
  meetingTypes: (...args: unknown[]) => mockMemberMeetingTypes(...args),
83
92
  requestForm: (...args: unknown[]) => mockMemberRequestForm(...args),
93
+ // #11157 — the member's own sent requests, the Messages tab; 404 here.
94
+ requests: () =>
95
+ Promise.resolve({
96
+ ok: false,
97
+ status: 404,
98
+ body: { ok: false, error: { code: "not_found", message: "Not found" } },
99
+ }),
84
100
  },
85
101
  // #8765 D7 — the layout's agreements read: complete, so the frame renders.
86
102
  consent: {
@@ -140,7 +156,9 @@ const FORM = {
140
156
  form: { title: "Request a quote", defaultLocale: "en", steps: requestQuoteFlowConfig.steps },
141
157
  };
142
158
 
143
- const LABELS = ["Schedule service", "Request quote", "Send message"];
159
+ const LABELS = ["Schedule appointment", "Request quote", "Send message"];
160
+ /** The rows that open a popup — Request quote alone: Schedule appointment (#11154) and Send message (#11152) are links. */
161
+ const POPUP_LABELS = LABELS.slice(1, 2);
144
162
 
145
163
  beforeAll(() => {
146
164
  // Radix menus open on pointerdown; jsdom has no PointerEvent.
@@ -184,18 +202,39 @@ function openMenu(trigger = screen.getByTestId("account-new-menu-trigger")): str
184
202
  .map((item) => item.textContent ?? "");
185
203
  }
186
204
 
187
- describe("New offers the three actions, each a popup over the Inbox (AC-1)", () => {
188
- it("lists exactly Schedule service · Request quote · Send message, none a link", async () => {
205
+ describe("New offers the three actions — one popup over the Inbox and two page links (AC-1)", () => {
206
+ it("lists exactly Schedule appointment · Request quote · Send message", async () => {
189
207
  await renderInbox();
190
208
  expect(openMenu()).toEqual(LABELS);
191
209
  const content = screen.getByTestId("account-new-menu-content");
192
- expect(content.querySelector("a")).toBeNull();
193
210
  expect(within(content).getByTestId("account-new-menu-item-schedule-service")).toBeInTheDocument();
194
211
  expect(within(content).getByTestId("account-new-menu-item-request-quote")).toBeInTheDocument();
195
212
  expect(within(content).getByTestId("account-new-menu-item-send-message")).toBeInTheDocument();
196
213
  });
197
214
 
198
- it.each(LABELS.map((label, i) => [label, i] as const))(
215
+ it("Schedule appointment navigates to /account/appointments and opens no popup (#11154)", async () => {
216
+ await renderInbox();
217
+ openMenu();
218
+ const row = screen.getByTestId("account-new-menu-item-schedule-service");
219
+ expect(row).toHaveAttribute("data-href", "/account/appointments");
220
+ fireEvent.click(row);
221
+ expect(mockPush).toHaveBeenCalledWith("/account/appointments");
222
+ expect(screen.queryByTestId("account-new-popup")).not.toBeInTheDocument();
223
+ expect(mockRefresh).not.toHaveBeenCalled();
224
+ });
225
+
226
+ it("Send message navigates to the member thread page and opens no popup (#11152)", async () => {
227
+ await renderInbox();
228
+ openMenu();
229
+ const row = screen.getByTestId("account-new-menu-item-send-message");
230
+ expect(row).toHaveAttribute("data-href", "/account/inbox/thread");
231
+ fireEvent.click(row);
232
+ expect(mockPush).toHaveBeenCalledWith("/account/inbox/thread");
233
+ expect(screen.queryByTestId("account-new-popup")).not.toBeInTheDocument();
234
+ expect(mockRefresh).not.toHaveBeenCalled();
235
+ });
236
+
237
+ it.each(POPUP_LABELS.map((label, i) => [label, i + 1] as const))(
199
238
  "%s opens a popup titled with its label over the Inbox, and never navigates",
200
239
  async (label, index) => {
201
240
  await renderInbox();
@@ -226,11 +265,11 @@ describe("each action is offered only while its read answers (AC-2)", () => {
226
265
  ])("requestForm %s → no Request quote", async (_name, answer) => {
227
266
  mockMemberRequestForm.mockResolvedValue(answer);
228
267
  await renderInbox();
229
- expect(openMenu()).toEqual(["Schedule service", "Send message"]);
268
+ expect(openMenu()).toEqual(["Schedule appointment", "Send message"]);
230
269
  expect(screen.queryByTestId("inbox-error")).not.toBeInTheDocument();
231
270
  });
232
271
 
233
- it("meetingTypes { items: [] } → Schedule service is still offered (its popup says why)", async () => {
272
+ it("meetingTypes { items: [] } → Schedule appointment is still offered (its page shows the empty line)", async () => {
234
273
  mockMemberMeetingTypes.mockResolvedValue(ok({ items: [] }));
235
274
  await renderInbox();
236
275
  expect(openMenu()).toEqual(LABELS);
@@ -249,7 +288,7 @@ describe("each action is offered only while its read answers (AC-2)", () => {
249
288
  it("requestForm 500 → no Request quote, and the Inbox error row (D12 parity)", async () => {
250
289
  mockMemberRequestForm.mockResolvedValue(failure(500));
251
290
  await renderInbox();
252
- expect(openMenu()).toEqual(["Schedule service", "Send message"]);
291
+ expect(openMenu()).toEqual(["Schedule appointment", "Send message"]);
253
292
  expect(screen.getByTestId("inbox-error")).toBeInTheDocument();
254
293
  });
255
294
 
@@ -9,6 +9,9 @@
9
9
  * (the same `available` function the config exports).
10
10
  * 2. Each popup's props carry no credential and no email — only the locale
11
11
  * and strings (SEC-8233-1).
12
+ * 3. Schedule appointment is a link row (#11154): it carries the
13
+ * Appointments page's path and binds no popup; so is Send message
14
+ * (#11152), which navigates to the member thread page.
12
15
  */
13
16
 
14
17
  jest.mock("@working-theory/api-client", () => ({
@@ -66,10 +69,22 @@ describe("newActions — the config's actions with their popups (#8233 D1, D2)",
66
69
  });
67
70
  });
68
71
 
69
- it.each(["schedule-service", "request-quote", "send-message"])(
72
+ it("schedule-service is a link to the Appointments page and binds no popup (#11154)", () => {
73
+ const schedule = action("schedule-service");
74
+ expect(schedule.href).toBe("/account/appointments");
75
+ expect(schedule.renderPopup).toBeUndefined();
76
+ });
77
+
78
+ it("send-message is a link to the member thread page and binds no popup (#11152)", () => {
79
+ const send = action("send-message");
80
+ expect(send.href).toBe("/account/inbox/thread");
81
+ expect(send.renderPopup).toBeUndefined();
82
+ });
83
+
84
+ it.each(["request-quote"])(
70
85
  "%s renders a popup whose props carry no cookie and no email (SEC-8233-1)",
71
86
  (id) => {
72
- const popup = action(id).renderPopup(ctx()) as ReactElement<
87
+ const popup = action(id).renderPopup!(ctx()) as ReactElement<
73
88
  Record<string, unknown>
74
89
  >;
75
90
  const props = JSON.stringify(popup.props);
@@ -1,9 +1,12 @@
1
1
  /**
2
2
  * Tests for /[locale]/account/notifications — User settings › Notifications
3
- * (#8339 D8; #8438 D15, AC-8). Always renders (decision A): one
3
+ * (#8339 D8; #8438 D15, AC-8; #11163 AC-1). Always renders (decision A): one
4
4
  * `ConsentSwitchList` of the registry's `area: "communications"` purposes,
5
5
  * or one empty line with none declared. The cookie-settings link moved to
6
- * Privacy (#8438 D14) — this tab no longer renders it.
6
+ * Privacy (#8438 D14) — this tab no longer renders it. #11163: the three
7
+ * shipped purposes render as Email notifications · Onboarding · Marketing —
8
+ * a title, a line and a switch, never the consent statement — over the
9
+ * always-sent line.
7
10
  */
8
11
  import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
9
12
  import { tmpdir } from "node:os";
@@ -72,6 +75,13 @@ jest.mock("next/navigation", () => ({
72
75
  redirect: jest.fn(),
73
76
  }));
74
77
 
78
+ import {
79
+ EMAIL_NOTIFICATIONS_PURPOSE_ID,
80
+ NEWSLETTER_PURPOSE_ID,
81
+ NEWSLETTER_TERMS_STATEMENT,
82
+ ONBOARDING_PURPOSE_ID,
83
+ } from "@working-theory/validation";
84
+
75
85
  import Page from "../notifications/page";
76
86
 
77
87
  const SESSION = {
@@ -109,6 +119,31 @@ function communicationsPurpose(
109
119
  };
110
120
  }
111
121
 
122
+ /**
123
+ * The three rows `GET /v1/member/consents` serves from the shipped registry
124
+ * (#11163 AC-2), as the route answers them for a caller with no row yet:
125
+ * the two preferences effective on, the newsletter consent effective off.
126
+ */
127
+ function shippedCommunicationsPurposes() {
128
+ return [
129
+ {
130
+ ...communicationsPurpose({ id: EMAIL_NOTIFICATIONS_PURPOSE_ID, kind: "preference", effective: true }),
131
+ description: "Updates about your work here: messages, deliverables and requests.",
132
+ statement: "Email me updates about my work here: messages, deliverables and requests.",
133
+ },
134
+ {
135
+ ...communicationsPurpose({ id: ONBOARDING_PURPOSE_ID, kind: "preference", effective: true }),
136
+ description: "Getting-started steps after your first sign-in.",
137
+ statement: "Email me getting-started steps after my first sign-in.",
138
+ },
139
+ {
140
+ ...communicationsPurpose({ id: NEWSLETTER_PURPOSE_ID, kind: "consent", effective: false }),
141
+ description: "This site's newsletter by email",
142
+ statement: NEWSLETTER_TERMS_STATEMENT,
143
+ },
144
+ ];
145
+ }
146
+
112
147
  let contentRoot: string;
113
148
 
114
149
  beforeEach(() => {
@@ -158,6 +193,9 @@ describe("AC-8 — always present, one empty line with no communications purpose
158
193
  expect(screen.getByTestId("account-notifications-empty")).toHaveTextContent(
159
194
  "There's nothing to set here yet.",
160
195
  );
196
+ expect(screen.getByTestId("account-notifications-foot")).toHaveTextContent(
197
+ "Receipts, sign-in links and security notices are always sent.",
198
+ );
161
199
  expect(screen.queryByTestId("account-cookie-settings")).not.toBeInTheDocument();
162
200
  expect(screen.queryByTestId("account-notifications")).not.toBeInTheDocument();
163
201
  });
@@ -168,6 +206,97 @@ describe("AC-8 — always present, one empty line with no communications purpose
168
206
  });
169
207
  });
170
208
 
209
+ describe("#11163 AC-1 — the three rows: Email notifications · Onboarding · Marketing", () => {
210
+ beforeEach(() => {
211
+ mockConsents.mockResolvedValue(ok({ purposes: shippedCommunicationsPurposes() }));
212
+ });
213
+
214
+ it("renders exactly three switch rows in registry order, each a title, a one-line description and a switch", async () => {
215
+ await renderPage();
216
+ const list = screen.getByTestId("account-notifications");
217
+ const rows = within(list).getAllByTestId(/^account-notifications-[a-z_]+$/);
218
+ expect(rows.map((row) => row.getAttribute("data-testid"))).toEqual([
219
+ "account-notifications-email_notifications",
220
+ "account-notifications-onboarding",
221
+ "account-notifications-newsletter",
222
+ ]);
223
+ expect(within(list).getAllByRole("switch")).toHaveLength(3);
224
+
225
+ const titles = rows.map((row) => within(row).getByTestId(/-label$/).textContent);
226
+ expect(titles).toEqual(["Email notifications", "Onboarding", "Marketing"]);
227
+ expect(within(rows[0]!).getByText("Updates about your work here: messages, deliverables and requests.")).toBeInTheDocument();
228
+ expect(within(rows[1]!).getByText("Getting-started steps after your first sign-in.")).toBeInTheDocument();
229
+ expect(within(rows[2]!).getByText("This site's newsletter and offers by email.")).toBeInTheDocument();
230
+ for (const row of rows) {
231
+ expect(within(row).getByRole("switch")).toHaveAccessibleName(
232
+ within(row).getByTestId(/-label$/).textContent!,
233
+ );
234
+ }
235
+ });
236
+
237
+ it("defaults on · on · off with no row, and shows no date line until a state exists", async () => {
238
+ await renderPage();
239
+ expect(screen.getByTestId("account-notifications-email_notifications-switch")).toBeChecked();
240
+ expect(screen.getByTestId("account-notifications-onboarding-switch")).toBeChecked();
241
+ expect(screen.getByTestId("account-notifications-newsletter-switch")).not.toBeChecked();
242
+ expect(screen.queryAllByTestId(/^account-notifications-[a-z_]+-date$/)).toHaveLength(0);
243
+ });
244
+
245
+ it("renders the date line beneath a row once a state exists", async () => {
246
+ const [emailRow, onboarding, newsletter] = shippedCommunicationsPurposes();
247
+ mockConsents.mockResolvedValue(
248
+ ok({
249
+ purposes: [
250
+ {
251
+ ...emailRow!,
252
+ effective: false,
253
+ state: { granted: false, at: "2026-11-01T12:00:00.000Z", source: "account_settings", policyVersion: 1 },
254
+ },
255
+ onboarding!,
256
+ newsletter!,
257
+ ],
258
+ }),
259
+ );
260
+ await renderPage();
261
+ expect(screen.getByTestId("account-notifications-email_notifications-switch")).not.toBeChecked();
262
+ expect(screen.getByTestId("account-notifications-email_notifications-date")).toHaveTextContent(
263
+ "Withdrawn Nov 1, 2026",
264
+ );
265
+ expect(screen.queryByTestId("account-notifications-onboarding-date")).not.toBeInTheDocument();
266
+ });
267
+
268
+ it("renders the always-sent line under the rows, inside the same card", async () => {
269
+ await renderPage();
270
+ const foot = screen.getByTestId("account-notifications-foot");
271
+ expect(foot).toHaveTextContent("Receipts, sign-in links and security notices are always sent.");
272
+ const list = screen.getByTestId("account-notifications");
273
+ expect(list.compareDocumentPosition(foot) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
274
+ expect(screen.getByTestId("account-settings-notifications-card")).toContainElement(foot);
275
+ expect(screen.getByTestId("account-settings-notifications-card")).toContainElement(list);
276
+ });
277
+
278
+ it("renders no consent statement and no markdown on any row", async () => {
279
+ await renderPage();
280
+ const pane = screen.getByTestId("account-settings-notifications");
281
+ for (const purpose of shippedCommunicationsPurposes()) {
282
+ expect(within(pane).queryByText(purpose.statement)).not.toBeInTheDocument();
283
+ }
284
+ expect(pane.textContent).not.toMatch(/\[[^\]]+\]\([^)]+\)/);
285
+ expect(pane.textContent).not.toContain("I accept");
286
+ });
287
+
288
+ it("titles a purpose this app does not name by its registry description", async () => {
289
+ mockConsents.mockResolvedValue(
290
+ ok({ purposes: [communicationsPurpose({ id: "partner_offers", kind: "consent", effective: false })] }),
291
+ );
292
+ await renderPage();
293
+ expect(screen.getByTestId("account-notifications-partner_offers-label")).toHaveTextContent(
294
+ "Product news and offers.",
295
+ );
296
+ expect(screen.queryByText("Receive product news and offers by email.")).not.toBeInTheDocument();
297
+ });
298
+ });
299
+
171
300
  describe("AC-8 — a declared communications preference defaults on with no row", () => {
172
301
  it("renders one switch, on", async () => {
173
302
  mockConsents.mockResolvedValue(
@@ -214,6 +343,28 @@ describe("AC-8 — a declared communications consent defaults off with no row",
214
343
  });
215
344
  });
216
345
 
346
+ describe("the Privacy tab's data purposes (#11164 AC-2)", () => {
347
+ it("does not list a `data` purpose: the training switch is Privacy's alone", async () => {
348
+ mockConsents.mockResolvedValue(
349
+ ok({
350
+ purposes: [
351
+ ...shippedCommunicationsPurposes(),
352
+ {
353
+ ...communicationsPurpose({ id: "ai_training", kind: "consent", effective: false }),
354
+ area: "data" as const,
355
+ description: "Use of your communications, artifacts and sessions to train and improve AI models.",
356
+ statement: "I allow the use of my communications, artifacts, and sessions to train and improve AI models.",
357
+ },
358
+ ],
359
+ }),
360
+ );
361
+ await renderPage();
362
+ expect(screen.getAllByRole("switch")).toHaveLength(3);
363
+ expect(screen.queryByTestId("account-notifications-ai_training")).not.toBeInTheDocument();
364
+ expect(screen.queryByText("Help improve our AI models")).not.toBeInTheDocument();
365
+ });
366
+ });
367
+
217
368
  describe("a failed consents read", () => {
218
369
  it("shows the unavailable line, not a broken switch list", async () => {
219
370
  mockConsents.mockResolvedValue({ ok: false, status: 503, body: null });