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,219 +0,0 @@
1
- /**
2
- * /pricing reads `?plan=<key>` into the Pricing section (#8842).
3
- *
4
- * A diagnostic that recommends a plan links to `/pricing?plan=<key>`. The
5
- * page hands that key to every `pricing` section as its `recommended` value;
6
- * the section moves the authored "Recommended" treatment onto the plan whose
7
- * `key` matches (case-insensitive) and scrolls that card into view on load.
8
- * No key, or a key no plan carries, leaves the authored recommendation and
9
- * scrolls nothing.
10
- *
11
- * MDX is DI-injected (no fs reads); the real SectionRenderer and Pricing
12
- * section render, so the assertions read the served DOM.
13
- */
14
- import { act, render, screen, within } from "@testing-library/react";
15
-
16
- import PricingPage from "../page";
17
-
18
- // #10704 — a fixture suite: its content is shaped for the mdx source, whatever the site serves from.
19
- process.env.CONTENT_ADAPTER = "mdx";
20
-
21
- const PLANS = [
22
- {
23
- key: "basic",
24
- name: "Basic",
25
- price: { monthly: "$29" },
26
- features: ["One site"],
27
- cta: { label: "Choose Basic", href: "/checkout/basic", variant: "outline" },
28
- },
29
- {
30
- key: "business",
31
- name: "Business",
32
- price: { monthly: "$79" },
33
- features: ["Three sites"],
34
- cta: {
35
- label: "Choose Business",
36
- href: "/checkout/business",
37
- variant: "default",
38
- },
39
- highlighted: true,
40
- badge: "Recommended",
41
- },
42
- {
43
- key: "agency",
44
- name: "Agency",
45
- price: { monthly: "$199" },
46
- features: ["Unlimited sites"],
47
- cta: {
48
- label: "Choose Agency",
49
- href: "/checkout/agency",
50
- variant: "outline",
51
- },
52
- },
53
- ] as const;
54
-
55
- const getMdxSource = jest.fn().mockResolvedValue({
56
- frontmatter: {
57
- type: "Pricing",
58
- slug: "pricing",
59
- title: "Pricing",
60
- description: "Plans for every stage.",
61
- },
62
- body: "",
63
- });
64
-
65
- const getPageSections = jest.fn().mockResolvedValue([
66
- {
67
- id: "plans",
68
- type: "pricing",
69
- data: {
70
- variant: "three-tiers-with-toggle",
71
- billingToggle: false,
72
- plans: PLANS,
73
- },
74
- },
75
- ]);
76
-
77
- const scrollIntoView = jest.fn();
78
- let reducedMotion = false;
79
-
80
- beforeAll(() => {
81
- Element.prototype.scrollIntoView = scrollIntoView;
82
- });
83
-
84
- beforeEach(() => {
85
- scrollIntoView.mockClear();
86
- reducedMotion = false;
87
- // Answer the reduced-motion query from `reducedMotion`.
88
- jest.spyOn(window, "matchMedia").mockImplementation(
89
- (query: string): MediaQueryList => ({
90
- matches: query === "(prefers-reduced-motion: reduce)" && reducedMotion,
91
- media: query,
92
- onchange: null,
93
- addEventListener: jest.fn(),
94
- removeEventListener: jest.fn(),
95
- addListener: jest.fn(),
96
- removeListener: jest.fn(),
97
- dispatchEvent: jest.fn(),
98
- }),
99
- );
100
- });
101
-
102
- // #8927 — the page reads the Offerings shown set first; these cases are an
103
- // unconnected site's, so the read answers `unconnected` and the page is today's.
104
- beforeEach(() => {
105
- global.fetch = jest.fn(async () => ({
106
- ok: true,
107
- status: 200,
108
- json: async () => ({ ok: true, data: { status: "unconnected" } }),
109
- })) as jest.Mock;
110
- });
111
-
112
- afterEach(() => {
113
- jest.restoreAllMocks();
114
- });
115
-
116
- async function renderPricing(search: Record<string, string | string[]>) {
117
- const element = await PricingPage({
118
- params: Promise.resolve({ locale: "en" }),
119
- searchParams: Promise.resolve(search),
120
- getMdxSource,
121
- getPageSections,
122
- });
123
- await act(async () => {
124
- render(element);
125
- });
126
- }
127
-
128
- /** The tier card carrying the "Recommended" badge — the only highlighted card. */
129
- function recommendedCard(): HTMLElement {
130
- const badge = screen.getByTestId("tier-badge");
131
- const card = badge.closest<HTMLElement>("[data-testid='pricing-tier-card']");
132
- if (!card) throw new Error("badge is not inside a tier card");
133
- return card;
134
- }
135
-
136
- describe("/pricing ?plan=<key> (#8842)", () => {
137
- it("moves the Recommended badge and the filled button to the named plan", async () => {
138
- await renderPricing({ plan: "agency" });
139
-
140
- expect(screen.getAllByTestId("tier-badge")).toHaveLength(1);
141
- const card = recommendedCard();
142
- expect(within(card).getByText("Agency")).toBeTruthy();
143
- expect(card.getAttribute("aria-current")).toBe("true");
144
- // The badge says why this card is emphasised — a recommendation, never the
145
- // authored text, which may be a popularity claim about a different plan.
146
- expect(screen.getByTestId("tier-badge").textContent).toBe("Recommended for you");
147
-
148
- // The authored recommendation gives up its emphasis and its filled CTA.
149
- const cards = screen.getAllByTestId("pricing-tier-card");
150
- expect(cards.filter((c) => c.getAttribute("aria-current") === "true")).toEqual([card]);
151
- const business = cards.find((c) => within(c).queryByText("Business"));
152
- expect(
153
- within(business!).getByRole("link", { name: "Choose Business" }).className,
154
- ).toBe(within(cards[0]!).getByRole("link", { name: "Choose Basic" }).className);
155
- expect(within(card).getByRole("link", { name: "Choose Agency" }).className).not.toBe(
156
- within(business!).getByRole("link", { name: "Choose Business" }).className,
157
- );
158
- });
159
-
160
- it("matches the plan key case-insensitively", async () => {
161
- await renderPricing({ plan: "BASIC" });
162
-
163
- expect(within(recommendedCard()).getByText("Basic")).toBeTruthy();
164
- });
165
-
166
- it("scrolls the recommended card into view, centred and smooth", async () => {
167
- await renderPricing({ plan: "agency" });
168
-
169
- expect(scrollIntoView).toHaveBeenCalledTimes(1);
170
- expect(scrollIntoView.mock.contexts[0]).toBe(recommendedCard());
171
- expect(scrollIntoView).toHaveBeenCalledWith({
172
- block: "center",
173
- behavior: "smooth",
174
- });
175
- });
176
-
177
- it("jumps without animation when the visitor prefers reduced motion", async () => {
178
- reducedMotion = true;
179
- await renderPricing({ plan: "agency" });
180
-
181
- expect(scrollIntoView).toHaveBeenCalledWith({
182
- block: "center",
183
- behavior: "auto",
184
- });
185
- });
186
-
187
- it.each([
188
- ["no plan parameter", {}],
189
- ["an unknown key", { plan: "enterprise" }],
190
- ["an empty key", { plan: "" }],
191
- ])("keeps the authored recommendation and does not scroll for %s", async (_label, search) => {
192
- await renderPricing(search);
193
-
194
- expect(screen.getAllByTestId("tier-badge")).toHaveLength(1);
195
- expect(within(recommendedCard()).getByText("Business")).toBeTruthy();
196
- expect(scrollIntoView).not.toHaveBeenCalled();
197
- });
198
-
199
- it("keeps the authored recommendation when the key names a plan the variant does not show", async () => {
200
- // two-tiers-with-extra-tier renders the first two plans only.
201
- getPageSections.mockResolvedValueOnce([
202
- {
203
- id: "plans",
204
- type: "pricing",
205
- data: { variant: "two-tiers-with-extra-tier", plans: PLANS },
206
- },
207
- ]);
208
- await renderPricing({ plan: "agency" });
209
-
210
- expect(within(recommendedCard()).getByText("Business")).toBeTruthy();
211
- expect(scrollIntoView).not.toHaveBeenCalled();
212
- });
213
-
214
- it("reads the first value when the parameter repeats", async () => {
215
- await renderPricing({ plan: ["agency", "basic"] });
216
-
217
- expect(within(recommendedCard()).getByText("Agency")).toBeTruthy();
218
- });
219
- });
@@ -1,215 +0,0 @@
1
- /**
2
- * /pricing lists every offering pricing page (#10044 D6, AC-4).
3
- *
4
- * The hub's source and sections are DI-injected and `listPages` answers the
5
- * offering pages, so the real renderPage, SectionRenderer and Items section
6
- * run and the assertions read the served DOM. A hub with nothing to list is
7
- * compared with `renderPage` called directly, the `unconnected.test.tsx`
8
- * equality-oracle shape.
9
- *
10
- * `global.fetch` answers the shown-offerings route; each case moves
11
- * `Date.now` past the page's 15-second shared read.
12
- */
13
- import { act, render, screen, within } from "@testing-library/react";
14
- import { renderPage } from "@working-theory/page-renderer";
15
- import type { ReactElement } from "react";
16
-
17
- import type { DetailPage } from "../../../../lib/route-family";
18
- import PricingPage from "../page";
19
-
20
- const HUB_FRONTMATTER = {
21
- type: "Pricing",
22
- slug: "pricing",
23
- title: "Pricing",
24
- description: "Plans for every stage.",
25
- };
26
-
27
- const SECTIONS = [
28
- {
29
- id: "hero",
30
- type: "hero",
31
- data: { headline: "Find your plan", variant: "default" },
32
- },
33
- {
34
- id: "plans",
35
- type: "pricing",
36
- data: {
37
- variant: "three-tiers-with-toggle",
38
- billingToggle: false,
39
- plans: [
40
- {
41
- key: "basic",
42
- name: "Written Basic",
43
- price: { monthly: "$29" },
44
- features: ["One site"],
45
- cta: { label: "Choose Basic", href: "/checkout/basic" },
46
- },
47
- ],
48
- },
49
- },
50
- {
51
- id: "closing",
52
- type: "cta",
53
- data: {
54
- headline: "Still deciding?",
55
- primaryCta: { label: "Talk to us", href: "/contact" },
56
- },
57
- },
58
- ];
59
-
60
- function source(frontmatter: Record<string, unknown>) {
61
- return jest.fn().mockResolvedValue({ frontmatter, body: "" });
62
- }
63
-
64
- const getPageSections = jest.fn().mockResolvedValue(SECTIONS);
65
-
66
- function pages(...list: DetailPage[]): jest.Mock {
67
- return jest.fn().mockResolvedValue(list);
68
- }
69
-
70
- const A: DetailPage = {
71
- slug: "a",
72
- frontmatter: {
73
- type: "Pricing",
74
- slug: "a",
75
- title: "Offering A",
76
- description: "Description A.",
77
- summary: "Summary A.",
78
- },
79
- };
80
- const B: DetailPage = {
81
- slug: "b",
82
- frontmatter: {
83
- type: "Pricing",
84
- slug: "b",
85
- title: "Offering B",
86
- description: "Description B.",
87
- },
88
- };
89
- const HUB: DetailPage = { slug: "pricing", frontmatter: HUB_FRONTMATTER };
90
-
91
- let shownAnswer: unknown = { status: "unconnected" };
92
-
93
- const fetchMock: jest.Mock = jest.fn(async () => ({
94
- ok: true,
95
- status: 200,
96
- json: async () => ({ ok: true, data: shownAnswer }),
97
- }));
98
-
99
- let clock = Date.now();
100
-
101
- beforeAll(() => {
102
- Element.prototype.scrollIntoView = jest.fn();
103
- });
104
-
105
- beforeEach(() => {
106
- clock += 16_000;
107
- jest.spyOn(Date, "now").mockImplementation(() => clock);
108
- global.fetch = fetchMock;
109
- fetchMock.mockClear();
110
- shownAnswer = { status: "unconnected" };
111
- });
112
-
113
- afterEach(() => {
114
- jest.restoreAllMocks();
115
- });
116
-
117
- /** `useId` values renumbered by first appearance, as `unconnected.test.tsx` does. */
118
- function stableIds(markup: string): string {
119
- const seen = new Map<string, string>();
120
- return markup.replace(/_r_[0-9a-z]+_/g, (id) => {
121
- if (!seen.has(id)) seen.set(id, `_r_id${seen.size}_`);
122
- return seen.get(id)!;
123
- });
124
- }
125
-
126
- async function html(element: ReactElement): Promise<string> {
127
- let container: HTMLElement | undefined;
128
- await act(async () => {
129
- ({ container } = render(element));
130
- });
131
- return stableIds(container!.innerHTML);
132
- }
133
-
134
- async function hub(
135
- listPages: jest.Mock,
136
- frontmatter: Record<string, unknown> = HUB_FRONTMATTER,
137
- ): Promise<ReactElement> {
138
- return PricingPage({
139
- params: Promise.resolve({ locale: "en" }),
140
- searchParams: Promise.resolve({}),
141
- getMdxSource: source(frontmatter),
142
- getPageSections,
143
- listPages,
144
- });
145
- }
146
-
147
- /** True when `a` comes before `b` in document order. */
148
- function before(a: Element, b: Element): boolean {
149
- return (
150
- (a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING) !== 0
151
- );
152
- }
153
-
154
- describe("/pricing lists the offering pricing pages (#10044 AC-4)", () => {
155
- it("renders one card per offering page in slug order, before the closing CTA", async () => {
156
- await html(await hub(pages(A, B, HUB)));
157
-
158
- const heading = screen.getByText("Pricing by offering");
159
- const list = heading.closest("section") ?? document.body;
160
- const links = within(list)
161
- .getAllByRole("link")
162
- .map((link) => link.getAttribute("href"));
163
- expect(links.filter((href) => href?.includes("/pricing/"))).toEqual([
164
- expect.stringMatching(/\/pricing\/a$/),
165
- expect.stringMatching(/\/pricing\/b$/),
166
- ]);
167
- expect(within(list).getByText("Offering A")).not.toBeNull();
168
- expect(within(list).getByText("Summary A.")).not.toBeNull();
169
- expect(within(list).queryByText("Description A.")).toBeNull();
170
- expect(within(list).getByText("Description B.")).not.toBeNull();
171
- expect(within(list).queryByText("Pricing", { exact: true })).toBeNull();
172
- expect(before(heading, screen.getByText("Still deciding?"))).toBe(true);
173
- expect(before(screen.getByText("Written Basic"), heading)).toBe(true);
174
- });
175
-
176
- it.each([
177
- ["only the hub's own page", [HUB]],
178
- [
179
- "the hub plus a file whose frontmatter slug is `pricing`",
180
- [HUB, { slug: "x", frontmatter: { ...HUB_FRONTMATTER } }],
181
- ],
182
- ])("renders today's page with %s", async (_label, list) => {
183
- const served = await html(await hub(pages(...list)));
184
- const oracle = await html(
185
- await renderPage({
186
- type: "Pricing",
187
- slug: "pricing",
188
- locale: "en",
189
- translationsNamespace: "pricing",
190
- getMdxSource: source(HUB_FRONTMATTER),
191
- getPageSections,
192
- }),
193
- );
194
-
195
- expect(served).toBe(oracle);
196
- expect(served).not.toContain("Pricing by offering");
197
- });
198
-
199
- it("with the hub's `plans: []` and a shown set, renders its written sections and no Stripe card or contact section", async () => {
200
- shownAnswer = { status: "shown", shownSet: { state: "current" } };
201
- await html(await hub(pages(A), { ...HUB_FRONTMATTER, plans: [] }));
202
-
203
- expect(fetchMock).not.toHaveBeenCalled();
204
- expect(screen.getByText("Written Basic")).not.toBeNull();
205
- expect(screen.queryByTestId("contact-fallback")).toBeNull();
206
- expect(
207
- screen
208
- .queryAllByRole("link")
209
- .some((link) =>
210
- link.getAttribute("href")?.includes("/api/offerings/checkout/"),
211
- ),
212
- ).toBe(false);
213
- expect(screen.getByText("Pricing by offering")).not.toBeNull();
214
- });
215
- });