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,355 +0,0 @@
1
- /**
2
- * Tests for the member New menu (#8233, spec
3
- * docs/specs/8233-member-new-menu-the-new-spec.md D1–D4; AC-1, AC-2, AC-6).
4
- *
5
- * Covers:
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.
12
- * 2. Each row is offered only while its member read answers: a 404, or a
13
- * switched-off request form, leaves it out; every read 404 (a Free
14
- * build) leaves no New button and no error row; a failed read drops
15
- * its row AND shows the Inbox error row (AC-2).
16
- * 3. Placement: on the Inbox route the frame's phone top bar holds the
17
- * compact New; elsewhere in /account it holds nothing; outside a frame
18
- * only the desktop New shows, in the h1's header row (AC-6).
19
- */
20
- import { fireEvent, render, screen, waitFor, within } from "@testing-library/react";
21
- import type { ReactElement } from "react";
22
-
23
- // The account suites' next-intl mock: dotted namespaces and dotted keys
24
- // resolve against en.json, `{name}` placeholders fill from `values`.
25
- jest.mock("next-intl/server", () => {
26
- const msgs: unknown = require("../../../../../messages/en.json");
27
- const dig = (obj: unknown, path: string): unknown =>
28
- path.split(".").reduce<unknown>(
29
- (acc, k) => (acc !== null && typeof acc === "object" ? (acc as Record<string, unknown>)[k] : undefined),
30
- obj,
31
- );
32
- return {
33
- __esModule: true,
34
- getTranslations: async (arg: string | { namespace?: string; locale?: string }) => {
35
- const ns = typeof arg === "string" ? arg : (arg.namespace ?? "");
36
- const messages = dig(msgs, ns);
37
- return (key: string, values?: Record<string, unknown>): string => {
38
- const value = dig(messages, key);
39
- if (typeof value !== "string") return `${ns}.${key}`;
40
- return value.replace(/\{(\w+)\}/g, (m, name: string) =>
41
- values && name in values ? String(values[name]) : m,
42
- );
43
- };
44
- },
45
- };
46
- });
47
-
48
- jest.mock("next/headers", () => ({
49
- __esModule: true,
50
- headers: jest.fn().mockResolvedValue(new Headers()),
51
- cookies: jest.fn().mockResolvedValue({ toString: () => "session=abc" }),
52
- }));
53
-
54
- const mockGetSession = jest.fn();
55
- // 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.
56
- jest.mock("../../../../../auth", () => ({
57
- __esModule: true,
58
- auth: { api: { getSession: (...args: unknown[]) => mockGetSession(...args) } },
59
- }));
60
-
61
- const mockSubscriptionMe = jest.fn();
62
- const mockMemberPieces = jest.fn();
63
- const mockMemberMessages = jest.fn();
64
- const mockMemberPurchases = jest.fn();
65
- const mockMemberAppointments = jest.fn();
66
- const mockMemberMeetingTypes = jest.fn();
67
- const mockMemberRequestForm = jest.fn();
68
- jest.mock("@working-theory/api-client", () => ({
69
- __esModule: true,
70
- waitlistSignups: { me: jest.fn() },
71
- subscription: { me: (...args: unknown[]) => mockSubscriptionMe(...args) },
72
- member: {
73
- pieces: (...args: unknown[]) => mockMemberPieces(...args),
74
- messages: (...args: unknown[]) => mockMemberMessages(...args),
75
- purchases: (...args: unknown[]) => mockMemberPurchases(...args),
76
- appointments: (...args: unknown[]) => mockMemberAppointments(...args),
77
- // #10826 D7 — the user-magnet results read; 404 here (no workspace module).
78
- results: () =>
79
- Promise.resolve({
80
- ok: false,
81
- status: 404,
82
- body: { ok: false, error: { code: "not_found", message: "Not found" } },
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
- }),
91
- meetingTypes: (...args: unknown[]) => mockMemberMeetingTypes(...args),
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
- }),
100
- },
101
- // #8765 D7 — the layout's agreements read: complete, so the frame renders.
102
- consent: {
103
- accountAgreements: async () => ({ ok: true, body: { agreements: [], complete: true } }),
104
- },
105
- }));
106
-
107
- jest.mock("better-auth/react", () => ({
108
- __esModule: true,
109
- createAuthClient: () => ({ signOut: jest.fn() }),
110
- }));
111
-
112
- const mockPush = jest.fn();
113
- const mockRefresh = jest.fn();
114
- let mockPathname = "/account";
115
- jest.mock("next/navigation", () => ({
116
- __esModule: true,
117
- useRouter: () => ({ push: mockPush, refresh: mockRefresh }),
118
- usePathname: () => mockPathname,
119
- useSearchParams: () => new URLSearchParams(),
120
- }));
121
-
122
- import { PhoneTabProvider } from "@working-theory/templates/account";
123
- import { requestQuoteFlowConfig } from "@working-theory/validation";
124
-
125
- import AccountLayout from "../layout";
126
- import { NewMenu } from "../new-menu";
127
- import Page from "../page";
128
-
129
- const SESSION = {
130
- user: {
131
- id: "user_1",
132
- name: "Ada",
133
- email: "ada@example.com",
134
- emailVerified: true,
135
- createdAt: new Date("2026-09-01T00:00:00.000Z"),
136
- },
137
- };
138
-
139
- /** The cookie a single site forwards (`forwardedCookieInit()`, no Origin here). */
140
- const INIT = { headers: { cookie: "session=abc" } };
141
-
142
- const notFound = {
143
- ok: false,
144
- status: 404,
145
- body: { ok: false, error: { code: "not_found", message: "Not found" } },
146
- };
147
- const failure = (status: number) => ({
148
- ok: false,
149
- status,
150
- body: { ok: false, error: { code: "failed", message: "x" } },
151
- });
152
- const ok = <T,>(body: T) => ({ ok: true, body });
153
-
154
- const TYPE = { slug: "consult", title: "Consultation", durationMinutes: 30 };
155
- const FORM = {
156
- form: { title: "Request a quote", defaultLocale: "en", steps: requestQuoteFlowConfig.steps },
157
- };
158
-
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);
162
-
163
- beforeAll(() => {
164
- // Radix menus open on pointerdown; jsdom has no PointerEvent.
165
- if (typeof globalThis.PointerEvent === "undefined") {
166
- // eslint-disable-next-line no-restricted-syntax -- a MouseEvent stands in for jsdom's missing PointerEvent
167
- globalThis.PointerEvent = MouseEvent as unknown as typeof PointerEvent;
168
- }
169
- });
170
-
171
- beforeEach(() => {
172
- window.localStorage.clear();
173
- mockPathname = "/account";
174
- mockPush.mockReset();
175
- mockRefresh.mockReset();
176
- mockGetSession.mockReset().mockResolvedValue(SESSION);
177
- mockSubscriptionMe.mockReset().mockResolvedValue(notFound);
178
- mockMemberPieces.mockReset().mockResolvedValue(notFound);
179
- mockMemberPurchases.mockReset().mockResolvedValue(notFound);
180
- mockMemberAppointments.mockReset().mockResolvedValue(notFound);
181
- // Every action offered unless a case says otherwise.
182
- mockMemberMeetingTypes.mockReset().mockResolvedValue(ok({ items: [TYPE] }));
183
- mockMemberRequestForm.mockReset().mockResolvedValue(ok(FORM));
184
- mockMemberMessages.mockReset().mockResolvedValue(ok({ items: [] }));
185
- });
186
-
187
- function openByPointer(trigger: HTMLElement): void {
188
- fireEvent.pointerDown(trigger, { button: 0, ctrlKey: false, pointerType: "mouse" });
189
- }
190
-
191
- async function renderInbox(): Promise<void> {
192
- const element = await Page({ params: Promise.resolve({ locale: "en" }) });
193
- render(<PhoneTabProvider tab="inbox">{element}</PhoneTabProvider>);
194
- }
195
-
196
- /** The New menu's rows, as their visible names. */
197
- function openMenu(trigger = screen.getByTestId("account-new-menu-trigger")): string[] {
198
- openByPointer(trigger);
199
- const content = screen.getByTestId("account-new-menu-content");
200
- return within(content)
201
- .getAllByRole("menuitem")
202
- .map((item) => item.textContent ?? "");
203
- }
204
-
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 () => {
207
- await renderInbox();
208
- expect(openMenu()).toEqual(LABELS);
209
- const content = screen.getByTestId("account-new-menu-content");
210
- expect(within(content).getByTestId("account-new-menu-item-schedule-service")).toBeInTheDocument();
211
- expect(within(content).getByTestId("account-new-menu-item-request-quote")).toBeInTheDocument();
212
- expect(within(content).getByTestId("account-new-menu-item-send-message")).toBeInTheDocument();
213
- });
214
-
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))(
238
- "%s opens a popup titled with its label over the Inbox, and never navigates",
239
- async (label, index) => {
240
- await renderInbox();
241
- openMenu();
242
- fireEvent.click(screen.getAllByRole("menuitem")[index]!);
243
- const popup = await screen.findByTestId("account-new-popup");
244
- expect(within(popup).getByRole("heading", { name: label })).toBeInTheDocument();
245
- expect(screen.getByTestId("account-inbox")).toBeInTheDocument();
246
- expect(mockPush).not.toHaveBeenCalled();
247
- // Close leaves the Inbox as it was, with nothing refreshed.
248
- fireEvent.click(within(popup).getByRole("button", { name: "Close" }));
249
- await waitFor(() => expect(screen.queryByTestId("account-new-popup")).not.toBeInTheDocument());
250
- expect(mockRefresh).not.toHaveBeenCalled();
251
- },
252
- );
253
- });
254
-
255
- describe("each action is offered only while its read answers (AC-2)", () => {
256
- it("meetingTypes 404 → Request quote and Send message only", async () => {
257
- mockMemberMeetingTypes.mockResolvedValue(notFound);
258
- await renderInbox();
259
- expect(openMenu()).toEqual(["Request quote", "Send message"]);
260
- });
261
-
262
- it.each([
263
- ["{ form: null }", ok({ form: null })],
264
- ["404", notFound],
265
- ])("requestForm %s → no Request quote", async (_name, answer) => {
266
- mockMemberRequestForm.mockResolvedValue(answer);
267
- await renderInbox();
268
- expect(openMenu()).toEqual(["Schedule appointment", "Send message"]);
269
- expect(screen.queryByTestId("inbox-error")).not.toBeInTheDocument();
270
- });
271
-
272
- it("meetingTypes { items: [] } → Schedule appointment is still offered (its page shows the empty line)", async () => {
273
- mockMemberMeetingTypes.mockResolvedValue(ok({ items: [] }));
274
- await renderInbox();
275
- expect(openMenu()).toEqual(LABELS);
276
- });
277
-
278
- it("every member read 404 (a Free build) → no New button and no error row", async () => {
279
- mockMemberMeetingTypes.mockResolvedValue(notFound);
280
- mockMemberRequestForm.mockResolvedValue(notFound);
281
- mockMemberMessages.mockResolvedValue(notFound);
282
- await renderInbox();
283
- expect(screen.queryByTestId("account-new-menu-trigger")).not.toBeInTheDocument();
284
- expect(screen.queryByTestId("account-new-menu-trigger-compact")).not.toBeInTheDocument();
285
- expect(screen.queryByTestId("inbox-error")).not.toBeInTheDocument();
286
- });
287
-
288
- it("requestForm 500 → no Request quote, and the Inbox error row (D12 parity)", async () => {
289
- mockMemberRequestForm.mockResolvedValue(failure(500));
290
- await renderInbox();
291
- expect(openMenu()).toEqual(["Schedule appointment", "Send message"]);
292
- expect(screen.getByTestId("inbox-error")).toBeInTheDocument();
293
- });
294
-
295
- it("each availability read receives the request's init unchanged", async () => {
296
- await renderInbox();
297
- expect(mockMemberMeetingTypes).toHaveBeenCalledWith(INIT);
298
- expect(mockMemberRequestForm).toHaveBeenCalledWith(INIT);
299
- expect(mockMemberMessages).toHaveBeenCalledWith(INIT);
300
- });
301
-
302
- it("signed out → no New button and no read", async () => {
303
- mockGetSession.mockResolvedValue(null);
304
- await renderInbox();
305
- expect(screen.queryByTestId("account-new-menu-trigger")).not.toBeInTheDocument();
306
- expect(mockMemberMeetingTypes).not.toHaveBeenCalled();
307
- });
308
- });
309
-
310
- describe("placement — the h1's row from md up, the phone top bar below (AC-6)", () => {
311
- const ACTIONS = LABELS.map((label, i) => ({
312
- id: ["schedule-service", "request-quote", "send-message"][i]!,
313
- label,
314
- popup: <p>{label} body</p>,
315
- }));
316
-
317
- function InboxChild(): ReactElement {
318
- return <NewMenu actions={ACTIONS} labels={{ trigger: "New", close: "Close" }} />;
319
- }
320
-
321
- async function renderLayout(): Promise<void> {
322
- const element = await AccountLayout({
323
- children: <InboxChild />,
324
- params: Promise.resolve({ locale: "en" }),
325
- });
326
- render(element);
327
- }
328
-
329
- it("on /account the compact New sits in the top bar's trailing cell and opens the same menu", async () => {
330
- await renderLayout();
331
- const end = screen.getByTestId("sidebar-topbar-end");
332
- const compact = await within(end).findByTestId("account-new-menu-trigger-compact");
333
- expect(compact).toHaveAccessibleName("New");
334
- expect(openMenu(compact)).toEqual(LABELS);
335
- });
336
-
337
- it("on /account/settings the top bar holds no New slot", async () => {
338
- mockPathname = "/account/settings";
339
- await renderLayout();
340
- expect(screen.queryByTestId("account-top-bar-actions")).not.toBeInTheDocument();
341
- expect(screen.queryByTestId("account-new-menu-trigger-compact")).not.toBeInTheDocument();
342
- });
343
-
344
- it("outside a frame there is no compact New, and New sits in the h1's header row", async () => {
345
- await renderInbox();
346
- expect(screen.queryByTestId("account-new-menu-trigger-compact")).not.toBeInTheDocument();
347
- const heading = screen.getByRole("heading", { level: 1 });
348
- expect(heading.parentElement).toContainElement(screen.getByTestId("account-new-menu-trigger"));
349
- });
350
-
351
- it("with no action NewMenu renders nothing", () => {
352
- const { container } = render(<NewMenu actions={[]} labels={{ trigger: "New", close: "Close" }} />);
353
- expect(container).toBeEmptyDOMElement();
354
- });
355
- });
@@ -1,97 +0,0 @@
1
- /**
2
- * Tests for account/new-popups.tsx — the New actions with their popups bound
3
- * (#8233 D1, D2, D6–D8; spec AC-7's popup half, moved here with the popups:
4
- * `lib/account-config.ts` may import nothing under `(authed)`, so the
5
- * binding lives in the route).
6
- *
7
- * Covers:
8
- * 1. `newActions` is `accountNewActions` in menu order, each read untouched
9
- * (the same `available` function the config exports).
10
- * 2. Each popup's props carry no credential and no email — only the locale
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.
15
- */
16
-
17
- jest.mock("@working-theory/api-client", () => ({
18
- __esModule: true,
19
- waitlistSignups: { me: jest.fn() },
20
- subscription: { me: jest.fn() },
21
- member: {
22
- pieces: jest.fn(),
23
- messages: jest.fn(),
24
- purchases: jest.fn(),
25
- appointments: jest.fn(),
26
- meetingTypes: jest.fn(),
27
- requestForm: jest.fn(),
28
- },
29
- }));
30
-
31
- import type {
32
- AccountContext,
33
- AccountNewAction,
34
- } from "@working-theory/templates/account";
35
- import type { ReactElement } from "react";
36
-
37
- import { accountNewActions } from "../../../../../lib/account-config";
38
- import { newActions } from "../new-popups";
39
-
40
- const INIT = { headers: { cookie: "session=abc" } };
41
-
42
- function ctx(): AccountContext {
43
- return {
44
- locale: "en",
45
- user: { name: "Ada", email: "ada@example.com", emailVerified: true },
46
- t: (key) => `t:${key}`,
47
- init: INIT,
48
- };
49
- }
50
-
51
- function action(id: string): AccountNewAction {
52
- const found = newActions.find((a) => a.id === id);
53
- if (!found) throw new Error(`no New action ${id}`);
54
- return found;
55
- }
56
-
57
- describe("newActions — the config's actions with their popups (#8233 D1, D2)", () => {
58
- it("is accountNewActions in menu order, each read the config's own", () => {
59
- expect(newActions.map((a) => [a.id, a.label])).toEqual(
60
- accountNewActions.map((a) => [a.id, a.label]),
61
- );
62
- expect(newActions.map((a) => a.id)).toEqual([
63
- "schedule-service",
64
- "request-quote",
65
- "send-message",
66
- ]);
67
- newActions.forEach((a, i) => {
68
- expect(a.available).toBe(accountNewActions[i]!.available);
69
- });
70
- });
71
-
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"])(
85
- "%s renders a popup whose props carry no cookie and no email (SEC-8233-1)",
86
- (id) => {
87
- const popup = action(id).renderPopup!(ctx()) as ReactElement<
88
- Record<string, unknown>
89
- >;
90
- const props = JSON.stringify(popup.props);
91
- expect(props).not.toContain("session=abc");
92
- expect(props).not.toContain("ada@example.com");
93
- expect(popup.props).toMatchObject({ locale: "en" });
94
- expect(Object.keys(popup.props).sort()).toEqual(["labels", "locale"]);
95
- },
96
- );
97
- });