create-ailk 0.37.1 → 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 (230) hide show
  1. package/README.md +129 -0
  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 +2 -2
  6. package/dist/add-route.js +18 -11
  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 +14 -1
  36. package/dist/sync-routes.js +86 -5
  37. package/dist/topology.d.ts +15 -1
  38. package/dist/topology.js +20 -4
  39. package/dist/update.d.ts +17 -2
  40. package/dist/update.js +480 -77
  41. package/package.json +3 -3
  42. package/templates/README.md +1 -1
  43. package/templates/apps/mcp/CLAUDE.md +5 -3
  44. package/templates/apps/web/CLAUDE.md +62 -20
  45. package/templates/apps/web/account.config.tsx +101 -0
  46. package/templates/apps/web/app/[locale]/(authed)/account/appointments/[slug]/page.tsx +3 -161
  47. package/templates/apps/web/app/[locale]/(authed)/account/appointments/page.tsx +3 -139
  48. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/page.tsx +3 -406
  49. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/versions/[version]/file/route.ts +2 -190
  50. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/page.tsx +3 -182
  51. package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +8 -420
  52. package/templates/apps/web/app/[locale]/(authed)/account/connect/page.tsx +1 -1
  53. package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +8 -214
  54. package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +8 -115
  55. package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/route.ts +2 -80
  56. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/page.tsx +8 -121
  57. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/page.tsx +3 -154
  58. package/templates/apps/web/app/[locale]/(authed)/account/layout.tsx +7 -149
  59. package/templates/apps/web/app/[locale]/(authed)/account/notifications/page.tsx +3 -143
  60. package/templates/apps/web/app/[locale]/(authed)/account/onboarding/page.tsx +3 -126
  61. package/templates/apps/web/app/[locale]/(authed)/account/page.tsx +8 -302
  62. package/templates/apps/web/app/[locale]/(authed)/account/privacy/export/route.ts +2 -102
  63. package/templates/apps/web/app/[locale]/(authed)/account/privacy/page.tsx +3 -240
  64. package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +3 -131
  65. package/templates/apps/web/app/[locale]/(authed)/account/settings/page.tsx +2 -24
  66. package/templates/apps/web/app/[locale]/(authed)/account/support/page.tsx +3 -60
  67. package/templates/apps/web/app/[locale]/layout.tsx +45 -28
  68. package/templates/apps/web/app/apple-icon.tsx +72 -0
  69. package/templates/apps/web/app/llms.txt/__tests__/site-listing.test.ts +22 -12
  70. package/templates/apps/web/app/og/__tests__/__snapshots__/card.test.tsx.snap +3 -0
  71. package/templates/apps/web/app/og/__tests__/card.test.tsx +129 -0
  72. package/templates/apps/web/app/og/__tests__/route.test.ts +3 -4
  73. package/templates/apps/web/app/og/route.tsx +155 -72
  74. package/templates/apps/web/app/sitemap.xml/__tests__/site-listing.test.ts +12 -0
  75. package/templates/apps/web/i18n/request.ts +44 -1
  76. package/templates/apps/web/jest.config.cjs +13 -1
  77. package/templates/apps/web/lib/__tests__/auth-phone.test.ts +11 -0
  78. package/templates/apps/web/lib/__tests__/fixtures/site-topology.ts +70 -0
  79. package/templates/apps/web/lib/__tests__/nav-label-keys.test.ts +14 -0
  80. package/templates/apps/web/lib/__tests__/profile-back-link.test.ts +148 -61
  81. package/templates/apps/web/lib/__tests__/served-pages.test.ts +77 -0
  82. package/templates/apps/web/lib/__tests__/server-api.test.ts +37 -5
  83. package/templates/apps/web/lib/__tests__/structured-data.test.tsx +26 -13
  84. package/templates/apps/web/lib/listings.tsx +2 -2
  85. package/templates/apps/web/lib/nav-label-keys.ts +16 -2
  86. package/templates/apps/web/lib/paid-section-contracts.ts +35 -6
  87. package/templates/apps/web/lib/paid-sections.generated.ts +8 -0
  88. package/templates/apps/web/lib/profile-back-link.ts +105 -32
  89. package/templates/apps/web/lib/served-pages.ts +95 -0
  90. package/templates/apps/web/lib/site-brand.tsx +3 -5
  91. package/templates/apps/web/messages/en.json +8 -684
  92. package/templates/apps/web/middleware.ts +3 -1
  93. package/templates/apps/web/next.config.mjs +27 -0
  94. package/templates/apps/web/package.json +1 -0
  95. package/templates/customizations.yaml +9 -0
  96. package/templates/package.json +3 -1
  97. package/templates/tools/lint-architecture.ts +164 -11
  98. package/versions.json +48 -47
  99. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/account-frame-sign-out.test.tsx +0 -175
  100. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/agreements-prompt.test.tsx +0 -301
  101. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/billing.test.tsx +0 -515
  102. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/general.test.tsx +0 -883
  103. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/hub-mode.test.tsx +0 -758
  104. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/item.test.tsx +0 -264
  105. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout-sign-out.test.tsx +0 -167
  106. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout.test.tsx +0 -730
  107. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-menu.test.tsx +0 -355
  108. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-popups.test.tsx +0 -97
  109. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/notifications.test.tsx +0 -375
  110. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/onboarding.test.tsx +0 -323
  111. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +0 -1208
  112. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/popups.test.tsx +0 -418
  113. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/privacy.test.tsx +0 -462
  114. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/rich-translator.ts +0 -63
  115. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/security.test.tsx +0 -406
  116. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/settings.test.tsx +0 -93
  117. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/support.test.tsx +0 -208
  118. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/thread.test.tsx +0 -340
  119. package/templates/apps/web/app/[locale]/(authed)/account/account-data.ts +0 -182
  120. package/templates/apps/web/app/[locale]/(authed)/account/account-frame.tsx +0 -353
  121. package/templates/apps/web/app/[locale]/(authed)/account/actions.ts +0 -57
  122. package/templates/apps/web/app/[locale]/(authed)/account/agreements-actions.ts +0 -58
  123. package/templates/apps/web/app/[locale]/(authed)/account/agreements-gate.ts +0 -61
  124. package/templates/apps/web/app/[locale]/(authed)/account/agreements-prompt.tsx +0 -184
  125. package/templates/apps/web/app/[locale]/(authed)/account/appointments/__tests__/page.test.tsx +0 -426
  126. package/templates/apps/web/app/[locale]/(authed)/account/appointments/appointments-data.ts +0 -76
  127. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/pay-form.tsx +0 -65
  128. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/review-form.tsx +0 -172
  129. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/file-route.test.ts +0 -333
  130. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/page.test.tsx +0 -936
  131. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/pay.test.tsx +0 -193
  132. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/review.test.tsx +0 -476
  133. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-actions.ts +0 -184
  134. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-data.ts +0 -197
  135. package/templates/apps/web/app/[locale]/(authed)/account/billing/__tests__/offerings.test.ts +0 -99
  136. package/templates/apps/web/app/[locale]/(authed)/account/billing/offerings.ts +0 -123
  137. package/templates/apps/web/app/[locale]/(authed)/account/billing-source.ts +0 -303
  138. package/templates/apps/web/app/[locale]/(authed)/account/components/request-quote.tsx +0 -274
  139. package/templates/apps/web/app/[locale]/(authed)/account/error-row.tsx +0 -35
  140. package/templates/apps/web/app/[locale]/(authed)/account/for-you-labels.ts +0 -36
  141. package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/phone-verification.test.tsx +0 -215
  142. package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/seam-imports.test.ts +0 -65
  143. package/templates/apps/web/app/[locale]/(authed)/account/general/account-name.ts +0 -36
  144. package/templates/apps/web/app/[locale]/(authed)/account/general/billing-anchor.tsx +0 -27
  145. package/templates/apps/web/app/[locale]/(authed)/account/general/contact-actions.ts +0 -149
  146. package/templates/apps/web/app/[locale]/(authed)/account/general/contact-details.tsx +0 -42
  147. package/templates/apps/web/app/[locale]/(authed)/account/general/deletion-request.tsx +0 -132
  148. package/templates/apps/web/app/[locale]/(authed)/account/general/phone-actions.ts +0 -122
  149. package/templates/apps/web/app/[locale]/(authed)/account/general/phone-verification.tsx +0 -215
  150. package/templates/apps/web/app/[locale]/(authed)/account/general/photo-actions.ts +0 -73
  151. package/templates/apps/web/app/[locale]/(authed)/account/general/profile-form.tsx +0 -107
  152. package/templates/apps/web/app/[locale]/(authed)/account/general/profile-source.ts +0 -87
  153. package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/__tests__/route.test.ts +0 -215
  154. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/member-thread-composer.tsx +0 -43
  155. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-data.ts +0 -88
  156. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-write.ts +0 -31
  157. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/invitation-id.test.ts +0 -35
  158. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/page.test.tsx +0 -266
  159. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/actions.ts +0 -116
  160. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/invitation-id.ts +0 -12
  161. package/templates/apps/web/app/[locale]/(authed)/account/new-actions.ts +0 -219
  162. package/templates/apps/web/app/[locale]/(authed)/account/new-menu.tsx +0 -365
  163. package/templates/apps/web/app/[locale]/(authed)/account/new-popups.tsx +0 -86
  164. package/templates/apps/web/app/[locale]/(authed)/account/onboarding/actions.ts +0 -120
  165. package/templates/apps/web/app/[locale]/(authed)/account/onboarding/onboarding-form.tsx +0 -322
  166. package/templates/apps/web/app/[locale]/(authed)/account/privacy/__tests__/export-route.test.ts +0 -173
  167. package/templates/apps/web/app/[locale]/(authed)/account/privacy/actions.ts +0 -103
  168. package/templates/apps/web/app/[locale]/(authed)/account/profile-actions.ts +0 -116
  169. package/templates/apps/web/app/[locale]/(authed)/account/retry-button.tsx +0 -27
  170. package/templates/apps/web/app/[locale]/(authed)/account/security/__tests__/hub-variant.test.tsx +0 -258
  171. package/templates/apps/web/app/[locale]/(authed)/account/security/security-panel.tsx +0 -130
  172. package/templates/apps/web/app/[locale]/(authed)/account/security/security-source.ts +0 -92
  173. package/templates/apps/web/app/[locale]/(authed)/account/settings-frame.tsx +0 -121
  174. package/templates/apps/web/app/[locale]/(authed)/account/sign-in-method.ts +0 -37
  175. package/templates/apps/web/app/[locale]/(authed)/account/support/support-form.tsx +0 -98
  176. package/templates/apps/web/app/[locale]/(authed)/account/support-actions.ts +0 -100
  177. package/templates/apps/web/app/[locale]/checkout/__tests__/pages.test.tsx +0 -139
  178. package/templates/apps/web/app/[locale]/checkout/__tests__/thank-you-account.test.tsx +0 -146
  179. package/templates/apps/web/app/[locale]/checkout/thank-you/page.tsx +0 -114
  180. package/templates/apps/web/app/[locale]/checkout/unavailable/page.tsx +0 -51
  181. package/templates/apps/web/app/[locale]/flows/[slug]/FlowStepperClient.tsx +0 -614
  182. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.count.test.tsx +0 -43
  183. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.deliverable.test.tsx +0 -214
  184. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.ending.test.tsx +0 -197
  185. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.invite.test.tsx +0 -286
  186. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.permalink.test.tsx +0 -520
  187. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.test.tsx +0 -376
  188. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.thanks-by-tier.test.tsx +0 -306
  189. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/account-invite.actions.test.ts +0 -69
  190. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/flow.actions.test.ts +0 -398
  191. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/magnet-page.test.tsx +0 -704
  192. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/save.actions.test.ts +0 -173
  193. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/two-route-tool.test.tsx +0 -141
  194. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/verify.test.tsx +0 -249
  195. package/templates/apps/web/app/[locale]/flows/[slug]/account-invite.actions.ts +0 -35
  196. package/templates/apps/web/app/[locale]/flows/[slug]/email-moment.ts +0 -92
  197. package/templates/apps/web/app/[locale]/flows/[slug]/flow.actions.ts +0 -177
  198. package/templates/apps/web/app/[locale]/flows/[slug]/magnet-page.tsx +0 -472
  199. package/templates/apps/web/app/[locale]/flows/[slug]/page.tsx +0 -48
  200. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/LevelChart.tsx +0 -100
  201. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsCard.tsx +0 -99
  202. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsClient.tsx +0 -820
  203. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsEmailStep.tsx +0 -203
  204. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.no-commerce.test.tsx +0 -194
  205. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.report.test.tsx +0 -284
  206. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/by-result.test.tsx +0 -302
  207. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/cards.test.tsx +0 -402
  208. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/landing.test.tsx +0 -293
  209. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/page.test.tsx +0 -485
  210. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/score.test.tsx +0 -231
  211. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/checkout-seam.ts +0 -74
  212. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/meeting-seam.ts +0 -36
  213. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/page.tsx +0 -420
  214. package/templates/apps/web/app/[locale]/flows/[slug]/save.actions.ts +0 -85
  215. package/templates/apps/web/app/[locale]/flows/[slug]/served-flow.ts +0 -91
  216. package/templates/apps/web/app/[locale]/flows/[slug]/start/page.tsx +0 -32
  217. package/templates/apps/web/app/[locale]/flows/[slug]/verify/page.tsx +0 -153
  218. package/templates/apps/web/app/[locale]/flows/[slug]/verify.actions.ts +0 -151
  219. package/templates/apps/web/app/[locale]/meet/confirmed/BookingHandOff.tsx +0 -128
  220. package/templates/apps/web/app/[locale]/meet/confirmed/__tests__/BookingHandOff.test.tsx +0 -126
  221. package/templates/apps/web/app/[locale]/purchase/__tests__/cancel.test.tsx +0 -162
  222. package/templates/apps/web/app/[locale]/purchase/__tests__/module-scope.test.ts +0 -68
  223. package/templates/apps/web/app/[locale]/purchase/__tests__/success.test.tsx +0 -411
  224. package/templates/apps/web/app/[locale]/purchase/cancel/page.tsx +0 -115
  225. package/templates/apps/web/app/[locale]/purchase/success/page.tsx +0 -348
  226. package/templates/apps/web/lib/__tests__/account-config.test.ts +0 -704
  227. package/templates/apps/web/lib/account-config.ts +0 -678
  228. package/templates/apps/web/lib/checkout-config.ts +0 -16
  229. package/templates/apps/web/src/lib/__tests__/commerce-sections.test.ts +0 -57
  230. package/templates/apps/web/src/lib/commerce-sections.ts +0 -55
@@ -1,162 +0,0 @@
1
- /**
2
- * Tests for /[locale]/purchase/cancel (#6084).
3
- *
4
- * D4 — reads nothing. AC-2 — states nothing was charged, links to
5
- * `/services`, noindex, every string from the `purchase` namespace.
6
- */
7
- import React from "react";
8
- import { render } from "@testing-library/react";
9
-
10
- jest.mock("next/navigation", () => ({
11
- __esModule: true,
12
- notFound: jest.fn(() => {
13
- throw new Error("NEXT_NOT_FOUND");
14
- }),
15
- }));
16
-
17
- const requestedKeys: string[] = [];
18
- jest.mock("next-intl/server", () => ({
19
- __esModule: true,
20
- getTranslations: jest.fn().mockResolvedValue((key: string) => {
21
- requestedKeys.push(key);
22
- return `copy:${key}`;
23
- }),
24
- }));
25
-
26
- const capturedSections: unknown[] = [];
27
- jest.mock("@working-theory/ui/sections", () => ({
28
- __esModule: true,
29
- SectionRenderer: ({ sections }: { sections: unknown[] }) => {
30
- capturedSections.splice(0, capturedSections.length, ...sections);
31
- return React.createElement("div", {
32
- "data-testid": "section-renderer",
33
- "data-section-count": String(sections.length),
34
- });
35
- },
36
- }));
37
-
38
- const mockGetSession = jest.fn();
39
- jest.mock("@working-theory/api-client", () => ({
40
- __esModule: true,
41
- checkout: { getSession: (...args: unknown[]) => mockGetSession(...args) },
42
- }));
43
-
44
- // Mocks the REAL boundary `resolveCommerceClaim()` itself calls
45
- // (`checkLicense` from `@working-theory/license`), not the internal wrapper
46
- // module — matching the eslint "no internal-module mocks" rule (#507).
47
- const mockCheckLicense = jest.fn();
48
- jest.mock("@working-theory/license", () => ({
49
- __esModule: true,
50
- checkLicense: (...args: unknown[]) => mockCheckLicense(...args),
51
- }));
52
-
53
- // `../../../../src/lib/commerce-sections` wraps a lazy, webpack-ignored
54
- // `import()` of the paid `@working-theory/ui-commerce` package — mocked
55
- // directly, mirroring `../__tests__/success.test.tsx`'s identical mock.
56
- const mockEnsureCommerceSectionsRegistered = jest.fn();
57
- // eslint-disable-next-line no-restricted-syntax -- see the identical exception in success.test.tsx
58
- jest.mock("../../../../src/lib/commerce-sections", () => ({
59
- __esModule: true,
60
- ensureCommerceSectionsRegistered: () =>
61
- mockEnsureCommerceSectionsRegistered(),
62
- }));
63
-
64
- import { notFound } from "next/navigation";
65
-
66
- import Page, { generateMetadata } from "../cancel/page";
67
-
68
- const mockNotFound = notFound as jest.MockedFunction<typeof notFound>;
69
-
70
- function sectionTypes(): string[] {
71
- return capturedSections.map((s) => (s as { type: string }).type);
72
- }
73
-
74
- async function renderPage() {
75
- const element = await Page({ params: Promise.resolve({ locale: "en" }) });
76
- return render(element);
77
- }
78
-
79
- describe("/purchase/cancel", () => {
80
- beforeEach(() => {
81
- capturedSections.length = 0;
82
- requestedKeys.length = 0;
83
- mockGetSession.mockReset();
84
- mockCheckLicense.mockReset();
85
- mockCheckLicense.mockResolvedValue({ revoked: false, features: ["commerce"] });
86
- mockNotFound.mockClear();
87
- mockEnsureCommerceSectionsRegistered.mockReset();
88
- mockEnsureCommerceSectionsRegistered.mockResolvedValue(true);
89
- });
90
-
91
- it("renders payment-receipt(outcome:cancel) → cta, with a primary link to /services (AC-2, D5)", async () => {
92
- await renderPage();
93
-
94
- expect(sectionTypes()).toEqual(["payment-receipt", "cta"]);
95
- const receipt = capturedSections[0] as {
96
- data: Record<string, unknown>;
97
- };
98
- expect(receipt.data.outcome).toBe("cancel");
99
- const cta = capturedSections[1] as { data: Record<string, unknown> };
100
- expect((cta.data.primaryCta as { href: string }).href).toBe("/services");
101
- });
102
-
103
- it("falls back to content-block instead of payment-receipt when @working-theory/ui-commerce is not installed", async () => {
104
- mockEnsureCommerceSectionsRegistered.mockResolvedValue(false);
105
-
106
- await renderPage();
107
-
108
- expect(sectionTypes()).toEqual(["content-block", "cta"]);
109
- const fallback = capturedSections[0] as {
110
- data: { headline: string; body: string };
111
- };
112
- expect(fallback.data.headline).toBe("copy:cancel.title");
113
- expect(fallback.data.body).toContain("copy:cancel.message");
114
- });
115
-
116
- it("reads NOTHING — no API call at all (D4)", async () => {
117
- await renderPage();
118
- expect(mockGetSession).not.toHaveBeenCalled();
119
- });
120
-
121
- it("takes every string from the purchase namespace (D4/AC-2)", async () => {
122
- await renderPage();
123
- expect(requestedKeys.length).toBeGreaterThan(0);
124
- expect(requestedKeys.every((k) => k.startsWith("cancel."))).toBe(true);
125
- });
126
-
127
- it("is not indexable", async () => {
128
- const metadata = await generateMetadata({
129
- params: Promise.resolve({ locale: "en" }),
130
- });
131
- expect(metadata.robots).toEqual({ index: false, follow: true });
132
- });
133
-
134
- it("carries no data-outcome=success and no PaymentComplete string — a cancel is not a payment claim", async () => {
135
- await renderPage();
136
- const serialized = JSON.stringify(capturedSections);
137
- expect(serialized).not.toContain('"outcome":"success"');
138
- expect(serialized).not.toContain("PaymentComplete");
139
- });
140
-
141
- // ── T-16 / D12 — the request-time commerce-claim gate ───────────────────
142
-
143
- it("answers notFound() when the commerce claim is NOT held (D12)", async () => {
144
- mockCheckLicense.mockResolvedValue({ revoked: false, features: [] });
145
-
146
- await expect(renderPage()).rejects.toThrow("NEXT_NOT_FOUND");
147
- expect(mockNotFound).toHaveBeenCalledTimes(1);
148
- });
149
-
150
- it("fail-closed: answers notFound() when the licence read THROWS", async () => {
151
- mockCheckLicense.mockRejectedValue(new Error("licence read blew up"));
152
-
153
- await expect(renderPage()).rejects.toThrow();
154
- });
155
-
156
- it("renders normally when the commerce claim IS held", async () => {
157
- mockCheckLicense.mockResolvedValue({ revoked: false, features: ["commerce"] });
158
- await renderPage();
159
- expect(mockNotFound).not.toHaveBeenCalled();
160
- expect(sectionTypes()).toEqual(["payment-receipt", "cta"]);
161
- });
162
- });
@@ -1,68 +0,0 @@
1
- /**
2
- * T-8 (#6084) — neither `/purchase/success` nor `/purchase/cancel` may hold
3
- * a TOP-LEVEL STATIC import of `@working-theory/ui-commerce`.
4
- *
5
- * Superseded from its original form (a module-scope
6
- * `registerCommerceSections()` call + a static import — the shape the pages
7
- * shipped with initially). That shape is a genuine build-breaking defect:
8
- * both pages ship in the BASE TREE (`CORE_ROUTE_DIRS`, D12), but a keyless
9
- * `create-ailk` scaffold carries NO `@working-theory/ui-commerce` dependency
10
- * by design — `packages/create-ailk/scripts/build-templates.mjs`'s
11
- * `transformPaidUiPackages()` strips it, and
12
- * `__tests__/paid-module-honest-states.test.ts`'s "#5581 U6" suite pins a
13
- * keyless scaffold declaring none of the four paid `ui-*` packages as a
14
- * dependency. Webpack resolves a static top-level import at BUILD time
15
- * regardless of whether the importing code path ever executes, so the
16
- * original shape failed every keyless customer's build with
17
- * `ERR_MODULE_NOT_FOUND` (a code-review finding on this issue's own PR).
18
- *
19
- * The fix — `../../../../src/lib/commerce-sections.ts`'s
20
- * `ensureCommerceSectionsRegistered()` — registers the module LAZILY, via a
21
- * generated paid-sections registry (`lib/paid-sections.generated.ts`, #7536),
22
- * so the build never needs the package to resolve. This test now pins the ABSENCE of the
23
- * static import (the regression this file exists to catch) and the
24
- * PRESENCE of the lazy-registration call site instead.
25
- */
26
- import { readFileSync } from "node:fs";
27
- import { join } from "node:path";
28
-
29
- const PURCHASE_DIR = join(__dirname, "..");
30
-
31
- function readPageSource(page: "success" | "cancel"): string {
32
- return readFileSync(join(PURCHASE_DIR, page, "page.tsx"), "utf8");
33
- }
34
-
35
- describe("ui-commerce registration is LAZY, never a top-level static import (T-8, D5, #6084 code-review fix)", () => {
36
- for (const page of ["success", "cancel"] as const) {
37
- it(`purchase/${page}/page.tsx holds NO static top-level import of @working-theory/ui-commerce`, () => {
38
- const source = readPageSource(page);
39
- expect(source.includes('from "@working-theory/ui-commerce"')).toBe(
40
- false,
41
- );
42
- // The retired specifier may still appear in a doc comment (warning
43
- // readers away from it); what must be absent is an actual IMPORT of it.
44
- expect(
45
- source.includes('from "@working-theory/ui/slices/commerce"'),
46
- ).toBe(false);
47
- });
48
-
49
- it(`purchase/${page}/page.tsx imports ensureCommerceSectionsRegistered from the shared lazy-registration lib`, () => {
50
- const source = readPageSource(page);
51
- expect(
52
- source.includes(
53
- 'import { ensureCommerceSectionsRegistered } from "../../../../src/lib/commerce-sections";',
54
- ),
55
- ).toBe(true);
56
- });
57
-
58
- it(`purchase/${page}/page.tsx never calls registerCommerceSections() at module scope (only through the lazy wrapper)`, () => {
59
- const source = readPageSource(page);
60
- // A doc comment MAY still name it in prose (both pages do, warning
61
- // readers off the direct call) — what must be absent is the
62
- // unindented, top-level CALL EXPRESSION statement itself.
63
- expect(
64
- source.split("\n").some((line) => line === "registerCommerceSections();"),
65
- ).toBe(false);
66
- });
67
- }
68
- });
@@ -1,411 +0,0 @@
1
- /**
2
- * Tests for /[locale]/purchase/success (#6084).
3
- *
4
- * D6's five-row degrade table is the load-bearing surface here: only a 2xx
5
- * read with `paymentStatus === "paid"` may construct a `payment-receipt`
6
- * section — AC-8 pins the negative directly (no `outcome: "success"` DOM
7
- * marker on any other reachable state). AC-1/AC-7 cover the happy path and
8
- * the never-a-dead-end guarantee; T-16 covers the D12 request-time gate in
9
- * all three states (claimed / unclaimed / a throwing read).
10
- */
11
- import React from "react";
12
- import { render } from "@testing-library/react";
13
-
14
- jest.mock("next/navigation", () => ({
15
- __esModule: true,
16
- notFound: jest.fn(() => {
17
- throw new Error("NEXT_NOT_FOUND");
18
- }),
19
- }));
20
-
21
- const mockHeadersGet = jest.fn();
22
- jest.mock("next/headers", () => ({
23
- __esModule: true,
24
- headers: jest.fn().mockResolvedValue({ get: (key: string) => mockHeadersGet(key) }),
25
- }));
26
-
27
- const requestedKeys: string[] = [];
28
- jest.mock("next-intl/server", () => ({
29
- __esModule: true,
30
- getTranslations: jest
31
- .fn()
32
- .mockResolvedValue((key: string, values?: Record<string, unknown>) => {
33
- requestedKeys.push(key);
34
- if (values) return `copy:${key}:${JSON.stringify(values)}`;
35
- return `copy:${key}`;
36
- }),
37
- }));
38
-
39
- const capturedSections: unknown[] = [];
40
- jest.mock("@working-theory/ui/sections", () => ({
41
- __esModule: true,
42
- SectionRenderer: ({ sections }: { sections: unknown[] }) => {
43
- capturedSections.splice(0, capturedSections.length, ...sections);
44
- return React.createElement("div", {
45
- "data-testid": "section-renderer",
46
- "data-section-count": String(sections.length),
47
- });
48
- },
49
- }));
50
-
51
- const mockGetSession = jest.fn();
52
- jest.mock("@working-theory/api-client", () => ({
53
- __esModule: true,
54
- checkout: { getSession: (...args: unknown[]) => mockGetSession(...args) },
55
- }));
56
-
57
- // Mocks the REAL boundary `resolveCommerceClaim()` itself calls
58
- // (`checkLicense` from `@working-theory/license`), not the internal wrapper
59
- // module — matching the eslint "no internal-module mocks" rule (#507).
60
- const mockCheckLicense = jest.fn();
61
- jest.mock("@working-theory/license", () => ({
62
- __esModule: true,
63
- checkLicense: (...args: unknown[]) => mockCheckLicense(...args),
64
- }));
65
-
66
- // `../../../../src/lib/commerce-sections` wraps a lazy, webpack-ignored
67
- // `import()` of the paid `@working-theory/ui-commerce` package — mocked
68
- // directly here (an internal wrapper, but there is no OTHER boundary to
69
- // mock: the real thing it wraps is a dynamic import expression, not an
70
- // importable named export this file could bind instead) so a test can
71
- // simulate the package being genuinely absent (a keyless scaffold) without
72
- // needing to hide a real node_modules entry.
73
- const mockEnsureCommerceSectionsRegistered = jest.fn();
74
- // The wrapped thing is a bare, webpack-ignored `import()` expression, not a
75
- // named export of some other module — there is no external HTTP/DB/env
76
- // boundary to mock instead, mirroring team-page.test.tsx's identical
77
- // exception for auth.ts's lazy singleton.
78
- // eslint-disable-next-line no-restricted-syntax -- see comment above
79
- jest.mock("../../../../src/lib/commerce-sections", () => ({
80
- __esModule: true,
81
- ensureCommerceSectionsRegistered: () =>
82
- mockEnsureCommerceSectionsRegistered(),
83
- }));
84
-
85
- import { checkout } from "@working-theory/api-client";
86
- import { notFound } from "next/navigation";
87
-
88
- import { accountInviteHref } from "../../../../lib/account-invite";
89
- import Page, { generateMetadata } from "../success/page";
90
-
91
- const mockNotFound = notFound as jest.MockedFunction<typeof notFound>;
92
- void checkout; // referenced only to satisfy the mock import above
93
-
94
- function sectionTypes(): string[] {
95
- return capturedSections.map((s) => (s as { type: string }).type);
96
- }
97
-
98
- const PAID_SESSION = {
99
- id: "cs_test_abc123",
100
- status: "complete" as const,
101
- paymentStatus: "paid" as const,
102
- currency: "usd",
103
- amountTotal: 4800,
104
- lineItems: [
105
- {
106
- description: "Pro plan",
107
- quantity: 2,
108
- amountTotal: 4800,
109
- currency: "usd",
110
- },
111
- ],
112
- };
113
-
114
- async function renderPage(sessionId?: string) {
115
- const searchParams = sessionId
116
- ? Promise.resolve({ session_id: sessionId })
117
- : Promise.resolve({});
118
- const element = await Page({
119
- params: Promise.resolve({ locale: "en" }),
120
- searchParams,
121
- });
122
- return render(element);
123
- }
124
-
125
- describe("/purchase/success", () => {
126
- beforeEach(() => {
127
- capturedSections.length = 0;
128
- requestedKeys.length = 0;
129
- mockGetSession.mockReset();
130
- mockCheckLicense.mockReset();
131
- mockCheckLicense.mockResolvedValue({ revoked: false, features: ["commerce"] });
132
- mockNotFound.mockClear();
133
- mockEnsureCommerceSectionsRegistered.mockReset();
134
- mockEnsureCommerceSectionsRegistered.mockResolvedValue(true);
135
- mockHeadersGet.mockReset();
136
- mockHeadersGet.mockReturnValue(null);
137
- });
138
-
139
- // ── AC-1 — the paid render ────────────────────────────────────────────────
140
-
141
- it("renders payment-receipt → items → cta on a 2xx paid read (AC-1)", async () => {
142
- mockGetSession.mockResolvedValue({ ok: true, body: PAID_SESSION });
143
-
144
- await renderPage("cs_test_abc123");
145
-
146
- expect(sectionTypes()).toEqual(["payment-receipt", "items", "cta"]);
147
- });
148
-
149
- it("calls checkout.getSession with the exact session_id from the query, and undefined init when no forwarding header is present", async () => {
150
- mockGetSession.mockResolvedValue({ ok: true, body: PAID_SESSION });
151
- mockHeadersGet.mockReturnValue(null);
152
-
153
- await renderPage("cs_test_abc123");
154
-
155
- expect(mockGetSession).toHaveBeenCalledWith("cs_test_abc123", undefined);
156
- });
157
-
158
- it("forwards the visitor's x-forwarded-for as init.headers on the server-side read (security-review finding, #6084)", async () => {
159
- mockGetSession.mockResolvedValue({ ok: true, body: PAID_SESSION });
160
- mockHeadersGet.mockImplementation((key: string) =>
161
- key === "x-forwarded-for" ? "203.0.113.7" : null,
162
- );
163
-
164
- await renderPage("cs_test_abc123");
165
-
166
- expect(mockGetSession).toHaveBeenCalledWith("cs_test_abc123", {
167
- headers: { "x-forwarded-for": "203.0.113.7" },
168
- });
169
- });
170
-
171
- it("threads the session id + amount + currency into the payment-receipt section", async () => {
172
- mockGetSession.mockResolvedValue({ ok: true, body: PAID_SESSION });
173
-
174
- await renderPage("cs_test_abc123");
175
-
176
- const receipt = capturedSections[0] as {
177
- type: string;
178
- data: Record<string, unknown>;
179
- };
180
- expect(receipt.type).toBe("payment-receipt");
181
- expect(receipt.data.outcome).toBe("success");
182
- expect(receipt.data.sessionId).toBe("cs_test_abc123");
183
- expect(receipt.data.amount).toEqual({ amountMinor: 4800, currency: "usd" });
184
- });
185
-
186
- it("renders one items card per paid line item, with quantity and formatted money", async () => {
187
- mockGetSession.mockResolvedValue({ ok: true, body: PAID_SESSION });
188
-
189
- await renderPage("cs_test_abc123");
190
-
191
- const items = capturedSections[1] as {
192
- type: string;
193
- data: { items: { title: string; description: string }[] };
194
- };
195
- expect(items.type).toBe("items");
196
- expect(items.data.items).toHaveLength(1);
197
- expect(items.data.items[0]!.title).toBe("Pro plan");
198
- // The translated line renders through the t() mock, carrying the raw
199
- // interpolation values — quantity is threaded, and formatMoney ran (the
200
- // string contains a currency-formatted amount, not the raw minor units).
201
- expect(items.data.items[0]!.description).toContain("success.lineItem");
202
- expect(items.data.items[0]!.description).toContain('"quantity":2');
203
- });
204
-
205
- it("falls back to content-block instead of payment-receipt when @working-theory/ui-commerce is not installed", async () => {
206
- mockGetSession.mockResolvedValue({ ok: true, body: PAID_SESSION });
207
- mockEnsureCommerceSectionsRegistered.mockResolvedValue(false);
208
-
209
- await renderPage("cs_test_abc123");
210
-
211
- // Never the bare `payment-receipt` type — SectionRenderer would
212
- // otherwise fall back to `ModuleAbsent`, which renders nothing in
213
- // production. The line items and CTA are unaffected either way.
214
- expect(sectionTypes()).toEqual(["content-block", "items", "cta"]);
215
- const fallback = capturedSections[0] as {
216
- type: string;
217
- data: { headline: string; body: string };
218
- };
219
- expect(fallback.data.headline).toBe("copy:success.title");
220
- expect(fallback.data.body).toContain("copy:success.message");
221
- });
222
-
223
- // ── D6 — the five-row degrade table ─────────────────────────────────────
224
-
225
- it("renders content-block → cta with NO payment-receipt when there is no session_id (D6 row 3)", async () => {
226
- await renderPage(undefined);
227
-
228
- expect(sectionTypes()).toEqual(["content-block", "cta"]);
229
- expect(mockGetSession).not.toHaveBeenCalled();
230
- });
231
-
232
- it("renders content-block → cta with NO payment-receipt on a non-2xx read (D6 row 5)", async () => {
233
- mockGetSession.mockResolvedValue({
234
- ok: false,
235
- status: 404,
236
- body: { error: "unknown-session" },
237
- });
238
-
239
- await renderPage("cs_test_unknown");
240
-
241
- expect(sectionTypes()).toEqual(["content-block", "cta"]);
242
- });
243
-
244
- it("renders content-block → cta with NO payment-receipt when checkout.getSession REJECTS (a network failure, not a non-2xx response)", async () => {
245
- // `checkout.getSession()` calls `fetch()` with no try/catch of its own
246
- // (`packages/api-client/src/http.ts`) — a network-level failure rejects
247
- // the promise rather than resolving `{ ok: false }`. Code-review finding
248
- // on this issue's PR: without a catch here, this crashes the page
249
- // instead of degrading like every other unreachable-session case.
250
- mockGetSession.mockRejectedValue(new Error("fetch failed"));
251
-
252
- await renderPage("cs_test_unreachable");
253
-
254
- expect(sectionTypes()).toEqual(["content-block", "cta"]);
255
- });
256
-
257
- it("renders content-block → items → cta with NO payment-receipt when paymentStatus is unpaid (D6 row 2)", async () => {
258
- mockGetSession.mockResolvedValue({
259
- ok: true,
260
- body: { ...PAID_SESSION, paymentStatus: "unpaid" },
261
- });
262
-
263
- await renderPage("cs_test_pending");
264
-
265
- expect(sectionTypes()).toEqual(["content-block", "items", "cta"]);
266
- });
267
-
268
- it("renders content-block → items → cta when paymentStatus is no_payment_required (D6 row 2)", async () => {
269
- mockGetSession.mockResolvedValue({
270
- ok: true,
271
- body: { ...PAID_SESSION, paymentStatus: "no_payment_required" },
272
- });
273
-
274
- await renderPage("cs_test_pending");
275
-
276
- expect(sectionTypes()).toEqual(["content-block", "items", "cta"]);
277
- });
278
-
279
- // ── AC-8 — the paid render is not forgeable ─────────────────────────────
280
-
281
- it("no session_id: the DOM carries no data-outcome=success and no PaymentComplete string (AC-8)", async () => {
282
- await renderPage(undefined);
283
-
284
- const serialized = JSON.stringify(capturedSections);
285
- expect(serialized).not.toContain('"outcome":"success"');
286
- expect(serialized).not.toContain("PaymentComplete");
287
- });
288
-
289
- it("unpaid session: the DOM carries no data-outcome=success and no PaymentComplete string (AC-8)", async () => {
290
- mockGetSession.mockResolvedValue({
291
- ok: true,
292
- body: { ...PAID_SESSION, paymentStatus: "unpaid" },
293
- });
294
-
295
- await renderPage("cs_test_pending");
296
-
297
- const serialized = JSON.stringify(capturedSections);
298
- expect(serialized).not.toContain('"outcome":"success"');
299
- expect(serialized).not.toContain("PaymentComplete");
300
- });
301
-
302
- // ── AC-7 — degrade, never crash ──────────────────────────────────────────
303
-
304
- it("every degraded row still ends in a cta section (AC-7 — never a dead end)", async () => {
305
- await renderPage(undefined);
306
- expect(sectionTypes()[sectionTypes().length - 1]).toBe("cta");
307
-
308
- mockGetSession.mockResolvedValue({ ok: false, status: 502, body: {} });
309
- await renderPage("cs_test_outage");
310
- expect(sectionTypes()[sectionTypes().length - 1]).toBe("cta");
311
- });
312
-
313
- // ── AC-2/AC-5 — noindex ───────────────────────────────────────────────────
314
-
315
- it("is not indexable", async () => {
316
- const metadata = await generateMetadata({
317
- params: Promise.resolve({ locale: "en" }),
318
- });
319
- expect(metadata.robots).toEqual({ index: false, follow: true });
320
- });
321
-
322
- // ── #11095 D9, AC-7 — "Open your account" for the paid email ─────────────
323
-
324
- it("a paid read with customerEmail renders Open your account at accountInviteHref, inside a data-sentry-block (AC-7)", async () => {
325
- mockGetSession.mockResolvedValue({
326
- ok: true,
327
- body: { ...PAID_SESSION, customerEmail: "buyer@example.com" },
328
- });
329
- const { getByTestId } = await renderPage("cs_test_abc123");
330
- const link = getByTestId("purchase-success-account");
331
- expect(link.textContent).toBe("copy:success.openAccount");
332
- const expected = accountInviteHref("en", "buyer@example.com");
333
- expect(expected).not.toBeNull();
334
- expect(link.getAttribute("href")).toBe(expected);
335
- expect(link.closest("[data-sentry-block]")).not.toBeNull();
336
- // The sections are unchanged in every state.
337
- expect(sectionTypes()).toEqual(["payment-receipt", "items", "cta"]);
338
- });
339
-
340
- it.each([
341
- ["a paid read without customerEmail", { ok: true, body: PAID_SESSION }],
342
- [
343
- "an unpaid read, even with customerEmail",
344
- {
345
- ok: true,
346
- body: { ...PAID_SESSION, paymentStatus: "unpaid", customerEmail: "buyer@example.com" },
347
- },
348
- ],
349
- ["a 404 read", { ok: false, status: 404, body: { error: "unknown-session" } }],
350
- ])("%s renders no Open your account link (AC-7)", async (_label, response) => {
351
- mockGetSession.mockResolvedValue(response);
352
- const { queryByTestId, queryByText } = await renderPage("cs_test_abc123");
353
- expect(queryByTestId("purchase-success-account")).toBeNull();
354
- expect(queryByText("copy:success.openAccount")).toBeNull();
355
- });
356
-
357
- it("a rejected read renders no Open your account link (AC-7)", async () => {
358
- mockGetSession.mockRejectedValue(new Error("network"));
359
- const { queryByTestId, queryByText } = await renderPage("cs_test_abc123");
360
- expect(queryByTestId("purchase-success-account")).toBeNull();
361
- expect(queryByText("copy:success.openAccount")).toBeNull();
362
- });
363
-
364
- it("sends no referrer (SEC-11095-5)", async () => {
365
- const metadata = await generateMetadata({
366
- params: Promise.resolve({ locale: "en" }),
367
- });
368
- expect(metadata.referrer).toBe("no-referrer");
369
- });
370
-
371
- // ── T-16 / D12 — the request-time commerce-claim gate ───────────────────
372
-
373
- it("answers notFound() when the commerce claim is NOT held, before any API call (D12)", async () => {
374
- mockCheckLicense.mockResolvedValue({ revoked: false, features: [] });
375
-
376
- await expect(renderPage("cs_test_abc123")).rejects.toThrow(
377
- "NEXT_NOT_FOUND",
378
- );
379
- expect(mockNotFound).toHaveBeenCalledTimes(1);
380
- expect(mockGetSession).not.toHaveBeenCalled();
381
- });
382
-
383
- it("renders normally when the commerce claim IS held", async () => {
384
- mockCheckLicense.mockResolvedValue({ revoked: false, features: ["commerce"] });
385
- mockGetSession.mockResolvedValue({ ok: true, body: PAID_SESSION });
386
-
387
- await renderPage("cs_test_abc123");
388
-
389
- expect(mockNotFound).not.toHaveBeenCalled();
390
- expect(sectionTypes()).toEqual(["payment-receipt", "items", "cta"]);
391
- });
392
-
393
- it("fail-closed: answers notFound() when the licence read THROWS (D12's fail-closed direction)", async () => {
394
- mockCheckLicense.mockRejectedValue(new Error("licence read blew up"));
395
-
396
- await expect(renderPage("cs_test_abc123")).rejects.toThrow();
397
- // resolveCommerceClaim() itself is fail-closed (returns false on a
398
- // throw, never propagates) — this page never has to catch anything; it
399
- // just reads the resolver's own answer.
400
- });
401
-
402
- // ── FR-3 — never writes ──────────────────────────────────────────────────
403
-
404
- it("never calls prisma, stripe writes, .create(), .update() or .upsert() (FR-3, grep-style)", async () => {
405
- mockGetSession.mockResolvedValue({ ok: true, body: PAID_SESSION });
406
- await renderPage("cs_test_abc123");
407
-
408
- // The page's only Stripe-adjacent call is the READ wrapper.
409
- expect(mockGetSession).toHaveBeenCalledTimes(1);
410
- });
411
- });