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,520 +0,0 @@
1
- // oss: false
2
- /**
3
- * Tests for FlowStepperClient's permalink completion redirect on a
4
- * `mode:"recommending"` flow (#4770 D1/D7/D12).
5
- *
6
- * A SEPARATE file from `FlowStepperClient.test.tsx` — the regression floor
7
- * §5.2 requires stay UNEDITED — because that file's fixtures are all
8
- * `qualifying`-shaped (no `mode`/`offers`), so it never exercises the
9
- * recommending branch this spec adds. Scope extension (§4's own D6
10
- * precedent): the smallest addition that gives AC5's two novel assertions a
11
- * test home without touching the regression-floor file.
12
- *
13
- * AC5 (bullet 5, this file's half) — completing a recommending flow pushes
14
- * the results permalink, whose decoded payload matches the answers
15
- * submitted. (The qualifying-flow half of AC5 is already covered, unedited,
16
- * by `FlowStepperClient.test.tsx`'s own AC1/AC4 suites.)
17
- *
18
- * AC5 (bullet 6) — a recommending flow whose field steps submitted an
19
- * email, a name, a phone number, and free text produces a payload whose
20
- * decoded answers contain NONE of those four submitted substrings, and
21
- * whose keys are exactly the flow's segmentation question ids.
22
- *
23
- * `@working-theory/ui`'s FlowStepper is mocked as a minimal stub that
24
- * captures the `onSubmitStep`/`onCompleted` props it receives, exactly as
25
- * the sibling file does — this file's scope is FlowStepperClient's own
26
- * wiring, not FlowStepper's own submission/step-navigation behavior
27
- * (covered by its own package test).
28
- */
29
- import { render } from "@testing-library/react";
30
- import type { FlowConfig } from "@working-theory/validation";
31
- import { decodePermalink } from "@working-theory/validation";
32
- import type { ReactElement } from "react";
33
-
34
- const mockPush = jest.fn();
35
- jest.mock("next/navigation", () => ({
36
- useRouter: () => ({ push: mockPush }),
37
- }));
38
-
39
- jest.mock("next-intl", () => ({
40
- useTranslations: () => (key: string) => key,
41
- useMessages: () => ({}),
42
- }));
43
-
44
- // FlowStepperClient binds onSubmitStep directly to this Server Action, and
45
- // the boundary under test here is the onCompleted -> router.push wiring, not
46
- // the action itself (covered by flow.actions.test.ts) — mirrors the sibling
47
- // FlowStepperClient.test.tsx's identical narrow-scope justification.
48
- // eslint-disable-next-line no-restricted-syntax -- see comment above
49
- jest.mock("../flow.actions", () => ({
50
- submitFlowStepAction: jest.fn(),
51
- }));
52
-
53
- interface MockFlowStepperProps {
54
- onSubmitStep: (payload: {
55
- stepKey: string;
56
- values: Record<string, unknown>;
57
- locale?: string;
58
- }) => Promise<{
59
- ok: boolean;
60
- kind?: string;
61
- response?: { completed: boolean; segment?: string };
62
- }>;
63
- onCompleted?: (result: { segment?: string }) => void;
64
- }
65
-
66
- let captured: MockFlowStepperProps | undefined;
67
-
68
- jest.mock("@working-theory/ui-signal-collectors", () => ({
69
- FlowStepper: (props: MockFlowStepperProps) => {
70
- captured = props;
71
- return require("react").createElement("div", {
72
- "data-testid": "mock-flow-stepper",
73
- }) as ReactElement;
74
- },
75
- }));
76
-
77
- import { submitFlowStepAction } from "../flow.actions";
78
- import { FlowStepperClient } from "../FlowStepperClient";
79
-
80
- const mockSubmitFlowStepAction = submitFlowStepAction as jest.MockedFunction<
81
- typeof submitFlowStepAction
82
- >;
83
-
84
- const SLUG = "ailk-recommender";
85
-
86
- function recommendingFlowConfig(): FlowConfig {
87
- return {
88
- slug: SLUG,
89
- defaultLocale: "en",
90
- mode: "recommending",
91
- steps: [
92
- {
93
- key: "team",
94
- type: "segmentation",
95
- copy: { title: { en: "Team" } },
96
- questions: [
97
- {
98
- name: "team_size",
99
- options: [
100
- { value: "solo", label: { en: "Solo" } },
101
- { value: "agency", label: { en: "Agency" } },
102
- ],
103
- },
104
- {
105
- name: "wants_seo",
106
- options: [
107
- { value: "yes", label: { en: "Yes" } },
108
- { value: "no", label: { en: "No" } },
109
- ],
110
- },
111
- ],
112
- },
113
- {
114
- key: "contact",
115
- type: "field",
116
- copy: { title: { en: "Contact" } },
117
- fields: [
118
- {
119
- name: "email",
120
- inputType: "email",
121
- required: true,
122
- copy: { label: { en: "Email" } },
123
- },
124
- {
125
- name: "name",
126
- inputType: "text",
127
- required: true,
128
- copy: { label: { en: "Name" } },
129
- },
130
- {
131
- name: "phone",
132
- inputType: "tel",
133
- copy: { label: { en: "Phone" } },
134
- },
135
- {
136
- name: "message",
137
- inputType: "textarea",
138
- copy: { label: { en: "Message" } },
139
- },
140
- ],
141
- },
142
- ],
143
- offers: [
144
- {
145
- key: "free_oss",
146
- copy: { name: { en: "Free" } },
147
- price: { kind: "label", label: { en: "Free" } },
148
- rules: [
149
- {
150
- when: { answer: "team_size", eq: "solo" },
151
- reason: { en: "You're solo" },
152
- },
153
- ],
154
- },
155
- ],
156
- } as FlowConfig;
157
- }
158
-
159
- function pushedPayload(): string {
160
- expect(mockPush).toHaveBeenCalledTimes(1);
161
- const pushedUrl = mockPush.mock.calls[0]?.[0] as string;
162
- const match = pushedUrl.match(new RegExp(`^/en/flows/${SLUG}/results/(.+)$`));
163
- expect(match).not.toBeNull();
164
- return match![1]!;
165
- }
166
-
167
- beforeEach(() => {
168
- mockPush.mockClear();
169
- mockSubmitFlowStepAction.mockClear();
170
- captured = undefined;
171
- });
172
-
173
- describe("FlowStepperClient — permalink completion on a recommending flow (#4770 AC5 bullet 5)", () => {
174
- it("pushes the results permalink, whose decoded payload matches the answers submitted", async () => {
175
- mockSubmitFlowStepAction.mockResolvedValueOnce({
176
- ok: true,
177
- response: {
178
- sessionId: "sess1",
179
- landed: "team",
180
- nextStepKey: null,
181
- completed: true,
182
- },
183
- });
184
-
185
- render(
186
- <FlowStepperClient
187
- config={recommendingFlowConfig()}
188
- locale="en"
189
- slug={SLUG}
190
- />,
191
- );
192
-
193
- const result = await captured!.onSubmitStep({
194
- stepKey: "team",
195
- values: { team_size: "solo", wants_seo: "yes" },
196
- locale: "en",
197
- });
198
- expect(result.ok).toBe(true);
199
-
200
- captured!.onCompleted?.({});
201
-
202
- const decoded = decodePermalink(pushedPayload());
203
- expect(decoded.ok).toBe(true);
204
- if (!decoded.ok) return;
205
- expect(decoded.value.flowSlug).toBe(SLUG);
206
- expect(decoded.value.answers).toEqual({
207
- team_size: "solo",
208
- wants_seo: "yes",
209
- });
210
- });
211
- });
212
-
213
- describe("FlowStepperClient — PII exclusion on a recommending flow (#4770 AC5 bullet 6)", () => {
214
- it("excludes every field-step value; keys are exactly the segmentation question ids", async () => {
215
- mockSubmitFlowStepAction
216
- .mockResolvedValueOnce({
217
- ok: true,
218
- response: {
219
- sessionId: "sess1",
220
- landed: "team",
221
- nextStepKey: "contact",
222
- completed: false,
223
- },
224
- })
225
- .mockResolvedValueOnce({
226
- ok: true,
227
- response: {
228
- sessionId: "sess1",
229
- landed: "contact",
230
- nextStepKey: null,
231
- completed: true,
232
- },
233
- });
234
-
235
- render(
236
- <FlowStepperClient
237
- config={recommendingFlowConfig()}
238
- locale="en"
239
- slug={SLUG}
240
- />,
241
- );
242
-
243
- await captured!.onSubmitStep({
244
- stepKey: "team",
245
- values: { team_size: "agency", wants_seo: "no" },
246
- locale: "en",
247
- });
248
-
249
- const PII_PAYLOAD = {
250
- email: "jane@example.com",
251
- name: "Jane Doe",
252
- phone: "555-123-4567",
253
- message: "Please reach out about the enterprise plan as soon as possible",
254
- };
255
- await captured!.onSubmitStep({
256
- stepKey: "contact",
257
- values: PII_PAYLOAD,
258
- locale: "en",
259
- });
260
-
261
- captured!.onCompleted?.({});
262
-
263
- const decoded = decodePermalink(pushedPayload());
264
- expect(decoded.ok).toBe(true);
265
- if (!decoded.ok) return;
266
-
267
- expect(Object.keys(decoded.value.answers).sort()).toEqual([
268
- "team_size",
269
- "wants_seo",
270
- ]);
271
-
272
- const serializedAnswers = JSON.stringify(decoded.value.answers);
273
- for (const value of Object.values(PII_PAYLOAD)) {
274
- expect(serializedAnswers).not.toContain(value);
275
- }
276
- });
277
- });
278
-
279
- // Code-review finding (#4770): the permalink's answer set must include the
280
- // `whenHidden` auto-answers of a currently-hidden segmentation step —
281
- // exactly what the server's own completion-payload assembly
282
- // (flow-engine.ts's completeSubmission) merges in via `hiddenAnswers()` —
283
- // so a cold-load recommendation never silently diverges from what the same
284
- // walk would score through the server's own pipeline.
285
- function recommendingFlowConfigWithHiddenStep(): FlowConfig {
286
- return {
287
- slug: SLUG,
288
- defaultLocale: "en",
289
- mode: "recommending",
290
- steps: [
291
- {
292
- key: "team",
293
- type: "segmentation",
294
- copy: { title: { en: "Team" } },
295
- questions: [
296
- {
297
- name: "team_size",
298
- options: [
299
- { value: "solo", label: { en: "Solo" } },
300
- { value: "agency", label: { en: "Agency" } },
301
- ],
302
- },
303
- ],
304
- },
305
- {
306
- key: "extras",
307
- type: "segmentation",
308
- copy: { title: { en: "Extras" } },
309
- // Hidden whenever team_size !== "agency" — never landed/submitted
310
- // for a "solo" visitor, so its answer never reaches answersRef.
311
- showIf: { answer: "team_size", eq: "agency" },
312
- whenHidden: { extras_included: "none" },
313
- questions: [
314
- {
315
- name: "extras_included",
316
- options: [
317
- { value: "none", label: { en: "None" } },
318
- { value: "addon", label: { en: "Add-on" } },
319
- ],
320
- },
321
- ],
322
- },
323
- ],
324
- offers: [
325
- {
326
- key: "free_oss",
327
- copy: { name: { en: "Free" } },
328
- price: { kind: "label", label: { en: "Free" } },
329
- rules: [
330
- {
331
- when: { answer: "team_size", eq: "solo" },
332
- reason: { en: "You're solo" },
333
- },
334
- ],
335
- },
336
- ],
337
- } as FlowConfig;
338
- }
339
-
340
- describe("FlowStepperClient — hidden-step whenHidden auto-answers reach the permalink (code-review finding, #4770)", () => {
341
- it("includes a currently-hidden segmentation step's whenHidden auto-answer, never submitted directly", async () => {
342
- mockSubmitFlowStepAction.mockResolvedValueOnce({
343
- ok: true,
344
- response: {
345
- sessionId: "sess1",
346
- landed: "team",
347
- nextStepKey: null,
348
- completed: true,
349
- },
350
- });
351
-
352
- render(
353
- <FlowStepperClient
354
- config={recommendingFlowConfigWithHiddenStep()}
355
- locale="en"
356
- slug={SLUG}
357
- />,
358
- );
359
-
360
- // Only "team" is ever submitted — "extras" is hidden (showIf fails for
361
- // team_size:"solo") and its step is never landed/submitted.
362
- await captured!.onSubmitStep({
363
- stepKey: "team",
364
- values: { team_size: "solo" },
365
- locale: "en",
366
- });
367
-
368
- captured!.onCompleted?.({});
369
-
370
- const decoded = decodePermalink(pushedPayload());
371
- expect(decoded.ok).toBe(true);
372
- if (!decoded.ok) return;
373
-
374
- expect(decoded.value.answers).toEqual({
375
- team_size: "solo",
376
- extras_included: "none",
377
- });
378
- });
379
- });
380
-
381
- // ─── #4842 AC-6 (the write half) — the walk's session id rides sessionStorage
382
- // (additive; the cases above are the regression floor and stay as they were) ─
383
-
384
- describe("FlowStepperClient — session hand-off on completion (#4842 AC-6, write half)", () => {
385
- const STORAGE_KEY = `ailk:flow-session:${SLUG}`;
386
-
387
- beforeEach(() => {
388
- window.sessionStorage.clear();
389
- });
390
-
391
- it("a recommending completion writes the LAST onSubmitStep result's response.sessionId before router.push", async () => {
392
- mockSubmitFlowStepAction
393
- .mockResolvedValueOnce({
394
- ok: true,
395
- response: { sessionId: "sess-first", landed: "team", nextStepKey: "contact", completed: false },
396
- })
397
- .mockResolvedValueOnce({
398
- ok: true,
399
- response: { sessionId: "sess-last", landed: "contact", nextStepKey: null, completed: true },
400
- });
401
- let storedAtPush: string | null | undefined;
402
- mockPush.mockImplementationOnce(() => {
403
- storedAtPush = window.sessionStorage.getItem(STORAGE_KEY);
404
- });
405
-
406
- render(<FlowStepperClient config={recommendingFlowConfig()} locale="en" slug={SLUG} />);
407
-
408
- await captured!.onSubmitStep({
409
- stepKey: "team",
410
- values: { team_size: "solo", wants_seo: "yes" },
411
- locale: "en",
412
- });
413
- expect(window.sessionStorage.getItem(STORAGE_KEY)).toBeNull();
414
- await captured!.onSubmitStep({
415
- stepKey: "contact",
416
- values: { email: "jane@example.com", name: "Jane" },
417
- locale: "en",
418
- });
419
- expect(window.sessionStorage.getItem(STORAGE_KEY)).toBeNull();
420
-
421
- captured!.onCompleted?.({});
422
-
423
- expect(mockPush).toHaveBeenCalledTimes(1);
424
- expect(storedAtPush).toBe("sess-last");
425
- expect(window.sessionStorage.getItem(STORAGE_KEY)).toBe("sess-last");
426
- });
427
-
428
- it("a qualifying completion writes nothing", async () => {
429
- mockSubmitFlowStepAction.mockResolvedValueOnce({
430
- ok: true,
431
- response: { sessionId: "sess-q", landed: "team", nextStepKey: null, completed: true },
432
- });
433
- const { mode: _mode, offers: _offers, ...qualifying } = recommendingFlowConfig();
434
-
435
- render(<FlowStepperClient config={qualifying as FlowConfig} locale="en" slug={SLUG} />);
436
-
437
- await captured!.onSubmitStep({
438
- stepKey: "team",
439
- values: { team_size: "solo", wants_seo: "yes" },
440
- locale: "en",
441
- });
442
- captured!.onCompleted?.({});
443
-
444
- expect(window.sessionStorage.getItem(STORAGE_KEY)).toBeNull();
445
- });
446
- });
447
-
448
- // ─── #11013 spec E, D-J (AC-3) — a recommending flow with no offers now reaches
449
- // the results page; a flow with offers pushes exactly as before ─────────────
450
-
451
- describe("FlowStepperClient — the results push on a recommending flow with no offers (#11013 D-J, AC-3)", () => {
452
- function noOffersConfig(extra: Record<string, unknown> = {}): FlowConfig {
453
- const { offers: _offers, ...rest } = recommendingFlowConfig();
454
- return { ...rest, ...extra } as FlowConfig;
455
- }
456
-
457
- it("no offers, no by-result rows, no ending: the completed walk pushes the results permalink", async () => {
458
- mockSubmitFlowStepAction.mockResolvedValueOnce({
459
- ok: true,
460
- response: { sessionId: "sess-r", landed: "team", nextStepKey: null, completed: true },
461
- });
462
-
463
- render(<FlowStepperClient config={noOffersConfig()} locale="en" slug={SLUG} />);
464
- expect(captured?.onCompleted).toBeDefined();
465
-
466
- await captured!.onSubmitStep({
467
- stepKey: "team",
468
- values: { team_size: "solo", wants_seo: "yes" },
469
- locale: "en",
470
- });
471
- captured!.onCompleted?.({});
472
-
473
- const decoded = decodePermalink(pushedPayload());
474
- expect(decoded.ok).toBe(true);
475
- if (!decoded.ok) return;
476
- expect(decoded.value.answers).toEqual({ team_size: "solo", wants_seo: "yes" });
477
- expect(window.sessionStorage.getItem(`ailk:flow-session:${SLUG}`)).toBe("sess-r");
478
- });
479
-
480
- it("a flow that is not recommending is passed no onCompleted and pushes nothing", async () => {
481
- mockSubmitFlowStepAction.mockResolvedValueOnce({
482
- ok: true,
483
- response: { sessionId: "sess-q", landed: "team", nextStepKey: null, completed: true },
484
- });
485
- const { mode: _mode, ...qualifying } = noOffersConfig();
486
-
487
- render(<FlowStepperClient config={qualifying as FlowConfig} locale="en" slug={SLUG} />);
488
- expect(captured?.onCompleted).toBeUndefined();
489
- await captured!.onSubmitStep({ stepKey: "team", values: { team_size: "solo" }, locale: "en" });
490
- expect(mockPush).not.toHaveBeenCalled();
491
- });
492
-
493
- it("a recommending flow with an ending and offers is passed no onCompleted (the ending wins, D-I)", () => {
494
- render(
495
- <FlowStepperClient
496
- config={{
497
- ...recommendingFlowConfig(),
498
- ending: { default: { kind: "screen", headline: { en: "Done" } } },
499
- } as FlowConfig}
500
- locale="en"
501
- slug={SLUG}
502
- />,
503
- );
504
- expect(captured?.onCompleted).toBeUndefined();
505
- });
506
-
507
- it("a recommending flow with offers and no ending pushes the permalink as at the pin", async () => {
508
- mockSubmitFlowStepAction.mockResolvedValueOnce({
509
- ok: true,
510
- response: { sessionId: "sess-o", landed: "team", nextStepKey: null, completed: true },
511
- });
512
-
513
- render(<FlowStepperClient config={recommendingFlowConfig()} locale="en" slug={SLUG} />);
514
- await captured!.onSubmitStep({ stepKey: "team", values: { team_size: "agency", wants_seo: "no" }, locale: "en" });
515
- captured!.onCompleted?.({});
516
-
517
- const decoded = decodePermalink(pushedPayload());
518
- expect(decoded.ok && decoded.value.answers).toEqual({ team_size: "agency", wants_seo: "no" });
519
- });
520
- });