create-ailk 0.37.0 → 0.38.0

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 (232) hide show
  1. package/README.md +149 -2
  2. package/component-catalog.json +44 -6
  3. package/component-catalog.md +6 -5
  4. package/dist/add-module.js +16 -1
  5. package/dist/add-route.d.ts +7 -2
  6. package/dist/add-route.js +28 -13
  7. package/dist/cli.js +52 -0
  8. package/dist/declined-routes.d.ts +13 -0
  9. package/dist/declined-routes.js +74 -0
  10. package/dist/derive-architecture.d.ts +0 -6
  11. package/dist/derive-architecture.js +9 -15
  12. package/dist/index.d.ts +1 -0
  13. package/dist/index.js +3 -0
  14. package/dist/language-import.d.ts +93 -0
  15. package/dist/language-import.js +270 -43
  16. package/dist/lib/import-mdx.js +1 -1
  17. package/dist/lib/scaffold-render-sweep.d.ts +6 -3
  18. package/dist/lib/scaffold-render-sweep.js +8 -4
  19. package/dist/migrate-content.d.ts +6 -2
  20. package/dist/migrate-content.js +62 -5
  21. package/dist/module-architecture.js +139 -103
  22. package/dist/paid-sections.d.ts +13 -0
  23. package/dist/paid-sections.js +35 -5
  24. package/dist/programmatic.js +6 -16
  25. package/dist/remove-module.js +67 -0
  26. package/dist/routes.d.ts +103 -0
  27. package/dist/routes.js +708 -0
  28. package/dist/site-manifest.js +1 -1
  29. package/dist/site-roster.d.ts +2 -1
  30. package/dist/site-roster.js +30 -8
  31. package/dist/spoke-checkout.d.ts +28 -27
  32. package/dist/spoke-checkout.js +71 -102
  33. package/dist/surfaces.d.ts +18 -0
  34. package/dist/surfaces.js +47 -282
  35. package/dist/sync-routes.d.ts +28 -1
  36. package/dist/sync-routes.js +144 -11
  37. package/dist/template-record.d.ts +11 -0
  38. package/dist/template-record.js +18 -0
  39. package/dist/topology.d.ts +15 -1
  40. package/dist/topology.js +20 -4
  41. package/dist/update.d.ts +31 -2
  42. package/dist/update.js +627 -99
  43. package/package.json +3 -3
  44. package/templates/README.md +1 -1
  45. package/templates/apps/mcp/CLAUDE.md +5 -3
  46. package/templates/apps/web/CLAUDE.md +62 -20
  47. package/templates/apps/web/account.config.tsx +101 -0
  48. package/templates/apps/web/app/[locale]/(authed)/account/appointments/[slug]/page.tsx +3 -161
  49. package/templates/apps/web/app/[locale]/(authed)/account/appointments/page.tsx +3 -139
  50. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/page.tsx +3 -406
  51. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/versions/[version]/file/route.ts +2 -190
  52. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/page.tsx +3 -182
  53. package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +8 -420
  54. package/templates/apps/web/app/[locale]/(authed)/account/connect/page.tsx +1 -1
  55. package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +8 -214
  56. package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +8 -115
  57. package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/route.ts +2 -80
  58. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/page.tsx +8 -121
  59. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/page.tsx +3 -154
  60. package/templates/apps/web/app/[locale]/(authed)/account/layout.tsx +7 -149
  61. package/templates/apps/web/app/[locale]/(authed)/account/notifications/page.tsx +3 -143
  62. package/templates/apps/web/app/[locale]/(authed)/account/onboarding/page.tsx +3 -126
  63. package/templates/apps/web/app/[locale]/(authed)/account/page.tsx +8 -302
  64. package/templates/apps/web/app/[locale]/(authed)/account/privacy/export/route.ts +2 -102
  65. package/templates/apps/web/app/[locale]/(authed)/account/privacy/page.tsx +3 -240
  66. package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +3 -131
  67. package/templates/apps/web/app/[locale]/(authed)/account/settings/page.tsx +2 -24
  68. package/templates/apps/web/app/[locale]/(authed)/account/support/page.tsx +3 -60
  69. package/templates/apps/web/app/[locale]/layout.tsx +45 -28
  70. package/templates/apps/web/app/apple-icon.tsx +72 -0
  71. package/templates/apps/web/app/llms.txt/__tests__/site-listing.test.ts +22 -12
  72. package/templates/apps/web/app/og/__tests__/__snapshots__/card.test.tsx.snap +3 -0
  73. package/templates/apps/web/app/og/__tests__/card.test.tsx +129 -0
  74. package/templates/apps/web/app/og/__tests__/route.test.ts +3 -4
  75. package/templates/apps/web/app/og/route.tsx +155 -72
  76. package/templates/apps/web/app/sitemap.xml/__tests__/site-listing.test.ts +12 -0
  77. package/templates/apps/web/i18n/request.ts +44 -1
  78. package/templates/apps/web/jest.config.cjs +13 -1
  79. package/templates/apps/web/lib/__tests__/auth-phone.test.ts +11 -0
  80. package/templates/apps/web/lib/__tests__/fixtures/site-topology.ts +70 -0
  81. package/templates/apps/web/lib/__tests__/nav-label-keys.test.ts +14 -0
  82. package/templates/apps/web/lib/__tests__/profile-back-link.test.ts +148 -61
  83. package/templates/apps/web/lib/__tests__/served-pages.test.ts +77 -0
  84. package/templates/apps/web/lib/__tests__/server-api.test.ts +37 -5
  85. package/templates/apps/web/lib/__tests__/structured-data.test.tsx +26 -13
  86. package/templates/apps/web/lib/listings.tsx +2 -2
  87. package/templates/apps/web/lib/nav-label-keys.ts +16 -2
  88. package/templates/apps/web/lib/paid-section-contracts.ts +35 -6
  89. package/templates/apps/web/lib/paid-sections.generated.ts +8 -0
  90. package/templates/apps/web/lib/profile-back-link.ts +105 -32
  91. package/templates/apps/web/lib/served-pages.ts +95 -0
  92. package/templates/apps/web/lib/site-brand.tsx +3 -5
  93. package/templates/apps/web/messages/en.json +8 -684
  94. package/templates/apps/web/middleware.ts +3 -1
  95. package/templates/apps/web/next.config.mjs +27 -0
  96. package/templates/apps/web/package.json +1 -0
  97. package/templates/customizations.yaml +9 -0
  98. package/templates/package.json +3 -1
  99. package/templates/tools/lint-architecture.ts +164 -11
  100. package/versions.json +48 -47
  101. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/account-frame-sign-out.test.tsx +0 -175
  102. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/agreements-prompt.test.tsx +0 -301
  103. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/billing.test.tsx +0 -515
  104. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/general.test.tsx +0 -883
  105. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/hub-mode.test.tsx +0 -758
  106. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/item.test.tsx +0 -264
  107. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout-sign-out.test.tsx +0 -167
  108. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout.test.tsx +0 -730
  109. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-menu.test.tsx +0 -355
  110. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-popups.test.tsx +0 -97
  111. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/notifications.test.tsx +0 -375
  112. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/onboarding.test.tsx +0 -323
  113. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +0 -1208
  114. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/popups.test.tsx +0 -418
  115. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/privacy.test.tsx +0 -462
  116. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/rich-translator.ts +0 -63
  117. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/security.test.tsx +0 -406
  118. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/settings.test.tsx +0 -93
  119. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/support.test.tsx +0 -208
  120. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/thread.test.tsx +0 -340
  121. package/templates/apps/web/app/[locale]/(authed)/account/account-data.ts +0 -182
  122. package/templates/apps/web/app/[locale]/(authed)/account/account-frame.tsx +0 -353
  123. package/templates/apps/web/app/[locale]/(authed)/account/actions.ts +0 -57
  124. package/templates/apps/web/app/[locale]/(authed)/account/agreements-actions.ts +0 -58
  125. package/templates/apps/web/app/[locale]/(authed)/account/agreements-gate.ts +0 -61
  126. package/templates/apps/web/app/[locale]/(authed)/account/agreements-prompt.tsx +0 -184
  127. package/templates/apps/web/app/[locale]/(authed)/account/appointments/__tests__/page.test.tsx +0 -426
  128. package/templates/apps/web/app/[locale]/(authed)/account/appointments/appointments-data.ts +0 -76
  129. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/pay-form.tsx +0 -65
  130. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/review-form.tsx +0 -172
  131. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/file-route.test.ts +0 -333
  132. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/page.test.tsx +0 -936
  133. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/pay.test.tsx +0 -193
  134. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/review.test.tsx +0 -476
  135. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-actions.ts +0 -184
  136. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-data.ts +0 -197
  137. package/templates/apps/web/app/[locale]/(authed)/account/billing/__tests__/offerings.test.ts +0 -99
  138. package/templates/apps/web/app/[locale]/(authed)/account/billing/offerings.ts +0 -123
  139. package/templates/apps/web/app/[locale]/(authed)/account/billing-source.ts +0 -303
  140. package/templates/apps/web/app/[locale]/(authed)/account/components/request-quote.tsx +0 -274
  141. package/templates/apps/web/app/[locale]/(authed)/account/error-row.tsx +0 -35
  142. package/templates/apps/web/app/[locale]/(authed)/account/for-you-labels.ts +0 -36
  143. package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/phone-verification.test.tsx +0 -215
  144. package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/seam-imports.test.ts +0 -65
  145. package/templates/apps/web/app/[locale]/(authed)/account/general/account-name.ts +0 -36
  146. package/templates/apps/web/app/[locale]/(authed)/account/general/billing-anchor.tsx +0 -27
  147. package/templates/apps/web/app/[locale]/(authed)/account/general/contact-actions.ts +0 -149
  148. package/templates/apps/web/app/[locale]/(authed)/account/general/contact-details.tsx +0 -42
  149. package/templates/apps/web/app/[locale]/(authed)/account/general/deletion-request.tsx +0 -132
  150. package/templates/apps/web/app/[locale]/(authed)/account/general/phone-actions.ts +0 -122
  151. package/templates/apps/web/app/[locale]/(authed)/account/general/phone-verification.tsx +0 -215
  152. package/templates/apps/web/app/[locale]/(authed)/account/general/photo-actions.ts +0 -73
  153. package/templates/apps/web/app/[locale]/(authed)/account/general/profile-form.tsx +0 -107
  154. package/templates/apps/web/app/[locale]/(authed)/account/general/profile-source.ts +0 -87
  155. package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/__tests__/route.test.ts +0 -215
  156. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/member-thread-composer.tsx +0 -43
  157. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-data.ts +0 -88
  158. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-write.ts +0 -31
  159. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/invitation-id.test.ts +0 -35
  160. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/page.test.tsx +0 -266
  161. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/actions.ts +0 -116
  162. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/invitation-id.ts +0 -12
  163. package/templates/apps/web/app/[locale]/(authed)/account/new-actions.ts +0 -219
  164. package/templates/apps/web/app/[locale]/(authed)/account/new-menu.tsx +0 -365
  165. package/templates/apps/web/app/[locale]/(authed)/account/new-popups.tsx +0 -86
  166. package/templates/apps/web/app/[locale]/(authed)/account/onboarding/actions.ts +0 -120
  167. package/templates/apps/web/app/[locale]/(authed)/account/onboarding/onboarding-form.tsx +0 -322
  168. package/templates/apps/web/app/[locale]/(authed)/account/privacy/__tests__/export-route.test.ts +0 -173
  169. package/templates/apps/web/app/[locale]/(authed)/account/privacy/actions.ts +0 -103
  170. package/templates/apps/web/app/[locale]/(authed)/account/profile-actions.ts +0 -116
  171. package/templates/apps/web/app/[locale]/(authed)/account/retry-button.tsx +0 -27
  172. package/templates/apps/web/app/[locale]/(authed)/account/security/__tests__/hub-variant.test.tsx +0 -258
  173. package/templates/apps/web/app/[locale]/(authed)/account/security/security-panel.tsx +0 -130
  174. package/templates/apps/web/app/[locale]/(authed)/account/security/security-source.ts +0 -92
  175. package/templates/apps/web/app/[locale]/(authed)/account/settings-frame.tsx +0 -121
  176. package/templates/apps/web/app/[locale]/(authed)/account/sign-in-method.ts +0 -37
  177. package/templates/apps/web/app/[locale]/(authed)/account/support/support-form.tsx +0 -98
  178. package/templates/apps/web/app/[locale]/(authed)/account/support-actions.ts +0 -100
  179. package/templates/apps/web/app/[locale]/checkout/__tests__/pages.test.tsx +0 -139
  180. package/templates/apps/web/app/[locale]/checkout/__tests__/thank-you-account.test.tsx +0 -146
  181. package/templates/apps/web/app/[locale]/checkout/thank-you/page.tsx +0 -114
  182. package/templates/apps/web/app/[locale]/checkout/unavailable/page.tsx +0 -51
  183. package/templates/apps/web/app/[locale]/flows/[slug]/FlowStepperClient.tsx +0 -614
  184. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.count.test.tsx +0 -43
  185. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.deliverable.test.tsx +0 -214
  186. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.ending.test.tsx +0 -197
  187. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.invite.test.tsx +0 -286
  188. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.permalink.test.tsx +0 -520
  189. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.test.tsx +0 -376
  190. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.thanks-by-tier.test.tsx +0 -306
  191. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/account-invite.actions.test.ts +0 -69
  192. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/flow.actions.test.ts +0 -398
  193. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/magnet-page.test.tsx +0 -704
  194. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/save.actions.test.ts +0 -173
  195. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/two-route-tool.test.tsx +0 -141
  196. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/verify.test.tsx +0 -249
  197. package/templates/apps/web/app/[locale]/flows/[slug]/account-invite.actions.ts +0 -35
  198. package/templates/apps/web/app/[locale]/flows/[slug]/email-moment.ts +0 -92
  199. package/templates/apps/web/app/[locale]/flows/[slug]/flow.actions.ts +0 -177
  200. package/templates/apps/web/app/[locale]/flows/[slug]/magnet-page.tsx +0 -472
  201. package/templates/apps/web/app/[locale]/flows/[slug]/page.tsx +0 -48
  202. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/LevelChart.tsx +0 -100
  203. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsCard.tsx +0 -99
  204. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsClient.tsx +0 -820
  205. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsEmailStep.tsx +0 -203
  206. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.no-commerce.test.tsx +0 -194
  207. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.report.test.tsx +0 -284
  208. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/by-result.test.tsx +0 -302
  209. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/cards.test.tsx +0 -402
  210. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/landing.test.tsx +0 -293
  211. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/page.test.tsx +0 -485
  212. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/score.test.tsx +0 -231
  213. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/checkout-seam.ts +0 -74
  214. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/meeting-seam.ts +0 -36
  215. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/page.tsx +0 -420
  216. package/templates/apps/web/app/[locale]/flows/[slug]/save.actions.ts +0 -85
  217. package/templates/apps/web/app/[locale]/flows/[slug]/served-flow.ts +0 -91
  218. package/templates/apps/web/app/[locale]/flows/[slug]/start/page.tsx +0 -32
  219. package/templates/apps/web/app/[locale]/flows/[slug]/verify/page.tsx +0 -153
  220. package/templates/apps/web/app/[locale]/flows/[slug]/verify.actions.ts +0 -151
  221. package/templates/apps/web/app/[locale]/meet/confirmed/BookingHandOff.tsx +0 -128
  222. package/templates/apps/web/app/[locale]/meet/confirmed/__tests__/BookingHandOff.test.tsx +0 -126
  223. package/templates/apps/web/app/[locale]/purchase/__tests__/cancel.test.tsx +0 -162
  224. package/templates/apps/web/app/[locale]/purchase/__tests__/module-scope.test.ts +0 -68
  225. package/templates/apps/web/app/[locale]/purchase/__tests__/success.test.tsx +0 -411
  226. package/templates/apps/web/app/[locale]/purchase/cancel/page.tsx +0 -115
  227. package/templates/apps/web/app/[locale]/purchase/success/page.tsx +0 -348
  228. package/templates/apps/web/lib/__tests__/account-config.test.ts +0 -704
  229. package/templates/apps/web/lib/account-config.ts +0 -678
  230. package/templates/apps/web/lib/checkout-config.ts +0 -16
  231. package/templates/apps/web/src/lib/__tests__/commerce-sections.test.ts +0 -57
  232. package/templates/apps/web/src/lib/commerce-sections.ts +0 -55
@@ -1,1208 +0,0 @@
1
- /**
2
- * Tests for /[locale]/account — the base account Inbox (#7430, spec 7423
3
- * U4 · D6a, D9, D12; AC-7 as amended 2026-10-01; #8231 D3, D5–D7).
4
- *
5
- * Covers:
6
- * 1. The tabs All · Messages · Orders · Scheduled (#11149), each with its
7
- * count (zeros included), All selected (#8231 D3); `?tab=` opens one.
8
- * 2. All holds every row newest first — the union of the other tabs and
9
- * the updates-only kinds, each once — each linking to its item page;
10
- * Orders (the `purchases` tab) holds the kinds whose section is
11
- * `purchases`; Scheduled the `upcoming` kinds, upcoming soonest first,
12
- * then past newest first. No lead renders (#11149).
13
- * 3. `email-unverified` and `payment-due` are For-you items (the phone
14
- * For you tab), never Inbox rows.
15
- * 4. A member with no name gets an "Add your name" For-you item (needs-you,
16
- * an Open action) linking to User settings › General.
17
- * 5. A failed read renders an error row with Retry — never an empty Inbox.
18
- * 6. #7469 (DESIGN.md §2b as amended 2026-10-01) — the route is the
19
- * phone's two main tabs. The Inbox tab is the filter tabs and the list
20
- * only: no For-you stack, no bottom sheet, no large title. The For you
21
- * tab lists every For-you item in one inset card, and ✕ dismisses one.
22
- * At `md`+ only the Inbox panel shows (the aside holds For you).
23
- * 7. #7920 — the member area's `piece` and `message` kinds and the
24
- * needs-client For-you source. Each reads the hub with `ctx.init`
25
- * unchanged (the caller's own credential); 404 and an unverified 401/403
26
- * load `[]`, any other failure rejects (D12). On a cookie-session site
27
- * they call with the cookie too — no gate (#8231 D7).
28
- * 8. #8765 D8 — the Inbox renders nothing about agreements: the card is
29
- * retired, whatever `member.consents` answers (the layout's interstitial
30
- * is the one place an agreement is asked).
31
- */
32
- import { act, cleanup as cleanupRender, fireEvent, render, screen, within } from "@testing-library/react";
33
-
34
- // The global setup mock resolves only top-level namespace keys against
35
- // en.json; the area reads nested keys (`inbox.tabs.all`, …) — a call
36
- // shape real next-intl supports — so resolve dotted namespaces AND dotted
37
- // keys here against the same catalog. `{name}` placeholders are filled from
38
- // `values` the way next-intl does.
39
- jest.mock("next-intl/server", () => {
40
- const msgs: unknown = require("../../../../../messages/en.json");
41
- const dig = (obj: unknown, path: string): unknown =>
42
- path
43
- .split(".")
44
- .reduce<unknown>(
45
- (acc, k) =>
46
- acc !== null && typeof acc === "object"
47
- ? (acc as Record<string, unknown>)[k]
48
- : undefined,
49
- obj,
50
- );
51
- return {
52
- __esModule: true,
53
- getTranslations: async (
54
- arg: string | { namespace?: string; locale?: string },
55
- ) => {
56
- const ns = typeof arg === "string" ? arg : (arg.namespace ?? "");
57
- const messages = dig(msgs, ns);
58
- return (key: string, values?: Record<string, unknown>): string => {
59
- const value = dig(messages, key);
60
- if (typeof value !== "string") return `${ns}.${key}`;
61
- return value.replace(/\{(\w+)\}/g, (m, name: string) =>
62
- values && name in values ? String(values[name]) : m,
63
- );
64
- };
65
- },
66
- };
67
- });
68
-
69
- jest.mock("next/headers", () => ({
70
- __esModule: true,
71
- headers: jest.fn().mockResolvedValue(new Headers()),
72
- cookies: jest.fn().mockResolvedValue({ toString: () => "session=abc" }),
73
- }));
74
-
75
- const mockGetSession = jest.fn();
76
- // eslint-disable-next-line no-restricted-syntax -- #507: mock-internal rewrite pending; auth.ts's lazy Better-Auth singleton has no HTTP/DB boundary a unit test of the session fields can mock without standing up Prisma.
77
- jest.mock("../../../../../auth", () => ({
78
- __esModule: true,
79
- auth: {
80
- api: { getSession: (...args: unknown[]) => mockGetSession(...args) },
81
- },
82
- }));
83
-
84
- const mockSignupMe = jest.fn();
85
- const mockSubscriptionMe = jest.fn();
86
- const mockMemberPieces = jest.fn();
87
- const mockMemberMessages = jest.fn();
88
- const mockMemberRequests = jest.fn();
89
- const mockMemberPurchases = jest.fn();
90
- const mockMemberAppointments = jest.fn();
91
- const mockMemberConsents = jest.fn();
92
- const mockMemberWelcome = jest.fn();
93
- const mockAccountAgreements = jest.fn();
94
- jest.mock("@working-theory/api-client", () => ({
95
- __esModule: true,
96
- // #8765 D7 — the account-level agreements the layout and the page share.
97
- consent: {
98
- accountAgreements: (...args: unknown[]) => mockAccountAgreements(...args),
99
- },
100
- waitlistSignups: { me: (...args: unknown[]) => mockSignupMe(...args) },
101
- subscription: { me: (...args: unknown[]) => mockSubscriptionMe(...args) },
102
- member: {
103
- pieces: (...args: unknown[]) => mockMemberPieces(...args),
104
- messages: (...args: unknown[]) => mockMemberMessages(...args),
105
- // #11157 — the member's own sent requests and messages, the Messages tab.
106
- requests: (...args: unknown[]) => mockMemberRequests(...args),
107
- purchases: (...args: unknown[]) => mockMemberPurchases(...args),
108
- appointments: (...args: unknown[]) => mockMemberAppointments(...args),
109
- // #10826 D7 — the user-magnet results read; 404 here (no workspace module).
110
- results: () =>
111
- Promise.resolve({
112
- ok: false,
113
- status: 404,
114
- body: { ok: false, error: { code: "not_found", message: "Not found" } },
115
- }),
116
- // #11150 — the onboarding-steps read; 404 unless a case welcomes the member.
117
- welcome: (...args: unknown[]) => mockMemberWelcome(...args),
118
- // #8765 D8 — the retired card's read; the page must not depend on it.
119
- consents: (...args: unknown[]) => mockMemberConsents(...args),
120
- // #8233 C4 — the New menu's availability reads; 404 here, so the Inbox
121
- // cases see no New action and no error row.
122
- meetingTypes: () =>
123
- Promise.resolve({
124
- ok: false,
125
- status: 404,
126
- body: { ok: false, error: { code: "not_found", message: "Not found" } },
127
- }),
128
- requestForm: () =>
129
- Promise.resolve({
130
- ok: false,
131
- status: 404,
132
- body: { ok: false, error: { code: "not_found", message: "Not found" } },
133
- }),
134
- },
135
- }));
136
-
137
- const mockRefresh = jest.fn();
138
- jest.mock("next/navigation", () => ({
139
- __esModule: true,
140
- useRouter: () => ({ push: jest.fn(), refresh: mockRefresh }),
141
- usePathname: () => "/account",
142
- }));
143
-
144
- import {
145
- PhoneTabProvider,
146
- type AccountContext,
147
- type AccountTranslate,
148
- } from "@working-theory/templates/account";
149
- import { getTranslations } from "next-intl/server";
150
-
151
- import {
152
- accountExperimentKeys,
153
- accountForYouSources,
154
- accountInboxKinds,
155
- } from "../../../../../lib/account-config";
156
- import Page from "../page";
157
-
158
- const SESSION = {
159
- user: {
160
- id: "user_1",
161
- name: "Ada",
162
- email: "ada@example.com",
163
- emailVerified: true,
164
- createdAt: new Date("2026-09-01T00:00:00.000Z"),
165
- },
166
- };
167
-
168
- const SIGNUP = {
169
- experimentKey: "ailk-founder-diagnostic",
170
- waitlistKey: "early_bird",
171
- completedAt: "2026-09-03T00:00:05.000Z",
172
- tier: "hot",
173
- score: 12,
174
- aeoScore: null,
175
- answers: { q3: null },
176
- };
177
-
178
- const PURCHASE = {
179
- id: "pur_done",
180
- offering: "pro",
181
- amountMinor: 4900,
182
- currency: "usd",
183
- period: "monthly",
184
- purchasedAt: "2026-09-04T10:00:00.000Z",
185
- };
186
-
187
- function appointment(id: string, title: string, startTime: string) {
188
- return {
189
- id,
190
- title,
191
- startTime,
192
- endTime: startTime,
193
- status: "confirmed" as const,
194
- };
195
- }
196
-
197
- const NO_APPOINTMENTS = { ok: true, body: { upcoming: [], past: [] } };
198
-
199
- const NO_SUBSCRIPTION = {
200
- ok: true,
201
- body: {
202
- actionRequired: false,
203
- status: null,
204
- accessRevokesAt: null,
205
- portalAvailable: false,
206
- },
207
- };
208
-
209
- const PIECE = {
210
- id: "piece_01920000-0000-7000-8000-000000000001",
211
- title: "Spring newsletter",
212
- stage: "Drafting",
213
- needsClient: false,
214
- createdAt: "2026-09-05T09:00:00.000Z",
215
- updatedAt: "2026-09-06T09:00:00.000Z",
216
- };
217
-
218
- const PIECE_NEEDS_CLIENT = {
219
- id: "piece_01920000-0000-7000-8000-000000000002",
220
- title: "About page",
221
- stage: "Review",
222
- needsClient: true,
223
- createdAt: "2026-09-02T09:00:00.000Z",
224
- updatedAt: "2026-09-07T09:00:00.000Z",
225
- };
226
-
227
- const MESSAGE = {
228
- id: "intx_01920000-0000-7000-8000-000000000003",
229
- subject: "Kickoff notes",
230
- body: "Thanks for the call.",
231
- file: null,
232
- createdAt: "2026-09-08T09:00:00.000Z",
233
- readAt: null,
234
- };
235
-
236
- /** #11157 — a quote request the member sent from the New menu moments ago. */
237
- const SENT_REQUEST = {
238
- id: "intx_01920000-0000-7000-8000-000000000157",
239
- kind: "quote" as const,
240
- subject: "Request quote",
241
- body: "",
242
- createdAt: "2026-09-11T14:36:56.000Z",
243
- };
244
-
245
- const MESSAGE_WITH_FILE = {
246
- id: "intx_01920000-0000-7000-8000-000000000004",
247
- subject: "Your brand guide",
248
- body: "Attached.",
249
- file: { filename: "brand-guide.pdf", contentType: "application/pdf" },
250
- createdAt: "2026-09-09T09:00:00.000Z",
251
- readAt: "2026-09-09T10:00:00.000Z",
252
- };
253
-
254
- /** The hub credential a spoke signed in through its hub forwards (#7894 D12). */
255
- const BEARER = {
256
- headers: { authorization: `Bearer ailk_hst_${"t".repeat(43)}` },
257
- };
258
-
259
- const notFound = {
260
- ok: false,
261
- status: 404,
262
- body: { ok: false, error: { code: "not_found", message: "Not found" } },
263
- };
264
-
265
- /** The context a hub-mode spoke hands every contribution, signed in. */
266
- async function memberCtx(
267
- overrides: Partial<AccountContext> = {},
268
- ): Promise<AccountContext> {
269
- const locale = overrides.locale ?? "en";
270
- // The contract's translator takes any key (account-data.ts's reasoning):
271
- // forward through the mock's runtime signature.
272
- const translate = (await getTranslations({
273
- locale,
274
- namespace: "account",
275
- })) as (key: string, values?: Record<string, unknown>) => string;
276
- const t: AccountTranslate = (key, values) => translate(key, values);
277
- return {
278
- locale,
279
- user: { name: "Ada", email: "ada@example.com", emailVerified: true },
280
- t,
281
- init: BEARER,
282
- ...overrides,
283
- };
284
- }
285
-
286
- function kindOf(id: string): (typeof accountInboxKinds)[number] {
287
- const kind = accountInboxKinds.find((k) => k.kind === id);
288
- if (!kind) throw new Error(`no ${id} kind`);
289
- return kind;
290
- }
291
-
292
- function needsClientSource(): (typeof accountForYouSources)[number] {
293
- const source = accountForYouSources.find(
294
- (s) => s.id === "piece-needs-client",
295
- );
296
- if (!source) throw new Error("no piece-needs-client source");
297
- return source;
298
- }
299
-
300
- /** Renders the page on a phone tab — the frame's PhoneTabProvider. */
301
- async function renderPage(
302
- locale = "en",
303
- tab = "inbox",
304
- query?: Record<string, string | string[]>,
305
- ): Promise<void> {
306
- const element = await Page({
307
- params: Promise.resolve({ locale }),
308
- ...(query === undefined ? {} : { searchParams: Promise.resolve(query) }),
309
- });
310
- render(<PhoneTabProvider tab={tab}>{element}</PhoneTabProvider>);
311
- }
312
-
313
- const UNVERIFIED_AND_PAST_DUE = (): void => {
314
- mockGetSession.mockResolvedValue({
315
- user: { ...SESSION.user, emailVerified: false },
316
- });
317
- mockSubscriptionMe.mockResolvedValue({
318
- ok: true,
319
- body: {
320
- actionRequired: true,
321
- status: "past_due",
322
- accessRevokesAt: null,
323
- portalAvailable: true,
324
- },
325
- });
326
- };
327
-
328
- beforeEach(() => {
329
- window.localStorage.clear();
330
- accountExperimentKeys.length = 0;
331
- mockGetSession.mockReset().mockResolvedValue(SESSION);
332
- mockSignupMe.mockReset().mockResolvedValue({ ok: true, body: SIGNUP });
333
- mockMemberWelcome.mockReset().mockResolvedValue({
334
- ok: false,
335
- status: 404,
336
- body: { ok: false, error: { code: "not_found", message: "Not found" } },
337
- });
338
- mockSubscriptionMe.mockReset().mockResolvedValue(NO_SUBSCRIPTION);
339
- mockMemberPurchases
340
- .mockReset()
341
- .mockResolvedValue({ ok: true, body: { items: [PURCHASE] } });
342
- mockMemberAppointments.mockReset().mockResolvedValue(NO_APPOINTMENTS);
343
- // The page's pieces and messages answer 404 unless a case fills them.
344
- mockMemberPieces.mockReset().mockResolvedValue(notFound);
345
- mockMemberMessages.mockReset().mockResolvedValue(notFound);
346
- mockMemberRequests.mockReset().mockResolvedValue(notFound);
347
- mockAccountAgreements
348
- .mockReset()
349
- .mockResolvedValue({ ok: true, body: { agreements: [], complete: true } });
350
- mockRefresh.mockReset();
351
- });
352
-
353
- /** The member kinds' own cases read rows from both member reads. */
354
- function memberRows(): void {
355
- mockMemberPieces.mockResolvedValue({
356
- ok: true,
357
- body: { items: [PIECE, PIECE_NEEDS_CLIENT] },
358
- });
359
- mockMemberMessages.mockResolvedValue({
360
- ok: true,
361
- body: { items: [MESSAGE, MESSAGE_WITH_FILE] },
362
- });
363
- }
364
-
365
- afterEach(() => {
366
- // The viewer-zone case spies on `Intl.DateTimeFormat.prototype.resolvedOptions`.
367
- jest.restoreAllMocks();
368
- });
369
-
370
- afterAll(() => {
371
- accountExperimentKeys.length = 0;
372
- });
373
-
374
- describe("no agreements on the Inbox (#8765 D8, AC-3, AC-4)", () => {
375
- /** A `signUp` agreement the old card would have shown: no grant, or one at an older version. */
376
- function missingAgreement(
377
- state: null | { granted: boolean; policyVersion: number },
378
- ) {
379
- return {
380
- id: "account_terms",
381
- kind: "agreement",
382
- area: null,
383
- required: true,
384
- signUp: true,
385
- description: "Account terms.",
386
- statement: "I accept the [Terms](terms).",
387
- policyHref: "/working-agreement",
388
- policyVersion: 2,
389
- state: state && {
390
- ...state,
391
- at: "2026-09-01T00:00:00.000Z",
392
- source: "sign_up",
393
- },
394
- effective: false,
395
- };
396
- }
397
-
398
- it.each([
399
- ["no grant", { ok: true, body: { purposes: [missingAgreement(null)] } }],
400
- [
401
- "an older version",
402
- {
403
- ok: true,
404
- body: {
405
- purposes: [missingAgreement({ granted: true, policyVersion: 1 })],
406
- },
407
- },
408
- ],
409
- ["a refusal", { ok: false, status: 503, body: {} }],
410
- ])(
411
- "with member.consents answering %s, no account-agreements element renders",
412
- async (_label, answer) => {
413
- mockMemberConsents.mockResolvedValue(answer);
414
- await renderPage();
415
- // Let any mount-time effect settle — the retired card appeared only after one.
416
- await act(async () => {
417
- for (let i = 0; i < 10; i += 1)
418
- await new Promise((resolve) => setTimeout(resolve, 0));
419
- });
420
- expect(screen.getByTestId("account-inbox")).toBeInTheDocument();
421
- expect(
422
- document.querySelector('[data-testid^="account-agreements"]'),
423
- ).toBeNull();
424
- },
425
- );
426
- });
427
-
428
- describe("no Inbox loader runs behind the interstitial (#8765 D7)", () => {
429
- const OUTSTANDING = {
430
- ok: true,
431
- body: {
432
- agreements: [
433
- {
434
- id: "account_terms",
435
- statement: "I accept the [Terms](terms).",
436
- policyVersion: 2,
437
- acceptedVersion: null,
438
- acceptedAt: null,
439
- current: false,
440
- },
441
- ],
442
- complete: false,
443
- },
444
- };
445
-
446
- const inboxLoaders = () => [
447
- mockMemberPieces,
448
- mockMemberMessages,
449
- mockMemberPurchases,
450
- mockMemberAppointments,
451
- mockSubscriptionMe,
452
- mockSignupMe,
453
- ];
454
-
455
- it.each([
456
- [
457
- "complete: false",
458
- () => mockAccountAgreements.mockResolvedValue(OUTSTANDING),
459
- ],
460
- [
461
- "a 503 (fails closed)",
462
- () =>
463
- mockAccountAgreements.mockResolvedValue({
464
- ok: false,
465
- status: 503,
466
- body: {},
467
- }),
468
- ],
469
- [
470
- "a thrown read (fails closed)",
471
- () => mockAccountAgreements.mockRejectedValue(new Error("down")),
472
- ],
473
- ])(
474
- "with %s, the page renders nothing and calls no Inbox loader",
475
- async (_label, arrange) => {
476
- arrange();
477
- const element = await Page({ params: Promise.resolve({ locale: "en" }) });
478
- expect(element).toBeNull();
479
- // member.messages stamps readAt on its first read: it must never run here.
480
- for (const loader of inboxLoaders())
481
- expect(loader).not.toHaveBeenCalled();
482
- },
483
- );
484
-
485
- it("with an older hub's 404, the Inbox loads as before", async () => {
486
- mockAccountAgreements.mockResolvedValue(notFound);
487
- await renderPage();
488
- expect(screen.getByTestId("account-inbox")).toBeInTheDocument();
489
- expect(mockMemberMessages).toHaveBeenCalled();
490
- });
491
- });
492
-
493
- describe("the Inbox — tabs All · Messages · Orders · Scheduled (#8231 D3, AC-3; #11157; #11149)", () => {
494
- /** The rows of one tab, by title, after selecting it. */
495
- function tabRows(id: string): string[] {
496
- fireEvent.mouseDown(screen.getByTestId(`inbox-tab-${id}`));
497
- return within(screen.getByTestId(`inbox-${id}`))
498
- .queryAllByTestId(`inbox-${id}-row`)
499
- .map((row) => within(row).getByRole("link").textContent ?? "");
500
- }
501
-
502
- it("renders All · Messages · Orders · Scheduled with counts, All selected — no Recents or Suggested", async () => {
503
- accountExperimentKeys.push("ailk-founder-diagnostic");
504
- mockMemberPieces.mockResolvedValue({ ok: true, body: { items: [PIECE] } });
505
- mockMemberMessages.mockResolvedValue({
506
- ok: true,
507
- body: { items: [MESSAGE] },
508
- });
509
- mockMemberAppointments.mockResolvedValue({
510
- ok: true,
511
- body: {
512
- upcoming: [
513
- appointment("appt_1", "Kickoff call", "2026-09-10T15:00:00.000Z"),
514
- ],
515
- past: [],
516
- },
517
- });
518
- await renderPage();
519
- expect(screen.getByRole("heading", { level: 1 })).toHaveTextContent(
520
- "Inbox",
521
- );
522
- const tabs = screen.getAllByRole("tab");
523
- expect(tabs.map((tab) => tab.getAttribute("data-testid"))).toEqual([
524
- "inbox-tab-all",
525
- "inbox-tab-messages",
526
- "inbox-tab-purchases",
527
- "inbox-tab-scheduled",
528
- ]);
529
- expect(tabs.map((tab) => tab.textContent)).toEqual([
530
- "All5",
531
- "Messages1",
532
- "Orders1",
533
- "Scheduled1",
534
- ]);
535
- expect(screen.getByTestId("inbox-tab-all")).toHaveAttribute(
536
- "aria-selected",
537
- "true",
538
- );
539
- // All: every row, newest first.
540
- const all = within(screen.getByTestId("inbox-all")).getAllByTestId(
541
- "inbox-all-row",
542
- );
543
- expect(all.map((row) => row.textContent)).toEqual([
544
- expect.stringContaining("Kickoff call"),
545
- expect.stringContaining("Kickoff notes"),
546
- expect.stringContaining("Spring newsletter"),
547
- expect.stringContaining("pro"),
548
- expect.stringContaining("ailk-founder-diagnostic"),
549
- ]);
550
- // #11149 — All is the union: every other tab's rows, each exactly
551
- // once, plus the updates-only result row, newest first (above).
552
- const allTitles = all.map((row) => within(row).getByRole("link").textContent ?? "");
553
- // Messages: the provider's message only (#11157). Orders (the
554
- // `purchases` tab): the purchase row only. Scheduled: the appointment only.
555
- const messages = tabRows("messages");
556
- const orders = tabRows("purchases");
557
- const scheduled = tabRows("scheduled");
558
- expect(messages).toEqual([expect.stringContaining("Kickoff notes")]);
559
- expect(orders).toEqual([expect.stringContaining("pro")]);
560
- expect(scheduled).toEqual([expect.stringContaining("Kickoff call")]);
561
- const others = [...messages, ...orders, ...scheduled];
562
- for (const title of others) {
563
- expect(allTitles.filter((t) => t === title)).toHaveLength(1);
564
- }
565
- // + the two updates-only rows (the piece and the result), under All alone.
566
- expect(allTitles).toHaveLength(others.length + 2);
567
- // The result row is under All and in no other tab.
568
- expect(
569
- screen.queryByText("ailk-founder-diagnostic"),
570
- ).not.toBeInTheDocument();
571
- });
572
-
573
- it("#11157 AC-2 — a request the member sent lists under Messages and All, beside the provider's message, as its own item entry", async () => {
574
- mockMemberMessages.mockResolvedValue({ ok: true, body: { items: [MESSAGE] } });
575
- mockMemberRequests.mockResolvedValue({ ok: true, body: { items: [SENT_REQUEST] } });
576
- await renderPage();
577
- expect(screen.getAllByRole("tab").map((tab) => tab.textContent)).toEqual([
578
- "All3",
579
- "Messages2",
580
- "Orders1",
581
- "Scheduled0",
582
- ]);
583
- // All: the sent request first (newest), then the provider's message.
584
- const all = within(screen.getByTestId("inbox-all")).getAllByTestId("inbox-all-row");
585
- expect(all.map((row) => row.textContent)).toEqual([
586
- expect.stringContaining("Request quote"),
587
- expect.stringContaining("Kickoff notes"),
588
- expect.stringContaining("pro"),
589
- ]);
590
- expect(all[0]).toHaveTextContent("Sent ·");
591
- expect(within(all[0]!).getByRole("link")).toHaveAttribute(
592
- "href",
593
- `/account/inbox/request/${SENT_REQUEST.id}`,
594
- );
595
- // Messages: the two conversation rows only; Orders and Scheduled unchanged.
596
- expect(tabRows("messages")).toEqual([
597
- expect.stringContaining("Request quote"),
598
- expect.stringContaining("Kickoff notes"),
599
- ]);
600
- expect(tabRows("purchases")).toEqual([expect.stringContaining("pro")]);
601
- expect(tabRows("scheduled")).toEqual([]);
602
- });
603
-
604
- it("renders each row's day as a <time> in the server fallback zone until hydration (#11175)", async () => {
605
- mockMemberAppointments.mockResolvedValue({
606
- ok: true,
607
- body: {
608
- upcoming: [appointment("appt_1", "Kickoff call", "2026-09-11T03:30:00.000Z")],
609
- past: [],
610
- },
611
- });
612
- await renderPage();
613
- const row = within(screen.getByTestId("inbox-all")).getAllByTestId("inbox-all-row")[0]!;
614
- const time = row.querySelector("time");
615
- expect(time).toHaveAttribute("dateTime", "2026-09-11T03:30:00.000Z");
616
- // jest pins UTC, the zone the server renders in.
617
- expect(time).toHaveTextContent(/^Sep 11$/);
618
- expect(row).toHaveTextContent("· Sep 11");
619
- });
620
-
621
- it("re-reads each row's day in the viewer's zone once the browser has one (#11175)", async () => {
622
- const real = Intl.DateTimeFormat.prototype.resolvedOptions;
623
- jest
624
- .spyOn(Intl.DateTimeFormat.prototype, "resolvedOptions")
625
- .mockImplementation(function resolvedOptions(this: Intl.DateTimeFormat) {
626
- return { ...real.call(this), timeZone: "America/Denver" };
627
- });
628
- mockMemberAppointments.mockResolvedValue({
629
- ok: true,
630
- body: {
631
- upcoming: [appointment("appt_1", "Kickoff call", "2026-09-11T03:30:00.000Z")],
632
- past: [],
633
- },
634
- });
635
- await renderPage();
636
- const row = within(screen.getByTestId("inbox-all")).getAllByTestId("inbox-all-row")[0]!;
637
- // 03:30Z on the 11th is still the evening of the 10th in Mountain time.
638
- expect(row.querySelector("time")).toHaveTextContent(/^Sep 10$/);
639
- expect(row.querySelector("time")).toHaveAttribute("title", "MDT");
640
- });
641
-
642
- it("each All row links to its item page, prefixed off the default locale", async () => {
643
- accountExperimentKeys.push("ailk-founder-diagnostic");
644
- await renderPage("fr");
645
- const all = screen.getByTestId("inbox-all");
646
- expect(within(all).getByText("pro").closest("a")).toHaveAttribute(
647
- "href",
648
- "/fr/account/inbox/purchase/pur_done",
649
- );
650
- expect(
651
- within(all).getByText("ailk-founder-diagnostic").closest("a"),
652
- ).toHaveAttribute(
653
- "href",
654
- "/fr/account/inbox/result/ailk-founder-diagnostic",
655
- );
656
- });
657
-
658
- it("Scheduled lists the upcoming soonest first, then the past newest first", async () => {
659
- mockMemberAppointments.mockResolvedValue({
660
- ok: true,
661
- body: {
662
- // Out of order on purpose: the page orders them, not the read.
663
- upcoming: [
664
- appointment("u1", "U1", "2026-10-25T15:00:00.000Z"),
665
- appointment("u2", "U2", "2026-10-20T15:00:00.000Z"),
666
- ],
667
- past: [
668
- appointment("p1", "P1", "2026-09-01T15:00:00.000Z"),
669
- appointment("p2", "P2", "2026-09-05T15:00:00.000Z"),
670
- ],
671
- },
672
- });
673
- await renderPage();
674
- expect(tabRows("scheduled")).toEqual([
675
- expect.stringContaining("U2"),
676
- expect.stringContaining("U1"),
677
- expect.stringContaining("P2"),
678
- expect.stringContaining("P1"),
679
- ]);
680
- });
681
-
682
- it("a kind declaring section purchases lands under Orders (the `purchases` tab), not Scheduled", async () => {
683
- const licence: (typeof accountInboxKinds)[number] = {
684
- kind: "licence",
685
- label: "purchases.heading",
686
- section: "purchases",
687
- load: async () => [
688
- {
689
- id: "lic_1",
690
- title: "Site licence",
691
- at: "2026-09-05T00:00:00.000Z",
692
- data: null,
693
- },
694
- ],
695
- renderDetail: () => ({}),
696
- };
697
- accountInboxKinds.push(licence);
698
- try {
699
- await renderPage();
700
- expect(tabRows("purchases")).toEqual([
701
- expect.stringContaining("Site licence"),
702
- expect.stringContaining("pro"),
703
- ]);
704
- expect(tabRows("scheduled")).toEqual([]);
705
- } finally {
706
- accountInboxKinds.splice(accountInboxKinds.indexOf(licence), 1);
707
- }
708
- });
709
-
710
- it("with no rows, every tab still renders and All shows the empty line", async () => {
711
- mockMemberPurchases.mockResolvedValue({ ok: true, body: { items: [] } });
712
- await renderPage();
713
- expect(screen.getAllByRole("tab").map((tab) => tab.textContent)).toEqual([
714
- "All0",
715
- "Messages0",
716
- "Orders0",
717
- "Scheduled0",
718
- ]);
719
- expect(screen.getByTestId("inbox-empty")).toHaveTextContent(
720
- "Nothing here yet.",
721
- );
722
- });
723
- });
724
-
725
- describe("For-you items, not Inbox rows (AC-7, D9 as amended)", () => {
726
- it("email-unverified and payment-due are For you tab items, never Inbox rows", async () => {
727
- UNVERIFIED_AND_PAST_DUE();
728
- await renderPage("en", "for-you");
729
- const forYou = screen.getByTestId("inbox-panel-for-you");
730
- expect(within(forYou).getAllByTestId("for-you-item")).toHaveLength(2);
731
- const list = screen.getByTestId("inbox-list");
732
- expect(
733
- within(list).queryByText("Email not verified"),
734
- ).not.toBeInTheDocument();
735
- expect(
736
- within(list).queryByText("Your payment didn't go through"),
737
- ).not.toBeInTheDocument();
738
- });
739
-
740
- it("#11150 — a welcomed member with no name sees the one non-dismissible name step, not the area's own item too", async () => {
741
- mockGetSession.mockResolvedValue({ user: { ...SESSION.user, name: "" } });
742
- mockMemberWelcome.mockResolvedValue({
743
- ok: true,
744
- body: {
745
- welcomedAt: "2026-11-08T09:00:00.000Z",
746
- steps: [
747
- { id: "name", done: false },
748
- { id: "email", done: true },
749
- { id: "booking", done: true },
750
- ],
751
- },
752
- });
753
- await renderPage("en", "for-you");
754
- const forYou = screen.getByTestId("inbox-panel-for-you");
755
- const items = within(forYou).getAllByTestId("for-you-item");
756
- expect(items.map((item) => item.getAttribute("data-item-id"))).toEqual(["onboarding:name"]);
757
- expect(items[0]).toHaveTextContent("Add your name");
758
- expect(within(items[0]!).queryByTestId("for-you-dismiss")).toBeNull();
759
- // The default locale carries no prefix (`localeHref`).
760
- expect(within(items[0]!).getByTestId("for-you-open")).toHaveAttribute("href", "/account/general");
761
- });
762
-
763
- it("a member with no name sees 'Add your name' (needs-you, Open → User settings › General)", async () => {
764
- mockGetSession.mockResolvedValue({ user: { ...SESSION.user, name: "" } });
765
- await renderPage("en", "for-you");
766
- const forYou = screen.getByTestId("inbox-panel-for-you");
767
- const item = within(forYou).getByTestId("for-you-item");
768
- expect(item).toHaveAttribute("data-item-id", "add-name");
769
- expect(item).toHaveTextContent("Add your name");
770
- // DESIGN.md §5.4c — the tag is icon + label.
771
- expect(
772
- within(item).getByTestId("for-you-tag").querySelector("svg"),
773
- ).not.toBeNull();
774
- expect(within(item).getByTestId("for-you-open")).toHaveAttribute(
775
- "href",
776
- "/account/general",
777
- );
778
- });
779
- });
780
-
781
- describe("the phone Inbox tab (#7469, DESIGN.md §2b · §5.15)", () => {
782
- it("holds the filter tabs and the list only — no For-you stack and no bottom sheet", async () => {
783
- UNVERIFIED_AND_PAST_DUE();
784
- await renderPage();
785
- const inbox = screen.getByTestId("inbox-panel-inbox");
786
- expect(within(inbox).getByTestId("inbox-list")).toBeInTheDocument();
787
- expect(screen.queryByTestId("for-you-stack")).not.toBeInTheDocument();
788
- expect(screen.queryByTestId("for-you-stack-count")).not.toBeInTheDocument();
789
- expect(screen.queryByTestId("for-you-sheet")).not.toBeInTheDocument();
790
- expect(screen.queryByTestId("inbox-for-you")).not.toBeInTheDocument();
791
- });
792
-
793
- it("shows on the phone and at md+, while the For you panel stays hidden", async () => {
794
- UNVERIFIED_AND_PAST_DUE();
795
- await renderPage();
796
- expect(screen.getByTestId("inbox-panel-inbox")).not.toHaveClass("hidden");
797
- expect(screen.getByTestId("inbox-panel-inbox")).not.toHaveClass(
798
- "md:hidden",
799
- );
800
- expect(screen.getByTestId("inbox-panel-for-you")).toHaveClass("hidden");
801
- });
802
-
803
- it("the phone has no large title — it stays at md+; no lead renders on any width (#11149)", async () => {
804
- await renderPage();
805
- expect(screen.getByRole("heading", { level: 1 })).toHaveClass(
806
- "max-md:sr-only",
807
- );
808
- expect(screen.getByRole("heading", { level: 1 })).not.toHaveClass("hidden");
809
- expect(screen.queryByText("What changed, and what's coming.")).toBeNull();
810
- });
811
-
812
- it("the list sits in a bordered card, inset by the canvas on every side", async () => {
813
- accountExperimentKeys.push("ailk-founder-diagnostic");
814
- await renderPage();
815
- // The shell's main slot insets the canvas (p-4 below md); the page adds
816
- // no full-bleed escape, and the list is RowGroup's bordered box.
817
- const page = screen.getByTestId("account-inbox");
818
- expect(page.className).not.toMatch(/-mx-|w-screen/);
819
- expect(screen.getByTestId("inbox-panel-inbox").className ?? "").not.toMatch(
820
- /-mx-|w-screen/,
821
- );
822
- });
823
- });
824
-
825
- describe("#11149 — Orders on both, All first, no lead, ?tab=", () => {
826
- const catalog: { account: Record<string, unknown> & { inbox: Record<string, unknown> } } =
827
- require("../../../../../messages/en.json");
828
-
829
- it("every member-area string reads Orders, never Purchases; the `purchases` tab key reads Orders", () => {
830
- expect(JSON.stringify(catalog.account)).not.toContain("Purchases");
831
- expect((catalog.account.inbox.tabs as Record<string, string>).purchases).toBe("Orders");
832
- });
833
-
834
- it("the `purchases` section id, the `purchase` kind and its member read are unchanged — the tab is relabelled, not re-keyed", async () => {
835
- const purchase = accountInboxKinds.find((kind) => kind.kind === "purchase");
836
- expect(purchase?.section).toBe("purchases");
837
- await renderPage();
838
- expect(screen.getByTestId("inbox-tab-purchases")).toHaveTextContent("Orders1");
839
- expect(mockMemberPurchases).toHaveBeenCalled();
840
- });
841
-
842
- it("renders no lead: the key is gone from the catalog, nothing reads it, and the tabs follow the title row at the list's own mt-block-loose — the Admin's token", async () => {
843
- expect(catalog.account.inbox.lead).toBeUndefined();
844
- await renderPage();
845
- const panel = screen.getByTestId("inbox-panel-inbox");
846
- const list = screen.getByTestId("inbox-list");
847
- expect(panel.firstElementChild).toBe(list);
848
- expect(list).toHaveClass("mt-block-loose");
849
- });
850
-
851
- it("?tab= opens Messages or All; an unknown value or the phone's for-you opens All", async () => {
852
- await renderPage("en", "inbox", { tab: "messages" });
853
- expect(screen.getByTestId("inbox-tab-messages")).toHaveAttribute("aria-selected", "true");
854
- cleanupRender();
855
- await renderPage("en", "inbox", { tab: "all" });
856
- expect(screen.getByTestId("inbox-tab-all")).toHaveAttribute("aria-selected", "true");
857
- cleanupRender();
858
- await renderPage("en", "inbox", { tab: "purchases" });
859
- expect(screen.getByTestId("inbox-tab-purchases")).toHaveAttribute("aria-selected", "true");
860
- cleanupRender();
861
- await renderPage("en", "for-you", { tab: "for-you" });
862
- expect(screen.getByTestId("inbox-tab-all")).toHaveAttribute("aria-selected", "true");
863
- cleanupRender();
864
- await renderPage("en", "inbox", { tab: ["bogus", "messages"] });
865
- expect(screen.getByTestId("inbox-tab-all")).toHaveAttribute("aria-selected", "true");
866
- });
867
- });
868
-
869
- describe("the phone For you tab (#7469, DESIGN.md §2b · §5.15)", () => {
870
- it("lists every item with its type tag, title, Open or View, and ✕", async () => {
871
- UNVERIFIED_AND_PAST_DUE();
872
- mockGetSession.mockResolvedValue({
873
- user: { ...SESSION.user, name: "", emailVerified: false },
874
- });
875
- await renderPage("en", "for-you");
876
- const panel = screen.getByTestId("inbox-panel-for-you");
877
- // Phone-only: shown below md, hidden at md+ where the aside holds it.
878
- expect(panel).toHaveClass("md:hidden");
879
- expect(panel).not.toHaveClass("hidden");
880
- // The Inbox panel is hidden on the phone but still shows at md+.
881
- expect(screen.getByTestId("inbox-panel-inbox")).toHaveClass(
882
- "hidden",
883
- "md:block",
884
- );
885
- const card = within(panel).getByTestId("for-you-list-card");
886
- const items = within(card).getAllByTestId("for-you-item");
887
- expect(items).toHaveLength(3);
888
- for (const item of items) {
889
- expect(within(item).getByTestId("for-you-tag")).toBeInTheDocument();
890
- expect(
891
- within(item).queryByTestId("for-you-open") ??
892
- within(item).queryByTestId("for-you-view"),
893
- ).not.toBeNull();
894
- expect(within(item).getByTestId("for-you-dismiss")).toHaveAccessibleName(
895
- /^Dismiss/,
896
- );
897
- }
898
- expect(within(panel).getByText("Add your name")).toBeInTheDocument();
899
- expect(within(panel).getByText("Email not verified")).toBeInTheDocument();
900
- expect(
901
- within(panel).getByText("Your payment didn't go through"),
902
- ).toBeInTheDocument();
903
- });
904
-
905
- it("✕ dismisses an item — it leaves the list", async () => {
906
- UNVERIFIED_AND_PAST_DUE();
907
- await renderPage("en", "for-you");
908
- const panel = screen.getByTestId("inbox-panel-for-you");
909
- const [first] = within(panel).getAllByTestId("for-you-item");
910
- const id = first!.getAttribute("data-item-id");
911
- fireEvent.click(within(first!).getByTestId("for-you-dismiss"));
912
- const left = within(panel).getAllByTestId("for-you-item");
913
- expect(left).toHaveLength(1);
914
- expect(left.map((item) => item.getAttribute("data-item-id"))).not.toContain(
915
- id,
916
- );
917
- });
918
-
919
- it("the For you tab keeps the page's h1 (visually hidden on the phone)", async () => {
920
- await renderPage("en", "for-you");
921
- const h1 = screen.getByRole("heading", { level: 1 });
922
- expect(h1).toHaveTextContent("Inbox");
923
- expect(screen.getByTestId("inbox-panel-inbox")).not.toContainElement(h1);
924
- });
925
-
926
- it("with nothing waiting the tab shows its empty line, not a blank page", async () => {
927
- await renderPage("en", "for-you");
928
- const panel = screen.getByTestId("inbox-panel-for-you");
929
- expect(within(panel).queryByTestId("for-you-item")).not.toBeInTheDocument();
930
- expect(within(panel).getByTestId("for-you-empty")).toHaveTextContent(
931
- "Nothing here right now.",
932
- );
933
- });
934
- });
935
-
936
- describe("Hub unavailable (D12)", () => {
937
- it("a failed read renders an error row with Retry, never an empty Inbox", async () => {
938
- mockMemberPurchases.mockResolvedValue({ ok: false, status: 500, body: {} });
939
- await renderPage();
940
- expect(screen.getByTestId("inbox-error")).toHaveTextContent(
941
- "We couldn't load everything in your Inbox.",
942
- );
943
- expect(screen.queryByTestId("inbox-empty")).not.toBeInTheDocument();
944
- fireEvent.click(screen.getByTestId("inbox-retry"));
945
- expect(mockRefresh).toHaveBeenCalledTimes(1);
946
- });
947
-
948
- it("a failed For-you read also shows the error row", async () => {
949
- mockSubscriptionMe.mockResolvedValue({ ok: false, status: 502, body: {} });
950
- await renderPage();
951
- expect(
952
- within(screen.getByTestId("inbox-panel-inbox")).getByTestId(
953
- "inbox-error",
954
- ),
955
- ).toBeInTheDocument();
956
- });
957
-
958
- it("on the phone For you tab, a failed For-you read shows the error row above the list (#7469)", async () => {
959
- mockSubscriptionMe.mockResolvedValue({ ok: false, status: 502, body: {} });
960
- await renderPage("en", "for-you");
961
- const panel = screen.getByTestId("inbox-panel-for-you");
962
- expect(within(panel).getByTestId("inbox-error")).toHaveTextContent(
963
- "We couldn't load everything in your Inbox.",
964
- );
965
- // Never a silently empty list (D12): the empty line gives way to the error row.
966
- expect(
967
- within(panel).queryByTestId("for-you-empty"),
968
- ).not.toBeInTheDocument();
969
- });
970
-
971
- it("a failed Inbox-kind read leaves the For you tab without an error row", async () => {
972
- mockMemberPurchases.mockResolvedValue({ ok: false, status: 500, body: {} });
973
- await renderPage("en", "for-you");
974
- const panel = screen.getByTestId("inbox-panel-for-you");
975
- expect(within(panel).queryByTestId("inbox-error")).not.toBeInTheDocument();
976
- });
977
- });
978
-
979
- describe("the member kinds — piece and message (#7920, spec 7423 D8 · D12)", () => {
980
- beforeEach(memberRows);
981
-
982
- it("declares piece and message as Inbox kinds in the updates section, labelled from the account namespace", async () => {
983
- const ctx = await memberCtx();
984
- expect(kindOf("piece").section).toBe("updates");
985
- expect(kindOf("message").section).toBe("updates");
986
- expect(ctx.t(kindOf("piece").label)).toBe("My pieces");
987
- expect(ctx.t(kindOf("message").label)).toBe("My messages");
988
- });
989
-
990
- it("each kind reads the hub with ctx.init unchanged — the caller's own credential", async () => {
991
- const ctx = await memberCtx();
992
- const pieces = await kindOf("piece").load(ctx);
993
- const messages = await kindOf("message").load(ctx);
994
- expect(mockMemberPieces).toHaveBeenCalledWith(BEARER);
995
- expect(mockMemberMessages).toHaveBeenCalledWith(BEARER);
996
- expect(pieces.map((p) => [p.id, p.title, p.at])).toEqual([
997
- [PIECE.id, "Spring newsletter", PIECE.updatedAt],
998
- [PIECE_NEEDS_CLIENT.id, "About page", PIECE_NEEDS_CLIENT.updatedAt],
999
- ]);
1000
- expect(messages.map((m) => [m.id, m.title, m.at])).toEqual([
1001
- [MESSAGE.id, "Kickoff notes", MESSAGE.createdAt],
1002
- [MESSAGE_WITH_FILE.id, "Your brand guide", MESSAGE_WITH_FILE.createdAt],
1003
- ]);
1004
- });
1005
-
1006
- it.each(["piece", "message"])(
1007
- "%s loads [] on a 404 — nothing for this caller",
1008
- async (id) => {
1009
- mockMemberPieces.mockResolvedValue(notFound);
1010
- mockMemberMessages.mockResolvedValue(notFound);
1011
- await expect(kindOf(id).load(await memberCtx())).resolves.toEqual([]);
1012
- },
1013
- );
1014
-
1015
- it.each([
1016
- ["piece", 401],
1017
- ["piece", 403],
1018
- ["message", 401],
1019
- ["message", 403],
1020
- ])(
1021
- "%s loads [] on a %i while the email is unverified",
1022
- async (id, status) => {
1023
- const refusal = {
1024
- ok: false,
1025
- status,
1026
- body: { ok: false, error: { code: "email_unverified" } },
1027
- };
1028
- mockMemberPieces.mockResolvedValue(refusal);
1029
- mockMemberMessages.mockResolvedValue(refusal);
1030
- const ctx = await memberCtx({
1031
- user: { name: "Ada", email: "ada@example.com", emailVerified: false },
1032
- });
1033
- await expect(kindOf(id).load(ctx)).resolves.toEqual([]);
1034
- },
1035
- );
1036
-
1037
- it.each([
1038
- ["piece", 401],
1039
- ["piece", 403],
1040
- ["piece", 500],
1041
- ["piece", 0],
1042
- ["message", 401],
1043
- ["message", 403],
1044
- ["message", 502],
1045
- ["message", 0],
1046
- ])(
1047
- "%s rejects on a %i for a verified email — never a partial list shown as whole",
1048
- async (id, status) => {
1049
- const failure = {
1050
- ok: false,
1051
- status,
1052
- body: {
1053
- ok: false,
1054
- error: {
1055
- code: status === 0 ? "insecure_transport" : "failed",
1056
- message: "x",
1057
- },
1058
- },
1059
- };
1060
- mockMemberPieces.mockResolvedValue(failure);
1061
- mockMemberMessages.mockResolvedValue(failure);
1062
- await expect(kindOf(id).load(await memberCtx())).rejects.toMatchObject({
1063
- status,
1064
- });
1065
- },
1066
- );
1067
-
1068
- it("on a cookie-session site both kinds and the source call with the cookie and return rows (#8231 D7)", async () => {
1069
- const cookie = { headers: { cookie: "session=abc" } };
1070
- const ctx = await memberCtx({ init: cookie });
1071
- expect((await kindOf("piece").load(ctx)).map((p) => p.id)).toEqual([
1072
- PIECE.id,
1073
- PIECE_NEEDS_CLIENT.id,
1074
- ]);
1075
- expect((await kindOf("message").load(ctx)).map((m) => m.id)).toEqual([
1076
- MESSAGE.id,
1077
- MESSAGE_WITH_FILE.id,
1078
- ]);
1079
- expect((await needsClientSource().load(ctx)).map((i) => i.id)).toEqual([
1080
- `piece:${PIECE_NEEDS_CLIENT.id}`,
1081
- ]);
1082
- expect(mockMemberPieces).toHaveBeenCalledWith(cookie);
1083
- expect(mockMemberMessages).toHaveBeenCalledWith(cookie);
1084
- });
1085
-
1086
- it("the cookie-session Inbox lists the member rows under All, read with the forwarded cookie (#8231 D7)", async () => {
1087
- await renderPage();
1088
- const sent = expect.objectContaining({
1089
- headers: expect.objectContaining({ cookie: "session=abc" }),
1090
- });
1091
- expect(mockMemberPieces).toHaveBeenCalledWith(sent);
1092
- expect(mockMemberMessages).toHaveBeenCalledWith(sent);
1093
- expect(mockMemberPurchases).toHaveBeenCalledWith(sent);
1094
- expect(mockMemberAppointments).toHaveBeenCalledWith(sent);
1095
- const all = screen.getByTestId("inbox-all");
1096
- expect(within(all).getByText("Spring newsletter")).toBeInTheDocument();
1097
- expect(within(all).getByText("Kickoff notes")).toBeInTheDocument();
1098
- expect(screen.queryByTestId("inbox-error")).not.toBeInTheDocument();
1099
- });
1100
-
1101
- it.each([
1102
- ["pieces", mockMemberPieces],
1103
- ["messages", mockMemberMessages],
1104
- ] as const)(
1105
- "a 500 from member.%s shows the Inbox error row with Retry (#8231 D7)",
1106
- async (_name, mock) => {
1107
- mock.mockResolvedValue({ ok: false, status: 500, body: {} });
1108
- await renderPage();
1109
- const inbox = screen.getByTestId("inbox-panel-inbox");
1110
- expect(within(inbox).getByTestId("inbox-error")).toBeInTheDocument();
1111
- fireEvent.click(within(inbox).getByTestId("inbox-retry"));
1112
- expect(mockRefresh).toHaveBeenCalledTimes(1);
1113
- },
1114
- );
1115
-
1116
- it("a piece's detail shows its stage and dates", async () => {
1117
- const ctx = await memberCtx();
1118
- const [first] = await kindOf("piece").load(ctx);
1119
- const detail = kindOf("piece").renderDetail(first!, ctx);
1120
- expect(detail.status).toBe("Drafting");
1121
- expect(detail.fields?.heading).toBe("My pieces");
1122
- expect(detail.fields?.items.map((i) => i.label)).toEqual([
1123
- "Stage",
1124
- "Started",
1125
- "Updated",
1126
- ]);
1127
- });
1128
-
1129
- it("a message with an asset shows a file action that opens the member file read", async () => {
1130
- const ctx = await memberCtx();
1131
- const items = await kindOf("message").load(ctx);
1132
- const withFile = items.find((m) => m.id === MESSAGE_WITH_FILE.id)!;
1133
- const detail = kindOf("message").renderDetail(withFile, ctx);
1134
- expect(detail.actions).toEqual([
1135
- {
1136
- key: "file",
1137
- label: "Download brand-guide.pdf",
1138
- variant: "default",
1139
- href: `/account/inbox/message/${MESSAGE_WITH_FILE.id}/file`,
1140
- },
1141
- ]);
1142
- // #11007 — the message renders as a chat bubble; its file is the bubble's note.
1143
- expect(detail.fields).toBeUndefined();
1144
- render(<>{detail.body}</>);
1145
- expect(screen.getByTestId("account-item-message")).toHaveTextContent("File · brand-guide.pdf");
1146
- });
1147
-
1148
- it("the file action carries the locale prefix off the default locale", async () => {
1149
- const ctx = await memberCtx({ locale: "fr" });
1150
- const items = await kindOf("message").load(ctx);
1151
- const withFile = items.find((m) => m.id === MESSAGE_WITH_FILE.id)!;
1152
- expect(
1153
- kindOf("message").renderDetail(withFile, ctx).actions?.[0]?.href,
1154
- ).toBe(`/fr/account/inbox/message/${MESSAGE_WITH_FILE.id}/file`);
1155
- });
1156
-
1157
- it("a message without an asset has no file action", async () => {
1158
- const ctx = await memberCtx();
1159
- const [plain] = await kindOf("message").load(ctx);
1160
- const detail = kindOf("message").renderDetail(plain!, ctx);
1161
- expect(detail.actions).toBeUndefined();
1162
- render(<>{detail.body}</>);
1163
- expect(screen.getByTestId("account-item-message")).not.toHaveTextContent("File ·");
1164
- });
1165
- });
1166
-
1167
- describe("the needs-client For-you source (#7920)", () => {
1168
- beforeEach(memberRows);
1169
-
1170
- it("a needsClient piece is a needs-you For-you item with an Open action to its Inbox row", async () => {
1171
- const items = await needsClientSource().load(await memberCtx());
1172
- expect(items).toEqual([
1173
- {
1174
- id: `piece:${PIECE_NEEDS_CLIENT.id}`,
1175
- type: { id: "piece", label: "Piece", tone: "needs-you" },
1176
- title: "About page",
1177
- time: { kind: "at", at: PIECE_NEEDS_CLIENT.updatedAt },
1178
- action: {
1179
- kind: "open",
1180
- href: `/account/inbox/piece/${PIECE_NEEDS_CLIENT.id}`,
1181
- },
1182
- dismissible: true,
1183
- },
1184
- ]);
1185
- expect(mockMemberPieces).toHaveBeenCalledWith(BEARER);
1186
- });
1187
-
1188
- it("off the default locale the Open href carries the prefix", async () => {
1189
- const [item] = await needsClientSource().load(
1190
- await memberCtx({ locale: "fr" }),
1191
- );
1192
- expect(item?.action).toEqual({
1193
- kind: "open",
1194
- href: `/fr/account/inbox/piece/${PIECE_NEEDS_CLIENT.id}`,
1195
- });
1196
- });
1197
-
1198
- it("loads [] on a 404 and rejects on any other failure", async () => {
1199
- mockMemberPieces.mockResolvedValue(notFound);
1200
- await expect(needsClientSource().load(await memberCtx())).resolves.toEqual(
1201
- [],
1202
- );
1203
- mockMemberPieces.mockResolvedValue({ ok: false, status: 500, body: {} });
1204
- await expect(
1205
- needsClientSource().load(await memberCtx()),
1206
- ).rejects.toMatchObject({ status: 500 });
1207
- });
1208
- });