create-ailk 0.39.0 → 0.40.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 (187) hide show
  1. package/dist/add-route.js +15 -0
  2. package/dist/body-heading.d.ts +2 -1
  3. package/dist/body-heading.js +31 -3
  4. package/dist/module-architecture.js +0 -3
  5. package/dist/remove-module.js +13 -4
  6. package/dist/routes.d.ts +7 -0
  7. package/dist/routes.js +1 -1
  8. package/dist/site-roster.js +7 -1
  9. package/dist/surfaces.d.ts +2 -0
  10. package/dist/surfaces.js +59 -172
  11. package/package.json +3 -3
  12. package/templates/apps/web/CLAUDE.md +7 -1
  13. package/templates/apps/web/__tests__/__mocks__/next-intl-server.ts +3 -2
  14. package/templates/apps/web/__tests__/__mocks__/next-intl.ts +3 -2
  15. package/templates/apps/web/app/[locale]/layout.tsx +1 -1
  16. package/templates/apps/web/i18n/request.ts +5 -1
  17. package/templates/apps/web/jest.config.cjs +6 -0
  18. package/templates/apps/web/lib/__tests__/deck-page.test.ts +9 -0
  19. package/templates/apps/web/lib/__tests__/in-page-magnet-self-request.test.ts +1 -1
  20. package/templates/apps/web/lib/__tests__/in-page-magnet.test.ts +2 -2
  21. package/templates/apps/web/lib/__tests__/pricing-page.test.ts +1 -1
  22. package/templates/apps/web/lib/__tests__/structured-data.test.tsx +17 -4
  23. package/templates/apps/web/lib/in-page-magnet.ts +2 -2
  24. package/templates/apps/web/lib/pricing-page.ts +3 -3
  25. package/templates/apps/web/{app/[locale]/contact → lib}/site-contact-email.ts +1 -1
  26. package/templates/apps/web/{app/[locale]/contact → lib}/site-contact-lines.ts +1 -1
  27. package/templates/apps/web/lib/site-header.ts +1 -1
  28. package/templates/apps/web/messages/en.json +0 -119
  29. package/templates/apps/web/next.config.mjs +7 -0
  30. package/templates/apps/web/package.json +1 -0
  31. package/templates/apps/web/site-pages.config.tsx +85 -0
  32. package/templates/tools/body-heading.ts +30 -3
  33. package/versions.json +50 -49
  34. package/templates/apps/web/app/[locale]/(authed)/leads/__tests__/page.test.tsx +0 -205
  35. package/templates/apps/web/app/[locale]/(authed)/leads/components/LeadsTable.tsx +0 -137
  36. package/templates/apps/web/app/[locale]/(authed)/leads/page.tsx +0 -122
  37. package/templates/apps/web/app/[locale]/(authed)/waitlist/components/ForbiddenState.tsx +0 -24
  38. package/templates/apps/web/app/[locale]/(authed)/waitlist/format.ts +0 -111
  39. package/templates/apps/web/app/[locale]/[slug]/[detail]/__tests__/page.test.tsx +0 -402
  40. package/templates/apps/web/app/[locale]/[slug]/[detail]/page.tsx +0 -143
  41. package/templates/apps/web/app/[locale]/[slug]/__tests__/page.test.tsx +0 -148
  42. package/templates/apps/web/app/[locale]/[slug]/page.tsx +0 -109
  43. package/templates/apps/web/app/[locale]/about/[slug]/page.tsx +0 -46
  44. package/templates/apps/web/app/[locale]/about/__tests__/about-routes.test.tsx +0 -353
  45. package/templates/apps/web/app/[locale]/about/page.tsx +0 -122
  46. package/templates/apps/web/app/[locale]/alternatives/__tests__/page.test.tsx +0 -161
  47. package/templates/apps/web/app/[locale]/alternatives/page.tsx +0 -112
  48. package/templates/apps/web/app/[locale]/careers/[slug]/[action]/page.tsx +0 -244
  49. package/templates/apps/web/app/[locale]/careers/[slug]/apply.actions.ts +0 -325
  50. package/templates/apps/web/app/[locale]/careers/[slug]/job-application-form.ts +0 -120
  51. package/templates/apps/web/app/[locale]/careers/[slug]/page.tsx +0 -73
  52. package/templates/apps/web/app/[locale]/careers/__tests__/apply.actions.test.ts +0 -497
  53. package/templates/apps/web/app/[locale]/careers/__tests__/careers-hub.test.tsx +0 -172
  54. package/templates/apps/web/app/[locale]/careers/__tests__/careers-set.test.tsx +0 -153
  55. package/templates/apps/web/app/[locale]/careers/__tests__/job-application-form.test.ts +0 -141
  56. package/templates/apps/web/app/[locale]/careers/__tests__/job-apply-page.test.tsx +0 -546
  57. package/templates/apps/web/app/[locale]/careers/__tests__/page-renderer-migration.test.tsx +0 -189
  58. package/templates/apps/web/app/[locale]/careers/page.tsx +0 -165
  59. package/templates/apps/web/app/[locale]/case-studies/[slug]/page.tsx +0 -49
  60. package/templates/apps/web/app/[locale]/case-studies/__tests__/hub-children.test.tsx +0 -65
  61. package/templates/apps/web/app/[locale]/case-studies/__tests__/page-renderer-migration.test.tsx +0 -125
  62. package/templates/apps/web/app/[locale]/case-studies/page.tsx +0 -49
  63. package/templates/apps/web/app/[locale]/clients/__tests__/page-renderer-migration.test.tsx +0 -85
  64. package/templates/apps/web/app/[locale]/clients/page.tsx +0 -47
  65. package/templates/apps/web/app/[locale]/contact/ConversationalIntakeWrapper.tsx +0 -249
  66. package/templates/apps/web/app/[locale]/contact/__tests__/ConversationalIntakeWrapper.test.tsx +0 -400
  67. package/templates/apps/web/app/[locale]/contact/__tests__/contact-form-magnet.test.ts +0 -138
  68. package/templates/apps/web/app/[locale]/contact/__tests__/contact-form-text.test.ts +0 -49
  69. package/templates/apps/web/app/[locale]/contact/__tests__/contact-magnet-page.test.tsx +0 -494
  70. package/templates/apps/web/app/[locale]/contact/__tests__/contact.actions.test.ts +0 -1122
  71. package/templates/apps/web/app/[locale]/contact/__tests__/intake-analytics.test.ts +0 -51
  72. package/templates/apps/web/app/[locale]/contact/__tests__/page-renderer-migration.test.tsx +0 -319
  73. package/templates/apps/web/app/[locale]/contact/contact-form-magnet.ts +0 -77
  74. package/templates/apps/web/app/[locale]/contact/contact-form-text.ts +0 -52
  75. package/templates/apps/web/app/[locale]/contact/contact.actions.ts +0 -403
  76. package/templates/apps/web/app/[locale]/contact/intake-analytics.ts +0 -49
  77. package/templates/apps/web/app/[locale]/contact/intake-script.ts +0 -92
  78. package/templates/apps/web/app/[locale]/contact/page.tsx +0 -267
  79. package/templates/apps/web/app/[locale]/courses/[slug]/page.tsx +0 -50
  80. package/templates/apps/web/app/[locale]/courses/__tests__/hub-children.test.tsx +0 -32
  81. package/templates/apps/web/app/[locale]/courses/__tests__/page-renderer-migration.test.tsx +0 -123
  82. package/templates/apps/web/app/[locale]/courses/page.tsx +0 -49
  83. package/templates/apps/web/app/[locale]/events/[slug]/page.tsx +0 -57
  84. package/templates/apps/web/app/[locale]/events/__tests__/hub-children.test.tsx +0 -32
  85. package/templates/apps/web/app/[locale]/events/__tests__/page-renderer-migration.test.tsx +0 -164
  86. package/templates/apps/web/app/[locale]/events/__tests__/program-event.test.tsx +0 -120
  87. package/templates/apps/web/app/[locale]/events/page.tsx +0 -60
  88. package/templates/apps/web/app/[locale]/faq/page.tsx +0 -54
  89. package/templates/apps/web/app/[locale]/features/[slug]/page.tsx +0 -54
  90. package/templates/apps/web/app/[locale]/features/__tests__/hub-children.test.tsx +0 -32
  91. package/templates/apps/web/app/[locale]/features/page.tsx +0 -50
  92. package/templates/apps/web/app/[locale]/for/[slug]/page.tsx +0 -54
  93. package/templates/apps/web/app/[locale]/for/__tests__/hub-children.test.tsx +0 -32
  94. package/templates/apps/web/app/[locale]/for/__tests__/page-renderer-migration.test.tsx +0 -90
  95. package/templates/apps/web/app/[locale]/for/page.tsx +0 -51
  96. package/templates/apps/web/app/[locale]/glossary/page.tsx +0 -53
  97. package/templates/apps/web/app/[locale]/how-to/[slug]/page.tsx +0 -50
  98. package/templates/apps/web/app/[locale]/how-to/__tests__/page-renderer-migration.test.tsx +0 -78
  99. package/templates/apps/web/app/[locale]/how-to/page.tsx +0 -50
  100. package/templates/apps/web/app/[locale]/integrations/[slug]/page.tsx +0 -54
  101. package/templates/apps/web/app/[locale]/integrations/__tests__/hub-children.test.tsx +0 -38
  102. package/templates/apps/web/app/[locale]/integrations/__tests__/page-renderer-migration.test.tsx +0 -141
  103. package/templates/apps/web/app/[locale]/integrations/page.tsx +0 -49
  104. package/templates/apps/web/app/[locale]/launch-service/page.tsx +0 -44
  105. package/templates/apps/web/app/[locale]/newsletter/__tests__/page.test.tsx +0 -236
  106. package/templates/apps/web/app/[locale]/newsletter/page.tsx +0 -179
  107. package/templates/apps/web/app/[locale]/page.tsx +0 -147
  108. package/templates/apps/web/app/[locale]/partners/[slug]/page.tsx +0 -45
  109. package/templates/apps/web/app/[locale]/partners/__tests__/hub-children.test.tsx +0 -32
  110. package/templates/apps/web/app/[locale]/partners/__tests__/page-renderer-migration.test.tsx +0 -125
  111. package/templates/apps/web/app/[locale]/partners/page.tsx +0 -49
  112. package/templates/apps/web/app/[locale]/portfolio/[slug]/page.tsx +0 -46
  113. package/templates/apps/web/app/[locale]/portfolio/__tests__/hub-children.test.tsx +0 -38
  114. package/templates/apps/web/app/[locale]/portfolio/page.tsx +0 -50
  115. package/templates/apps/web/app/[locale]/pricing/[slug]/__tests__/page.test.tsx +0 -324
  116. package/templates/apps/web/app/[locale]/pricing/[slug]/page.tsx +0 -87
  117. package/templates/apps/web/app/[locale]/pricing/__tests__/__snapshots__/unconnected.test.tsx.snap +0 -7
  118. package/templates/apps/web/app/[locale]/pricing/__tests__/offerings.test.tsx +0 -605
  119. package/templates/apps/web/app/[locale]/pricing/__tests__/page.test.tsx +0 -219
  120. package/templates/apps/web/app/[locale]/pricing/__tests__/pricing-pages.test.tsx +0 -215
  121. package/templates/apps/web/app/[locale]/pricing/__tests__/unconnected.test.tsx +0 -282
  122. package/templates/apps/web/app/[locale]/pricing/page.tsx +0 -120
  123. package/templates/apps/web/app/[locale]/privacy/page.tsx +0 -40
  124. package/templates/apps/web/app/[locale]/products/[slug]/page.tsx +0 -50
  125. package/templates/apps/web/app/[locale]/products/__tests__/hub-children.test.tsx +0 -32
  126. package/templates/apps/web/app/[locale]/products/__tests__/page-renderer-migration.test.tsx +0 -141
  127. package/templates/apps/web/app/[locale]/products/page.tsx +0 -49
  128. package/templates/apps/web/app/[locale]/projects/[slug]/page.tsx +0 -37
  129. package/templates/apps/web/app/[locale]/projects/__tests__/hub-children.test.tsx +0 -32
  130. package/templates/apps/web/app/[locale]/projects/__tests__/page-renderer-migration.test.tsx +0 -157
  131. package/templates/apps/web/app/[locale]/projects/page.tsx +0 -49
  132. package/templates/apps/web/app/[locale]/purchase-policy/page.tsx +0 -49
  133. package/templates/apps/web/app/[locale]/resources/[slug]/page.tsx +0 -54
  134. package/templates/apps/web/app/[locale]/resources/__tests__/hub-children.test.tsx +0 -38
  135. package/templates/apps/web/app/[locale]/resources/__tests__/page-renderer-migration.test.tsx +0 -151
  136. package/templates/apps/web/app/[locale]/resources/page.tsx +0 -49
  137. package/templates/apps/web/app/[locale]/services/[slug]/[child]/page.tsx +0 -68
  138. package/templates/apps/web/app/[locale]/services/[slug]/page.tsx +0 -88
  139. package/templates/apps/web/app/[locale]/services/__tests__/hub-children.test.tsx +0 -158
  140. package/templates/apps/web/app/[locale]/services/__tests__/page-renderer-migration.test.tsx +0 -187
  141. package/templates/apps/web/app/[locale]/services/__tests__/service-detail-sections.test.tsx +0 -224
  142. package/templates/apps/web/app/[locale]/services/__tests__/service-families.test.tsx +0 -368
  143. package/templates/apps/web/app/[locale]/services/page.tsx +0 -71
  144. package/templates/apps/web/app/[locale]/software/[slug]/page.tsx +0 -49
  145. package/templates/apps/web/app/[locale]/software/__tests__/page-renderer-migration.test.tsx +0 -81
  146. package/templates/apps/web/app/[locale]/software/page.tsx +0 -49
  147. package/templates/apps/web/app/[locale]/team/[slug]/page.tsx +0 -45
  148. package/templates/apps/web/app/[locale]/team/__tests__/hub-children.test.tsx +0 -32
  149. package/templates/apps/web/app/[locale]/team/__tests__/team-routes.test.tsx +0 -161
  150. package/templates/apps/web/app/[locale]/team/page.tsx +0 -50
  151. package/templates/apps/web/app/[locale]/tech-articles/[slug]/page.tsx +0 -54
  152. package/templates/apps/web/app/[locale]/tech-articles/__tests__/page-renderer-migration.test.tsx +0 -82
  153. package/templates/apps/web/app/[locale]/tech-articles/page.tsx +0 -49
  154. package/templates/apps/web/app/[locale]/templates/[slug]/__tests__/page.test.tsx +0 -203
  155. package/templates/apps/web/app/[locale]/templates/[slug]/page.tsx +0 -81
  156. package/templates/apps/web/app/[locale]/templates/__tests__/page.test.tsx +0 -237
  157. package/templates/apps/web/app/[locale]/templates/page.tsx +0 -114
  158. package/templates/apps/web/app/[locale]/terms/page.tsx +0 -40
  159. package/templates/apps/web/app/[locale]/testimonials/__tests__/page-renderer-migration.test.tsx +0 -85
  160. package/templates/apps/web/app/[locale]/testimonials/page.tsx +0 -51
  161. package/templates/apps/web/app/[locale]/thanks/[slug]/__tests__/page.test.tsx +0 -136
  162. package/templates/apps/web/app/[locale]/thanks/[slug]/page.tsx +0 -39
  163. package/templates/apps/web/app/[locale]/unsubscribe/__tests__/unsubscribe-rsc-boundary.test.tsx +0 -226
  164. package/templates/apps/web/app/[locale]/unsubscribe/__tests__/unsubscribe.test.tsx +0 -217
  165. package/templates/apps/web/app/[locale]/unsubscribe/page.tsx +0 -106
  166. package/templates/apps/web/app/[locale]/unsubscribe/unsubscribe-button.tsx +0 -94
  167. package/templates/apps/web/app/[locale]/unsubscribe/unsubscribe.actions.ts +0 -55
  168. package/templates/apps/web/app/[locale]/vs/[slug]/__tests__/page.test.tsx +0 -100
  169. package/templates/apps/web/app/[locale]/vs/[slug]/page.tsx +0 -60
  170. package/templates/apps/web/app/[locale]/whitepapers/[slug]/page.tsx +0 -54
  171. package/templates/apps/web/app/[locale]/whitepapers/__tests__/page-renderer-migration.test.tsx +0 -82
  172. package/templates/apps/web/app/[locale]/whitepapers/page.tsx +0 -49
  173. package/templates/apps/web/app/[locale]/working-agreement/__tests__/page.test.tsx +0 -63
  174. package/templates/apps/web/app/[locale]/working-agreement/page.tsx +0 -41
  175. package/templates/apps/web/lib/__tests__/hub-children.fixtures.ts +0 -279
  176. package/templates/apps/web/lib/__tests__/route-family.test.ts +0 -57
  177. package/templates/apps/web/lib/__tests__/service-listing.test.ts +0 -111
  178. package/templates/apps/web/lib/__tests__/template-listing.test.ts +0 -158
  179. package/templates/apps/web/lib/hub-children.tsx +0 -351
  180. package/templates/apps/web/lib/meet-placeholder.ts +0 -5
  181. package/templates/apps/web/lib/posting-title.ts +0 -39
  182. package/templates/apps/web/lib/route-family.ts +0 -69
  183. package/templates/apps/web/lib/service-listing.ts +0 -89
  184. package/templates/apps/web/lib/template-listing.ts +0 -169
  185. package/templates/apps/web/src/lib/__tests__/lead-write.test.ts +0 -187
  186. package/templates/apps/web/src/lib/lead-write.ts +0 -90
  187. /package/templates/apps/web/{app/[locale]/contact → lib}/__tests__/site-contact-lines.test.ts +0 -0
@@ -1,605 +0,0 @@
1
- /**
2
- * /pricing renders the workspace's Offerings shown set (#8927, spec
3
- * docs/specs/8927-pricing-renders-the-shown-set-spec.md AC-1–AC-3, AC-5).
4
- *
5
- * A connected fixture workspace (C1): `global.fetch` answers
6
- * `GET <base>/v1/content/shown-offerings` with the route's own envelope and a
7
- * `shownSet` in the wire shape the route sends (no workspace or organization
8
- * id). The real api-client, the real mapper and the real Pricing section run.
9
- * The site's contact email is read from a temporary content root's
10
- * `_site.mdx`. The fixture is parsed with the shown-set schema first, so it
11
- * cannot drift from spec 8876 D4.
12
- *
13
- * The page shares one read for 15 seconds, so the suite moves `Date.now` 16
14
- * seconds before every case; AC-2 moves it by hand inside its cases.
15
- */
16
- import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
17
- import { tmpdir } from "node:os";
18
- import { join, resolve } from "node:path";
19
-
20
- import { act, fireEvent, render, screen, within } from "@testing-library/react";
21
- import {
22
- PageSectionsSchema,
23
- workspaceShownSetSchema,
24
- type OfferingsPrice,
25
- type OfferingsProduct,
26
- } from "@working-theory/validation";
27
-
28
- import PricingPage, { generateMetadata } from "../page";
29
-
30
- // #10704 — a fixture suite: its content is shaped for the mdx source, whatever the site serves from.
31
- process.env.CONTENT_ADAPTER = "mdx";
32
-
33
- const SITE_EMAIL = "hello@example.com";
34
- const HOSTILE = "</script><script>alert(1)</script>";
35
-
36
- // ── The connected fixture ────────────────────────────────────────────────────
37
-
38
- const INTERVAL = { monthly: "month", yearly: "year", once: null } as const;
39
-
40
- function price(
41
- plan: string,
42
- period: OfferingsPrice["period"],
43
- amount: number,
44
- ): OfferingsPrice {
45
- return {
46
- priceId: `price_${plan.replace(/-/g, "")}${period}`,
47
- lookupKey: `${plan}_${period}`,
48
- plan,
49
- period,
50
- interval: INTERVAL[period],
51
- amount,
52
- currency: "usd",
53
- };
54
- }
55
-
56
- function product(
57
- plan: string,
58
- ailkGroup: OfferingsProduct["ailkGroup"],
59
- name: string,
60
- prices: OfferingsPrice[],
61
- extra: Partial<OfferingsProduct> = {},
62
- ): OfferingsProduct {
63
- return {
64
- productId: `prod_${plan.replace(/-/g, "")}`,
65
- plan,
66
- name,
67
- description: null,
68
- marketingFeatures: [],
69
- unitLabel: null,
70
- note: null,
71
- termsNote: null,
72
- ailkGroup,
73
- ailkOrder: null,
74
- prices,
75
- recommended: false,
76
- ...extra,
77
- };
78
- }
79
-
80
- const STARTER = {
81
- name: "Starter",
82
- description: "For one small site",
83
- features: ["One site", "Email support", "Weekly backups"],
84
- unitLabel: "per site",
85
- note: "Billed per live site",
86
- termsNote: "Cancel any time",
87
- monthly: "$19/mo",
88
- annual: "$190/yr",
89
- };
90
-
91
- function offerings(): OfferingsProduct[] {
92
- return [
93
- product(
94
- "starter",
95
- "plan",
96
- STARTER.name,
97
- [price("starter", "monthly", 1900), price("starter", "yearly", 19000)],
98
- {
99
- description: STARTER.description,
100
- marketingFeatures: STARTER.features,
101
- unitLabel: STARTER.unitLabel,
102
- note: STARTER.note,
103
- termsNote: STARTER.termsNote,
104
- },
105
- ),
106
- product("growth", "plan", "Growth", [price("growth", "monthly", 4900)], {
107
- recommended: true,
108
- }),
109
- product("scale", "plan", "Scale", [price("scale", "once", 150000)]),
110
- product(
111
- "seo-audit",
112
- "addon",
113
- "SEO audit",
114
- [price("seo-audit", "monthly", 1500)],
115
- { unitLabel: "per audit" },
116
- ),
117
- ];
118
- }
119
-
120
- /** The shown set as the route sends it: parsed, then without the two ids. */
121
- function wireSet(
122
- edit: (list: OfferingsProduct[]) => OfferingsProduct[] = (l) => l,
123
- ) {
124
- const list = edit(offerings());
125
- const {
126
- workspaceId: _w,
127
- organizationId: _o,
128
- ...wire
129
- } = workspaceShownSetSchema.parse({
130
- workspaceId: "wksp_01890a5d-ac96-774b-bcce-b302099a8057",
131
- organizationId: "org_01890a5d-ac96-774b-bcce-b302099a8058",
132
- productIds: list.map((o) => o.productId),
133
- recommended: {
134
- plan:
135
- list.find((o) => o.ailkGroup === "plan" && o.recommended)?.productId ??
136
- null,
137
- addon: null,
138
- },
139
- offerings: list,
140
- state: "current",
141
- snapshotAt: "2026-10-18T00:00:00.000Z",
142
- });
143
- return wire;
144
- }
145
-
146
- // ── The fetch stub ───────────────────────────────────────────────────────────
147
-
148
- type Answer =
149
- | { status: number; body: unknown }
150
- | { status: number; notJson: true }
151
- | { reject: true };
152
-
153
- function shown(set: unknown = wireSet()): Answer {
154
- return {
155
- status: 200,
156
- body: { ok: true, data: { status: "shown", shownSet: set } },
157
- };
158
- }
159
-
160
- const answers: Answer[] = [];
161
- let answer: Answer = shown();
162
-
163
- const fetchMock: jest.Mock = jest.fn(async () => {
164
- const next = answers.shift() ?? answer;
165
- if ("reject" in next) throw new TypeError("fetch failed");
166
- return {
167
- ok: next.status >= 200 && next.status < 300,
168
- status: next.status,
169
- json: async () => {
170
- if ("notJson" in next) throw new SyntaxError("Unexpected token <");
171
- return next.body;
172
- },
173
- };
174
- });
175
-
176
- // ── The authored page ────────────────────────────────────────────────────────
177
-
178
- const getMdxSource = jest.fn().mockResolvedValue({
179
- frontmatter: {
180
- type: "Pricing",
181
- slug: "pricing",
182
- title: "Pricing",
183
- description: "Plans for every stage.",
184
- },
185
- body: "",
186
- });
187
-
188
- const HERO = {
189
- id: "hero",
190
- type: "hero",
191
- data: { headline: "Plans that grow with you", variant: "default" },
192
- };
193
- const FAQ = {
194
- id: "faq",
195
- type: "faq",
196
- data: {
197
- headline: "Questions",
198
- items: [{ question: "Can I cancel?", answer: "Yes, any time." }],
199
- },
200
- };
201
- const AUTHORED_PLANS = {
202
- id: "plans",
203
- type: "pricing",
204
- data: {
205
- eyebrow: "Plans",
206
- headline: "Pick a plan",
207
- variant: "three-tiers-with-toggle",
208
- billingToggle: false,
209
- plans: [
210
- {
211
- key: "basic",
212
- name: "Authored Basic",
213
- price: { monthly: "$29" },
214
- features: ["Authored feature"],
215
- cta: { label: "Choose Basic", href: "/checkout/basic" },
216
- },
217
- {
218
- key: "business",
219
- name: "Authored Business",
220
- price: { monthly: "$29.50" },
221
- features: ["Another authored feature"],
222
- cta: { label: "Choose Business", href: "/checkout/business" },
223
- highlighted: true,
224
- },
225
- ],
226
- },
227
- };
228
- const AUTHORED_ADDONS = {
229
- id: "addons",
230
- type: "pricing",
231
- data: {
232
- variant: "addons",
233
- plans: [],
234
- addons: [{ name: "Authored add-on", price: "$29", features: [] }],
235
- },
236
- };
237
-
238
- const authoredPage = PageSectionsSchema.parse([
239
- HERO,
240
- AUTHORED_PLANS,
241
- AUTHORED_ADDONS,
242
- FAQ,
243
- ]);
244
- const pageWithoutPricing = PageSectionsSchema.parse([HERO, FAQ]);
245
-
246
- const getPageSections = jest.fn();
247
-
248
- let clock = Date.now();
249
-
250
- /** A content root whose `_site.mdx` publishes `contactEmail`, or none. */
251
- const contentRoot = mkdtempSync(join(tmpdir(), "ailk-8927-"));
252
- const priorContentRoot = process.env.AILK_CONTENT_ROOT;
253
-
254
- function publishContactEmail(email: string | undefined): void {
255
- writeFileSync(
256
- join(contentRoot, "_site.mdx"),
257
- `---\nsiteName: Example\n${email ? `contactEmail: ${email}\n` : ""}---\n`,
258
- );
259
- }
260
-
261
- beforeAll(() => {
262
- Element.prototype.scrollIntoView = jest.fn();
263
- });
264
-
265
- afterAll(() => {
266
- rmSync(contentRoot, { recursive: true, force: true });
267
- });
268
-
269
- beforeEach(() => {
270
- clock += 16_000;
271
- jest.spyOn(Date, "now").mockImplementation(() => clock);
272
- global.fetch = fetchMock;
273
- fetchMock.mockClear();
274
- answers.length = 0;
275
- answer = shown();
276
- getPageSections.mockResolvedValue(authoredPage);
277
- });
278
-
279
- afterEach(() => {
280
- jest.restoreAllMocks();
281
- });
282
-
283
- async function renderPricing(
284
- search: Record<string, string> = {},
285
- ): Promise<HTMLElement> {
286
- const element = await PricingPage({
287
- params: Promise.resolve({ locale: "en" }),
288
- searchParams: Promise.resolve(search),
289
- getMdxSource,
290
- getPageSections,
291
- });
292
- let container: HTMLElement | undefined;
293
- await act(async () => {
294
- ({ container } = render(element));
295
- });
296
- return container!;
297
- }
298
-
299
- function tierCards(): HTMLElement[] {
300
- return screen.queryAllByTestId("pricing-tier-card");
301
- }
302
-
303
- function cardNamed(name: string): HTMLElement {
304
- const card = tierCards().find((c) => within(c).queryByText(name));
305
- if (!card) throw new Error(`no tier card named ${name}`);
306
- return card;
307
- }
308
-
309
- /** True when `a` comes before `b` in document order. */
310
- function before(a: Element, b: Element): boolean {
311
- return (
312
- (a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING) !== 0
313
- );
314
- }
315
-
316
- /** Every JSON-LD node on the page, `@graph` flattened. */
317
- function jsonLdNodes(container: HTMLElement): Array<Record<string, unknown>> {
318
- const script = container.querySelector('script[type="application/ld+json"]');
319
- if (!script) return [];
320
- const doc = JSON.parse(script.textContent ?? "") as Record<string, unknown>;
321
- const graph = doc["@graph"];
322
- return Array.isArray(graph)
323
- ? (graph as Array<Record<string, unknown>>)
324
- : [doc];
325
- }
326
-
327
- /** Every value of `key` anywhere in `value`. */
328
- function valuesOf(value: unknown, key: string): unknown[] {
329
- if (Array.isArray(value)) return value.flatMap((v) => valuesOf(v, key));
330
- if (value === null || typeof value !== "object") return [];
331
- return Object.entries(value).flatMap(([k, v]) =>
332
- k === key ? [v, ...valuesOf(v, key)] : valuesOf(v, key),
333
- );
334
- }
335
-
336
- // ── AC-1 ─────────────────────────────────────────────────────────────────────
337
-
338
- describe("/pricing on a connected workspace shows its Stripe cards (#8927 AC-1)", () => {
339
- it("renders one card per shown plan, every visible fact, and the add-on tile", async () => {
340
- await renderPricing();
341
-
342
- expect(
343
- tierCards().map(
344
- (c) => within(c).getByRole("heading", { level: 3 }).textContent,
345
- ),
346
- ).toEqual(["Starter", "Growth", "Scale"]);
347
- const starter = cardNamed("Starter");
348
- for (const text of [
349
- STARTER.description,
350
- ...STARTER.features,
351
- STARTER.monthly,
352
- STARTER.unitLabel,
353
- STARTER.note,
354
- STARTER.termsNote,
355
- ]) {
356
- expect(within(starter).getByText(text, { exact: false })).toBeTruthy();
357
- }
358
- expect(
359
- within(cardNamed("Growth")).getByText("$49/mo", { exact: false }),
360
- ).toBeTruthy();
361
- expect(within(cardNamed("Growth")).getByText("Recommended")).toBeTruthy();
362
- expect(
363
- within(cardNamed("Scale")).getByText("$1,500 one-time", { exact: false }),
364
- ).toBeTruthy();
365
-
366
- const tiles = screen.getAllByTestId("addon-card");
367
- expect(tiles).toHaveLength(1);
368
- for (const text of ["SEO audit", "$15/mo", "per audit"]) {
369
- expect(within(tiles[0]!).getByText(text, { exact: false })).toBeTruthy();
370
- }
371
- expect(tierCards().some((c) => within(c).queryByText("SEO audit"))).toBe(
372
- false,
373
- );
374
-
375
- const body = document.body.textContent ?? "";
376
- for (const authored of [
377
- "Authored Basic",
378
- "Authored Business",
379
- "Authored add-on",
380
- "$29",
381
- ]) {
382
- expect(body).not.toContain(authored);
383
- }
384
-
385
- const hero = screen.getByText("Plans that grow with you");
386
- const faq = screen.getByText("Can I cancel?");
387
- expect(before(hero, tierCards()[0]!)).toBe(true);
388
- expect(before(tiles[0]!, faq)).toBe(true);
389
- // The authored plans section's copy stays on the Stripe cards.
390
- expect(screen.getByText("Pick a plan")).toBeTruthy();
391
-
392
- expect(fetchMock).toHaveBeenCalledTimes(1);
393
- expect(String(fetchMock.mock.calls[0]![0])).toMatch(
394
- /\/v1\/content\/shown-offerings$/,
395
- );
396
- });
397
-
398
- it("shows the annual phrase once Annually is pressed", async () => {
399
- await renderPricing();
400
- expect(screen.queryByText(STARTER.annual, { exact: false })).toBeNull();
401
-
402
- await act(async () => {
403
- fireEvent.click(screen.getByTestId("billing-toggle-annual"));
404
- });
405
-
406
- expect(
407
- within(cardNamed("Starter")).getByText(STARTER.annual, { exact: false }),
408
- ).toBeTruthy();
409
- });
410
-
411
- it("places the plans after the hero and the add-ons after the plans on a page with no pricing section", async () => {
412
- getPageSections.mockResolvedValue(pageWithoutPricing);
413
- await renderPricing();
414
-
415
- const hero = screen.getByText("Plans that grow with you");
416
- const cards = tierCards();
417
- const tile = screen.getByTestId("addon-card");
418
- const faq = screen.getByText("Can I cancel?");
419
- expect(cards).toHaveLength(3);
420
- expect(before(hero, cards[0]!)).toBe(true);
421
- expect(before(cards[2]!, tile)).toBe(true);
422
- expect(before(tile, faq)).toBe(true);
423
- // An inserted add-ons section carries its own headline (D4, D6), so the
424
- // lone tile is never an unlabeled band.
425
- const addonsHeadline = screen.getByText("Add-ons");
426
- expect(before(cards[2]!, addonsHeadline)).toBe(true);
427
- expect(before(addonsHeadline, tile)).toBe(true);
428
- });
429
- });
430
-
431
- // ── AC-2 ─────────────────────────────────────────────────────────────────────
432
-
433
- /** The one tier card the page highlights — Stripe's pick or ?plan='s. */
434
- function highlightedCard(): HTMLElement {
435
- const lit = tierCards().filter(
436
- (c) =>
437
- within(c).queryByText("Recommended") ||
438
- within(c).queryByText("Recommended for you"),
439
- );
440
- expect(lit).toHaveLength(1);
441
- return lit[0]!;
442
- }
443
-
444
- describe("/pricing ?plan= and a product switched off (#8927 AC-2)", () => {
445
- it("moves the recommendation to the card whose {plan} matches", async () => {
446
- await renderPricing({ plan: "scale" });
447
-
448
- const card = highlightedCard();
449
- expect(within(card).getByText("Scale")).toBeTruthy();
450
- expect(card.getAttribute("aria-current")).toBe("true");
451
- expect(within(card).getByText("Recommended for you")).toBeTruthy();
452
- // One label, not two: the mapper's "Recommended" pill does not ride along
453
- // with the moved recommendation (D4).
454
- expect(within(card).queryByText("Recommended")).toBeNull();
455
- expect(screen.queryByText("Recommended")).toBeNull();
456
- });
457
-
458
- it.each(["Scale", "scale_monthly", "enterprise", ""])(
459
- "keeps the workspace's own recommendation for ?plan=%j",
460
- async (plan) => {
461
- await renderPricing({ plan });
462
-
463
- expect(within(highlightedCard()).getByText("Growth")).toBeTruthy();
464
- },
465
- );
466
-
467
- it("shares one read for 15 seconds and drops a switched-off product on the next read", async () => {
468
- answers.push(
469
- shown(),
470
- shown(wireSet((list) => list.filter((o) => o.plan !== "scale"))),
471
- );
472
- await renderPricing();
473
- clock += 10_000;
474
- await renderPricing();
475
- expect(fetchMock).toHaveBeenCalledTimes(1);
476
-
477
- document.body.innerHTML = "";
478
- clock += 6_000;
479
- await renderPricing();
480
-
481
- expect(fetchMock).toHaveBeenCalledTimes(2);
482
- expect(tierCards()).toHaveLength(2);
483
- expect(screen.queryByText("Scale")).toBeNull();
484
- });
485
- });
486
-
487
- // ── AC-3 ─────────────────────────────────────────────────────────────────────
488
-
489
- const FAILED_READS: Array<[string, Answer]> = [
490
- ["shown, state expired", shown({ ...wireSet(), state: "expired" })],
491
- ["shown, state empty", shown({ ...wireSet(), state: "empty" })],
492
- [
493
- "shown, no offerings",
494
- shown({ ...wireSet(), offerings: [], productIds: [] }),
495
- ],
496
- [
497
- "status empty",
498
- { status: 200, body: { ok: true, data: { status: "empty" } } },
499
- ],
500
- ["a 500", { status: 500, body: { ok: false, error: "internal_error" } }],
501
- ["a 429", { status: 429, body: { ok: false, error: "rate_limited" } }],
502
- [
503
- "an unknown status",
504
- { status: 200, body: { ok: true, data: { status: "maybe" } } },
505
- ],
506
- ["a non-JSON body", { status: 200, notJson: true }],
507
- ["a rejected fetch", { reject: true }],
508
- ];
509
-
510
- describe("/pricing shows the contact email when there is nothing to sell (#8927 AC-3)", () => {
511
- beforeEach(() => {
512
- process.env.AILK_CONTENT_ROOT = contentRoot;
513
- publishContactEmail(SITE_EMAIL);
514
- });
515
-
516
- afterEach(() => {
517
- if (priorContentRoot === undefined) delete process.env.AILK_CONTENT_ROOT;
518
- else process.env.AILK_CONTENT_ROOT = priorContentRoot;
519
- });
520
-
521
- it.each(FAILED_READS)(
522
- "renders the contact email for %s",
523
- async (_label, failure) => {
524
- answer = failure;
525
- const container = await renderPricing();
526
-
527
- const fallback = screen.getByTestId("contact-fallback");
528
- expect(within(fallback).getByText("Get in touch")).toBeTruthy();
529
- expect(fallback.textContent).toContain(SITE_EMAIL);
530
- expect(screen.queryAllByTestId("pricing-tier-card")).toHaveLength(0);
531
- expect(screen.queryAllByTestId("addon-card")).toHaveLength(0);
532
- expect(document.body.textContent).not.toContain("$29");
533
-
534
- const section = fallback.closest("[data-testid='contact-form']");
535
- expect(section).not.toBeNull();
536
- expect(
537
- before(screen.getByText("Plans that grow with you"), section!),
538
- ).toBe(true);
539
- expect(before(section!, screen.getByText("Can I cancel?"))).toBe(true);
540
-
541
- expect(valuesOf(jsonLdNodes(container), "@type").flat()).not.toContain(
542
- "Offer",
543
- );
544
- },
545
- );
546
-
547
- it("says no contact details are published when the site has no email", async () => {
548
- answer = { status: 200, body: { ok: true, data: { status: "empty" } } };
549
- publishContactEmail(undefined);
550
- await renderPricing();
551
-
552
- expect(screen.getByTestId("contact-fallback-no-email")).toBeTruthy();
553
- });
554
- });
555
-
556
- // ── AC-5 ─────────────────────────────────────────────────────────────────────
557
-
558
- const OFFERINGS_SOURCES = [
559
- "apps/web/app/[locale]/pricing/page.tsx",
560
- "apps/web/lib/offerings-pricing.ts",
561
- // #10044 — the shared Pricing render and the offering pricing page.
562
- "apps/web/lib/pricing-page.ts",
563
- "apps/web/app/[locale]/pricing/[slug]/page.tsx",
564
- ];
565
- const REPO_ROOT = resolve(__dirname, "../../../../../..");
566
-
567
- describe("/pricing keeps Stripe text in its element and out of the metadata (#8927 AC-5)", () => {
568
- it("serializes a hostile product name into JSON-LD without breaking out of it", async () => {
569
- answer = shown(
570
- wireSet((list) =>
571
- list.map((o) => (o.plan === "growth" ? { ...o, name: HOSTILE } : o)),
572
- ),
573
- );
574
- const container = await renderPricing();
575
-
576
- const scripts = container.querySelectorAll("script");
577
- expect(scripts).toHaveLength(1);
578
- expect(scripts[0]!.getAttribute("data-testid")).toBe("json-ld");
579
- expect(scripts[0]!.textContent).not.toContain("</script");
580
- expect(valuesOf(jsonLdNodes(container), "name")).toContain(HOSTILE);
581
- expect(screen.getByText(HOSTILE)).toBeTruthy();
582
- });
583
-
584
- it("keeps every fixture product name out of the page metadata", async () => {
585
- const metadata = await generateMetadata({
586
- params: Promise.resolve({ locale: "en" }),
587
- });
588
- const fields = JSON.stringify([
589
- metadata.title,
590
- metadata.description,
591
- metadata.openGraph,
592
- ]);
593
-
594
- for (const name of [HOSTILE, "Starter", "Growth", "Scale", "SEO audit"]) {
595
- expect(fields).not.toContain(name);
596
- }
597
- });
598
-
599
- it.each(OFFERINGS_SOURCES)("%s never serializes into __html", (path) => {
600
- const source = readFileSync(join(REPO_ROOT, path), "utf8");
601
-
602
- expect(source).not.toContain("__html");
603
- expect(source).not.toContain("JSON.stringify");
604
- });
605
- });