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,282 +0,0 @@
1
- /**
2
- * An unconnected site's /pricing is today's page, byte for byte (#8927 AC-4,
3
- * spec docs/specs/8927-pricing-renders-the-shown-set-spec.md D2 step 1, D7).
4
- *
5
- * Two oracles. The committed snapshot was recorded against `page.tsx` as it
6
- * stood before #8927, in an earlier commit than the page change, and is never
7
- * regenerated. The equality oracle renders `renderPage` called directly with
8
- * today's `?plan=` wrapper (copied below), so it holds whatever the commit
9
- * order. Both read today's DI fixture; the equality oracle also reads the
10
- * site's own `content/en/Pricing/pricing.mdx` through the default loader. The
11
- * snapshot of the monorepo's own pricing.mdx is `monorepo-only.test.tsx`'s,
12
- * which no scaffold ships (#9179).
13
- *
14
- * `global.fetch` answers the shown-offerings route's `unconnected`; with
15
- * `NODE_ENV` `production` and no API origin, the page makes no call at all.
16
- */
17
- import { act, render } from "@testing-library/react";
18
- import {
19
- getPageSections as loadPageSections,
20
- renderPage,
21
- renderPageMetadata,
22
- } from "@working-theory/page-renderer";
23
- import type { PageSection } from "@working-theory/validation";
24
- import type { ReactElement } from "react";
25
-
26
- import { TOPOLOGY } from "../../../../lib/topology.generated";
27
- import * as pricingPage from "../page";
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 PLANS = [
34
- {
35
- key: "basic",
36
- name: "Basic",
37
- price: { monthly: "$29" },
38
- features: ["One site"],
39
- cta: { label: "Choose Basic", href: "/checkout/basic", variant: "outline" },
40
- },
41
- {
42
- key: "business",
43
- name: "Business",
44
- price: { monthly: "$79" },
45
- features: ["Three sites"],
46
- cta: {
47
- label: "Choose Business",
48
- href: "/checkout/business",
49
- variant: "default",
50
- },
51
- highlighted: true,
52
- badge: "Recommended",
53
- },
54
- {
55
- key: "agency",
56
- name: "Agency",
57
- price: { monthly: "$199" },
58
- features: ["Unlimited sites"],
59
- cta: {
60
- label: "Choose Agency",
61
- href: "/checkout/agency",
62
- variant: "outline",
63
- },
64
- },
65
- ] as const;
66
-
67
- const getMdxSource = jest.fn().mockResolvedValue({
68
- frontmatter: {
69
- type: "Pricing",
70
- slug: "pricing",
71
- title: "Pricing",
72
- description: "Plans for every stage.",
73
- },
74
- body: "",
75
- });
76
-
77
- const getPageSections = jest.fn().mockResolvedValue([
78
- {
79
- id: "plans",
80
- type: "pricing",
81
- data: {
82
- variant: "three-tiers-with-toggle",
83
- billingToggle: false,
84
- plans: PLANS,
85
- },
86
- },
87
- ]);
88
-
89
- /** Today's `withRecommendedPlan` (#8842), copied as the oracle's wrapper. */
90
- function todaysSections(
91
- load: (frontmatter: unknown) => Promise<PageSection[]>,
92
- plan: string | undefined,
93
- ): (frontmatter: unknown) => Promise<PageSection[]> {
94
- if (!plan) return load;
95
- return async (frontmatter) =>
96
- (await load(frontmatter)).map((section) =>
97
- section.type === "pricing"
98
- ? {
99
- ...section,
100
- data: { ...section.data, recommended: plan } as typeof section.data,
101
- }
102
- : section,
103
- );
104
- }
105
-
106
- const API_ENV = [
107
- "AILK_API_URL",
108
- "NEXT_PUBLIC_AILK_API_URL",
109
- "NEXT_PUBLIC_API_URL",
110
- ] as const;
111
- const priorEnv = new Map<string, string | undefined>(
112
- [...API_ENV, "NODE_ENV"].map((name) => [name, process.env[name]]),
113
- );
114
-
115
- const fetchMock: jest.Mock = jest.fn(async () => ({
116
- ok: true,
117
- status: 200,
118
- json: async () => ({ ok: true, data: { status: "unconnected" } }),
119
- }));
120
-
121
- let clock = Date.now();
122
-
123
- beforeAll(() => {
124
- Element.prototype.scrollIntoView = jest.fn();
125
- });
126
-
127
- beforeEach(() => {
128
- // Each case reads afresh: the page shares one read for 15 seconds.
129
- clock += 16_000;
130
- jest.spyOn(Date, "now").mockImplementation(() => clock);
131
- global.fetch = fetchMock;
132
- fetchMock.mockClear();
133
- });
134
-
135
- afterEach(() => {
136
- jest.restoreAllMocks();
137
- for (const [name, value] of priorEnv) {
138
- if (value === undefined)
139
- delete (process.env as Record<string, string | undefined>)[name];
140
- else (process.env as Record<string, string | undefined>)[name] = value;
141
- }
142
- });
143
-
144
- /**
145
- * `useId` values renumbered by first appearance. A client render draws them
146
- * from one counter shared by every root in the process, so the same tree
147
- * rendered second gets different numbers; the served (server) HTML does not.
148
- */
149
- function stableIds(markup: string): string {
150
- const seen = new Map<string, string>();
151
- return markup.replace(/_r_[0-9a-z]+_/g, (id) => {
152
- if (!seen.has(id)) seen.set(id, `_r_id${seen.size}_`);
153
- return seen.get(id)!;
154
- });
155
- }
156
-
157
- async function html(element: ReactElement): Promise<string> {
158
- let container: HTMLElement | undefined;
159
- await act(async () => {
160
- ({ container } = render(element));
161
- });
162
- return stableIds(container!.innerHTML);
163
- }
164
-
165
- async function pageHtml(
166
- search: Record<string, string>,
167
- di: boolean,
168
- ): Promise<string> {
169
- return html(
170
- await PricingPage({
171
- params: Promise.resolve({ locale: "en" }),
172
- searchParams: Promise.resolve(search),
173
- ...(di ? { getMdxSource, getPageSections } : {}),
174
- }),
175
- );
176
- }
177
-
178
- async function oracleHtml(
179
- plan: string | undefined,
180
- di: boolean,
181
- ): Promise<string> {
182
- return html(
183
- await renderPage({
184
- type: "Pricing",
185
- slug: "pricing",
186
- locale: "en",
187
- translationsNamespace: "pricing",
188
- ...(di ? { getMdxSource } : {}),
189
- getPageSections: todaysSections(
190
- di ? getPageSections : loadPageSections,
191
- plan,
192
- ),
193
- }),
194
- );
195
- }
196
-
197
- describe("/pricing on an unconnected site is today's page (#8927 AC-4)", () => {
198
- it.each([
199
- ["no plan", {}],
200
- ["?plan=agency", { plan: "agency" }],
201
- ["?plan=BASIC", { plan: "BASIC" }],
202
- ] as const)("renders today's DI page for %s", async (_label, search) => {
203
- const served = await pageHtml(search, true);
204
- const plan = "plan" in search ? search.plan : undefined;
205
-
206
- expect(served).toBe(await oracleHtml(plan, true));
207
- expect(served).toMatchSnapshot();
208
- });
209
-
210
- it("renders the site's own pricing.mdx unchanged", async () => {
211
- const served = await pageHtml({}, false);
212
-
213
- expect(served).toBe(await oracleHtml(undefined, false));
214
- });
215
-
216
- it("makes no call and renders today's page in production with no API origin", async () => {
217
- for (const name of API_ENV) delete process.env[name];
218
- (process.env as Record<string, string>).NODE_ENV = "production";
219
-
220
- const served = await pageHtml({}, true);
221
-
222
- expect(fetchMock).not.toHaveBeenCalled();
223
- expect(served).toBe(await oracleHtml(undefined, true));
224
- });
225
-
226
- // #9480 — the browser-facing origin is read through the topology seam
227
- // (#7874 D12). The committed seam is the hub render, so this case runs it
228
- // unmocked. #8060 — hub-only: a spoke render of the seam reads no
229
- // NEXT_PUBLIC_AILK_API_URL, so a spoke scaffold skips this case.
230
- (TOPOLOGY === "hub" ? it : it.skip)(
231
- "on a hub, reads the shown set in production configured only by the browser-facing origin",
232
- async () => {
233
- for (const name of API_ENV) delete process.env[name];
234
- process.env.NEXT_PUBLIC_AILK_API_URL = "https://api.example.test";
235
- (process.env as Record<string, string>).NODE_ENV = "production";
236
-
237
- const served = await pageHtml({}, true);
238
-
239
- expect(fetchMock).toHaveBeenCalledTimes(1);
240
- expect(String(fetchMock.mock.calls[0][0])).toMatch(
241
- /^https:\/\/api\.example\.test\/v1\/content\/shown-offerings/,
242
- );
243
- expect(served).toBe(await oracleHtml(undefined, true));
244
- },
245
- );
246
-
247
- it("on a spoke (the seam's spoke render), that origin is not read in production", async () => {
248
- for (const name of API_ENV) delete process.env[name];
249
- process.env.NEXT_PUBLIC_AILK_API_URL = "https://api.example.test";
250
- (process.env as Record<string, string>).NODE_ENV = "production";
251
-
252
- await jest.isolateModulesAsync(async () => {
253
- jest.doMock("../../../../lib/api-origin.generated", () => ({
254
- browserApiOrigin: (): string | undefined => undefined,
255
- }));
256
- const spoke = await import("../page");
257
- await spoke.default({
258
- params: Promise.resolve({ locale: "en" }),
259
- searchParams: Promise.resolve({}),
260
- getMdxSource,
261
- getPageSections,
262
- });
263
- });
264
-
265
- expect(fetchMock).not.toHaveBeenCalled();
266
- });
267
-
268
- it("keeps the MDX page's metadata and renders per request", async () => {
269
- const params = Promise.resolve({ locale: "en" });
270
-
271
- expect(await generateMetadata({ params })).toEqual(
272
- await renderPageMetadata({
273
- type: "Pricing",
274
- slug: "pricing",
275
- locale: "en",
276
- }),
277
- );
278
- expect((pricingPage as { dynamic?: unknown }).dynamic).toBe(
279
- "force-dynamic",
280
- );
281
- });
282
- });
@@ -1,120 +0,0 @@
1
- // Pricing page. Reads the Pricing MDX frontmatter, renders sections via
2
- // SectionRenderer, and emits a JSON-LD <script>.
3
- //
4
- // `?plan=<key>` (#8842) — a diagnostic's recommended plan. The key is handed
5
- // to every `pricing` section as `recommended`; the section moves its authored
6
- // recommendation onto the matching plan and scrolls it into view. Reading the
7
- // query renders this page per request: the recommendation is in the served
8
- // HTML, so the card never flashes from the authored plan to the named one.
9
- //
10
- // The Offerings shown set (#8927, spec
11
- // docs/specs/8927-pricing-renders-the-shown-set-spec.md). The page reads
12
- // `GET /v1/content/shown-offerings` through the api-client, shared per server
13
- // instance, and renders one of three pages — unconnected, a current shown
14
- // set, or the contact email — through `pricingSections` in
15
- // `lib/pricing-page.ts`, shared with every offering pricing page (#10044 D5).
16
- // The page's own `plans` frontmatter narrows its Stripe cards; `plans: []`
17
- // keeps its written sections and reads no Stripe data.
18
- //
19
- // The offering pricing pages (#10044 D6): every other `Pricing` file
20
- // (`content/<locale>/Pricing/<offering>.mdx`, served at /pricing/<offering>)
21
- // is listed after this page's own sections, before its closing CTA, as one
22
- // generated `items` section — no hand-maintained list. A site with no
23
- // offering page renders exactly as before.
24
- //
25
- // Stripe text reaches markup only as React text and JSON-LD only through
26
- // renderPage's serializer (T4); the metadata stays the MDX page's (T8).
27
- import {
28
- getMdxSource as loadMdxSource,
29
- getPageSections as defaultGetPageSections,
30
- renderPage,
31
- renderPageMetadata,
32
- } from "@working-theory/page-renderer";
33
- import type { getMdxSource as defaultGetMdxSource } from "@working-theory/page-renderer";
34
- import type { Metadata } from "next";
35
- import { getTranslations } from "next-intl/server";
36
- import type { ReactElement } from "react";
37
-
38
- import {
39
- offeringPricingPages,
40
- pagePlans,
41
- pricingPageCard,
42
- pricingSections,
43
- pricingSectionSlots,
44
- } from "../../../lib/pricing-page";
45
- import {
46
- insertBeforeClosingCtas,
47
- listDetailPages,
48
- } from "../../../lib/route-family";
49
-
50
- // #8927 D2 — never prerendered; the Offerings read behind it is shared for READ_TTL_MS.
51
- export const dynamic = "force-dynamic";
52
-
53
- interface Props {
54
- params: Promise<{ locale: string }>;
55
- searchParams?: Promise<Record<string, string | string[] | undefined>>;
56
- getMdxSource?: typeof defaultGetMdxSource;
57
- getPageSections?: typeof defaultGetPageSections;
58
- /** The offering pages' reader (#10044 D6); a test's DI seam. */
59
- listPages?: typeof listDetailPages;
60
- }
61
-
62
- type Section = Awaited<ReturnType<typeof defaultGetPageSections>>[number];
63
-
64
- export async function generateMetadata({
65
- params,
66
- }: Pick<Props, "params">): Promise<Metadata> {
67
- const { locale } = await params;
68
- return renderPageMetadata({ type: "Pricing", slug: "pricing", locale });
69
- }
70
-
71
- export default async function Page({
72
- params,
73
- searchParams,
74
- getMdxSource,
75
- getPageSections = defaultGetPageSections,
76
- listPages = listDetailPages,
77
- }: Props): Promise<ReactElement> {
78
- const { locale } = await params;
79
- const search = (await searchParams) ?? {};
80
- const plan = Array.isArray(search.plan) ? search.plan[0] : search.plan;
81
-
82
- /**
83
- * The page's sections in its Offerings state, then the offering pricing
84
- * pages list. Runs only when the hub's source exists.
85
- */
86
- async function withPricing(frontmatter: unknown): Promise<Section[]> {
87
- const sections = await pricingSections(await getPageSections(frontmatter), {
88
- plans: pagePlans(frontmatter),
89
- plan,
90
- locale,
91
- });
92
- const pages = offeringPricingPages(
93
- await listPages("Pricing", locale, getMdxSource ?? loadMdxSource),
94
- );
95
- if (pages.length === 0) return sections;
96
- const t = await getTranslations({ locale, namespace: "pricingPages" });
97
- const labels = { viewPricing: t("viewPricing") };
98
- return insertBeforeClosingCtas(sections, {
99
- type: "items",
100
- id: "pricing-pages",
101
- data: {
102
- headline: t("heading"),
103
- // A tile is one click target per card (the /templates hub's rule).
104
- variant: "tile",
105
- tileHover: "outline",
106
- items: pages.map((page) => pricingPageCard(page, labels)),
107
- },
108
- });
109
- }
110
-
111
- return renderPage({
112
- type: "Pricing",
113
- slug: "pricing",
114
- locale,
115
- translationsNamespace: "pricing",
116
- ...(getMdxSource !== undefined && { getMdxSource }),
117
- getPageSections: withPricing,
118
- sectionSlots: await pricingSectionSlots(locale),
119
- });
120
- }
@@ -1,40 +0,0 @@
1
- // Privacy page. Reads the PrivacyPage MDX frontmatter, renders sections via
2
- // SectionRenderer, and emits a JSON-LD <script>.
3
- import type {
4
- getMdxSource as defaultGetMdxSource,
5
- getPageSections as defaultGetPageSections} from "@working-theory/page-renderer";
6
- import {
7
- renderPage,
8
- renderPageMetadata
9
- } from "@working-theory/page-renderer";
10
- import type { Metadata } from "next";
11
- import type { ReactElement } from "react";
12
-
13
- interface Props {
14
- params: Promise<{ locale: string }>;
15
- getMdxSource?: typeof defaultGetMdxSource;
16
- getPageSections?: typeof defaultGetPageSections;
17
- }
18
-
19
- export async function generateMetadata({
20
- params,
21
- }: Pick<Props, "params">): Promise<Metadata> {
22
- const { locale } = await params;
23
- return renderPageMetadata({ type: "PrivacyPage", slug: "privacy", locale });
24
- }
25
-
26
- export default async function Page({
27
- params,
28
- getMdxSource,
29
- getPageSections,
30
- }: Props): Promise<ReactElement> {
31
- const { locale } = await params;
32
- return renderPage({
33
- type: "PrivacyPage",
34
- slug: "privacy",
35
- locale,
36
- translationsNamespace: "privacy",
37
- ...(getMdxSource !== undefined && { getMdxSource }),
38
- ...(getPageSections !== undefined && { getPageSections }),
39
- });
40
- }
@@ -1,50 +0,0 @@
1
- // Product detail page. Reads the Product MDX for the given slug, renders via
2
- // @working-theory/page-renderer, and emits a JSON-LD <script>. Unknown slugs 404 through renderPage.
3
- import type { getMdxSource as defaultGetMdxSource } from "@working-theory/page-renderer";
4
- import {
5
- getMdxSource as loadMdxSource,
6
- renderPage,
7
- renderPageMetadata,
8
- } from "@working-theory/page-renderer";
9
- import type { Metadata } from "next";
10
- import type { ReactElement } from "react";
11
-
12
- interface Props {
13
- params: Promise<{ locale: string; slug: string }>;
14
- getMdxSource?: typeof defaultGetMdxSource;
15
- }
16
-
17
- export async function generateMetadata({
18
- params,
19
- }: Pick<Props, "params">): Promise<Metadata> {
20
- const { locale, slug } = await params;
21
- return renderPageMetadata({ type: "Product", slug, locale });
22
- }
23
-
24
- export default async function Page({
25
- params,
26
- getMdxSource,
27
- }: Props): Promise<ReactElement> {
28
- const { locale, slug } = await params;
29
- // A page that composes `sections[]` renders them (JSON-LD is built from
30
- // the same sections); a prose page renders its MDX body — the rule
31
- // /vs/[slug] applies (#10122).
32
- const source = await (getMdxSource ?? loadMdxSource)("Product", slug, locale);
33
- const composed =
34
- source !== null &&
35
- Array.isArray((source.frontmatter as { sections?: unknown[] }).sections) &&
36
- ((source.frontmatter as { sections?: unknown[] }).sections?.length ?? 0) >
37
- 0;
38
- return renderPage({
39
- type: "Product",
40
- slug,
41
- locale,
42
- ...(composed
43
- ? {}
44
- : {
45
- bodyMode: "mdx-body" as const,
46
- populatedDescriptionTestId: "product-description",
47
- }),
48
- ...(getMdxSource !== undefined && { getMdxSource }),
49
- });
50
- }
@@ -1,32 +0,0 @@
1
- /**
2
- * Hub child cards (#10121) for /products. The shared cases live in
3
- * `lib/__tests__/hub-children.fixtures.ts`; this file sits beside the route so
4
- * a scaffold without /products drops it with the route (#10157).
5
- */
6
- const mockRenderPage = jest.fn(async (..._args: unknown[]) => "<rendered/>");
7
-
8
- jest.mock("@working-theory/page-renderer", () => ({
9
- __esModule: true,
10
- renderPage: (...args: unknown[]) => mockRenderPage(...args),
11
- renderPageMetadata: jest.fn(),
12
- // Never reached — every call in this suite passes its loaders via DI.
13
- getMdxSlugs: jest.fn(),
14
- getMdxSource: jest.fn(),
15
- getPageSections: jest.fn(),
16
- }));
17
-
18
- jest.mock("@working-theory/ui/sections", () => ({
19
- __esModule: true,
20
- SectionRenderer: () => null,
21
- }));
22
-
23
- import ProductsPage from "../page";
24
- import {
25
- describeHub,
26
- type HubPage,
27
- } from "../../../../lib/__tests__/hub-children.fixtures";
28
-
29
- describeHub(
30
- ["products", ProductsPage as HubPage, "ProductsList", "Product", "mdx-body"],
31
- mockRenderPage,
32
- );