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,41 +0,0 @@
1
- // Working Agreement page (#8661 D10). The /working-agreement route for the registered
2
- // `WorkingAgreementPage` type: reads its MDX frontmatter, renders sections via
3
- // SectionRenderer, and emits a JSON-LD <script>.
4
- import type {
5
- getMdxSource as defaultGetMdxSource,
6
- getPageSections as defaultGetPageSections} from "@working-theory/page-renderer";
7
- import {
8
- renderPage,
9
- renderPageMetadata
10
- } from "@working-theory/page-renderer";
11
- import type { Metadata } from "next";
12
- import type { ReactElement } from "react";
13
-
14
- interface Props {
15
- params: Promise<{ locale: string }>;
16
- getMdxSource?: typeof defaultGetMdxSource;
17
- getPageSections?: typeof defaultGetPageSections;
18
- }
19
-
20
- export async function generateMetadata({
21
- params,
22
- }: Pick<Props, "params">): Promise<Metadata> {
23
- const { locale } = await params;
24
- return renderPageMetadata({ type: "WorkingAgreementPage", slug: "working-agreement", locale });
25
- }
26
-
27
- export default async function Page({
28
- params,
29
- getMdxSource,
30
- getPageSections,
31
- }: Props): Promise<ReactElement> {
32
- const { locale } = await params;
33
- return renderPage({
34
- type: "WorkingAgreementPage",
35
- slug: "working-agreement",
36
- locale,
37
- translationsNamespace: "workingAgreement",
38
- ...(getMdxSource !== undefined && { getMdxSource }),
39
- ...(getPageSections !== undefined && { getPageSections }),
40
- });
41
- }
@@ -1,279 +0,0 @@
1
- /**
2
- * Shared cases for the hub child-card tests (#10121).
3
- *
4
- * Each hub's test lives beside its route
5
- * (`app/[locale]/<hub>/__tests__/hub-children.test.tsx`) so a scaffold that
6
- * drops a gated hub drops its test with it (#10157). This module imports no
7
- * route, so it ships to every scaffold and type-checks without any hub.
8
- *
9
- * `renderPage`/`renderPageMetadata` are mocked at the
10
- * `@working-theory/page-renderer` boundary in each test file, the /templates
11
- * test shape: each assertion inspects the sections a hub hands `renderPage`.
12
- * The JSON-LD is built from those same sections with the real `buildJsonLd`,
13
- * as `renderPage` does, so the cards and the ItemList are compared on one
14
- * input per hub.
15
- */
16
- import { buildJsonLd } from "@working-theory/schema";
17
- import type { ReactElement } from "react";
18
-
19
- export type Section = {
20
- type: string;
21
- id?: string;
22
- data?: Record<string, unknown>;
23
- };
24
- export type Loaders = {
25
- getMdxSource: jest.Mock;
26
- getPageSections: jest.Mock;
27
- getMdxSlugs: jest.Mock;
28
- };
29
- export type HubPage = (
30
- props: {
31
- params: Promise<{ locale: string }>;
32
- } & Loaders,
33
- ) => Promise<ReactElement>;
34
- export type RenderPageMock = jest.Mock<Promise<string>, unknown[]>;
35
-
36
- /** [route, page, list type, child type, body rule] — one row per hub. */
37
- export type HubRow = [
38
- string,
39
- HubPage,
40
- string,
41
- string,
42
- "sections" | "mdx-body" | "composed",
43
- ];
44
-
45
- export const HERO: Section = {
46
- type: "hero",
47
- id: "hero",
48
- data: { headline: "Hub" },
49
- };
50
- export const CLOSING: Section = {
51
- type: "cta",
52
- id: "closing",
53
- data: { headline: "Go" },
54
- };
55
-
56
- /** Loaders for one hub: its seed, its declared sections, and its children. */
57
- export function loaders(
58
- listType: string,
59
- childType: string,
60
- children: Record<string, { title?: string; description?: string } | null>,
61
- declared: Section[],
62
- hubSections = true,
63
- ): Loaders {
64
- return {
65
- getMdxSource: jest.fn(async (type: string, slug: string) => {
66
- if (type === listType) {
67
- return {
68
- frontmatter: {
69
- type,
70
- slug,
71
- title: "Hub",
72
- description: "The hub.",
73
- ...(hubSections && { sections: declared }),
74
- },
75
- body: "",
76
- };
77
- }
78
- if (type !== childType) return null;
79
- const child = children[slug];
80
- return child === null || child === undefined
81
- ? null
82
- : { frontmatter: { type, slug, ...child }, body: "" };
83
- }),
84
- getPageSections: jest.fn(async () => declared),
85
- getMdxSlugs: jest.fn(async (type: string) =>
86
- type === childType ? Object.keys(children) : [],
87
- ),
88
- };
89
- }
90
-
91
- /** Renders a hub and returns the one input it handed `renderPage`. */
92
- export async function renderInput(
93
- mockRenderPage: RenderPageMock,
94
- page: HubPage,
95
- l: Loaders,
96
- ) {
97
- mockRenderPage.mockClear();
98
- await page({ params: Promise.resolve({ locale: "en" }), ...l });
99
- expect(mockRenderPage).toHaveBeenCalledTimes(1);
100
- return mockRenderPage.mock.calls[0]?.[0] as {
101
- type: string;
102
- slug: string;
103
- bodyMode?: string;
104
- trailing?: { props: { sections: Section[] } };
105
- getPageSections: (fm: unknown) => Promise<Section[]>;
106
- };
107
- }
108
-
109
- export const titlesOf = (section: unknown) =>
110
- (section as { data: { items: { title: string }[] } } | null)?.data.items.map(
111
- (i) => i.title,
112
- );
113
-
114
- /** The five cases every hub meets, registered as one `describe` per hub. */
115
- export function describeHub(
116
- [route, page, listType, childType, body]: HubRow,
117
- mockRenderPage: RenderPageMock,
118
- ): void {
119
- describe(`/${route} hub`, () => {
120
- // Out of slug order on purpose, plus one slug that does not load.
121
- const children = {
122
- zeta: { title: "Zeta", description: "Zeta page." },
123
- alpha: { title: "Alpha", description: "Alpha page." },
124
- gone: null,
125
- beta: { title: "Beta" },
126
- };
127
-
128
- it("generates one card per child page, sorted by slug, before the closing CTA", async () => {
129
- const input = await renderInput(
130
- mockRenderPage,
131
- page,
132
- loaders(listType, childType, children, [HERO, CLOSING]),
133
- );
134
- expect(input.type).toBe(listType);
135
- expect(input.slug).toBe(route);
136
-
137
- const sections = await input.getPageSections({});
138
- expect(sections.map((s) => s.type)).toEqual(["hero", "items", "cta"]);
139
- const items = (sections[1]?.data as { items: unknown[] }).items;
140
- expect(items).toEqual([
141
- expect.objectContaining({
142
- title: "Alpha",
143
- description: "Alpha page.",
144
- link: expect.objectContaining({ href: `/${route}/alpha` }),
145
- }),
146
- expect.objectContaining({
147
- title: "Beta",
148
- description: "",
149
- link: expect.objectContaining({ href: `/${route}/beta` }),
150
- }),
151
- expect.objectContaining({
152
- title: "Zeta",
153
- link: expect.objectContaining({ href: `/${route}/zeta` }),
154
- }),
155
- ]);
156
- });
157
-
158
- it("lists the same pages in the CollectionPage ItemList as in the cards", async () => {
159
- const input = await renderInput(
160
- mockRenderPage,
161
- page,
162
- loaders(listType, childType, children, [HERO, CLOSING]),
163
- );
164
- const sections = await input.getPageSections({});
165
- // eslint-disable-next-line no-restricted-syntax -- buildJsonLd returns a loose JSON-LD node; this case reads one nested key of it
166
- const jsonLd = buildJsonLd({
167
- type: listType,
168
- slug: route,
169
- title: "Hub",
170
- description: "The hub.",
171
- locale: "en",
172
- sections,
173
- } as never) as unknown as {
174
- mainEntity: { itemListElement: { name?: string }[] };
175
- };
176
- expect(jsonLd.mainEntity.itemListElement.map((e) => e.name)).toEqual([
177
- "Alpha",
178
- "Beta",
179
- "Zeta",
180
- ]);
181
- });
182
-
183
- it("gives an already-linked child no second card", async () => {
184
- const authored: Section = {
185
- type: "items",
186
- id: "authored",
187
- data: {
188
- items: [
189
- {
190
- title: "Alpha (hand-written)",
191
- link: { label: "Read", href: `/en/${route}/alpha/` },
192
- },
193
- {
194
- title: "Zeta (hand-written)",
195
- link: {
196
- label: "Read",
197
- href: `https://example.com/${route}/zeta?x=1`,
198
- },
199
- },
200
- ],
201
- },
202
- };
203
- const input = await renderInput(
204
- mockRenderPage,
205
- page,
206
- loaders(listType, childType, children, [HERO, authored, CLOSING]),
207
- );
208
- const sections = await input.getPageSections({});
209
- const titles = (s: Section | undefined) =>
210
- (s?.data as { items: { title: string }[] }).items.map((i) => i.title);
211
- if (body === "mdx-body") {
212
- // A prose hub never renders its declared sections, so links there do
213
- // not count: every child gets a visible card after the body.
214
- expect(sections.map((s) => s.type)).toEqual([
215
- "hero",
216
- "items",
217
- "items",
218
- "cta",
219
- ]);
220
- expect(titles(sections[2])).toEqual(["Alpha", "Beta", "Zeta"]);
221
- } else {
222
- // The missing child continues the authored grid: one list, no duplicate.
223
- expect(sections.map((s) => s.id)).toEqual([
224
- "hero",
225
- "authored",
226
- "closing",
227
- ]);
228
- expect(titles(sections[1])).toEqual([
229
- "Alpha (hand-written)",
230
- "Zeta (hand-written)",
231
- "Beta",
232
- ]);
233
- }
234
- });
235
-
236
- it("renders its authored sections unchanged with zero child pages", async () => {
237
- const input = await renderInput(
238
- mockRenderPage,
239
- page,
240
- loaders(listType, childType, {}, [HERO, CLOSING]),
241
- );
242
- expect(await input.getPageSections({})).toEqual([HERO, CLOSING]);
243
- expect(input.trailing).toBeUndefined();
244
- });
245
-
246
- it("keeps the hub's body rule, rendering the cards after a prose body", async () => {
247
- const prose = await renderInput(
248
- mockRenderPage,
249
- page,
250
- loaders(listType, childType, children, [], false),
251
- );
252
- if (body === "sections") {
253
- expect(prose.bodyMode).toBeUndefined();
254
- expect(prose.trailing).toBeUndefined();
255
- } else {
256
- // A prose seed renders its MDX body, with the cards after it.
257
- expect(prose.bodyMode).toBe("mdx-body");
258
- expect(prose.trailing?.props.sections.map((s) => s.type)).toEqual([
259
- "items",
260
- ]);
261
- expect(await prose.getPageSections({})).toEqual(
262
- prose.trailing?.props.sections,
263
- );
264
- }
265
-
266
- const composed = await renderInput(
267
- mockRenderPage,
268
- page,
269
- loaders(listType, childType, children, [HERO, CLOSING]),
270
- );
271
- if (body === "mdx-body") {
272
- expect(composed.bodyMode).toBe("mdx-body");
273
- } else {
274
- expect(composed.bodyMode).toBeUndefined();
275
- expect(composed.trailing).toBeUndefined();
276
- }
277
- });
278
- });
279
- }
@@ -1,57 +0,0 @@
1
- /**
2
- * The route-family helper (#10051 D5, AC-6) — the generic pieces a content
3
- * hub uses: list every detail page of a type, and slot a generated section in
4
- * before the page's closing CTAs.
5
- */
6
- import { insertBeforeClosingCtas, listDetailPages } from "../route-family";
7
-
8
- jest.mock("@working-theory/page-renderer", () => ({
9
- getMdxSlugs: jest.fn(async () => ["c", "a", "gone", "b"]),
10
- getMdxSource: jest.fn(),
11
- }));
12
-
13
- describe("listDetailPages", () => {
14
- it("returns every loaded page sorted by slug, dropping a null load", async () => {
15
- const load = jest.fn(async (_type: string, slug: string) =>
16
- slug === "gone" ? null : { frontmatter: { title: slug.toUpperCase() } },
17
- );
18
- const pages = await listDetailPages("TemplatePage", "en", load as never);
19
- expect(pages).toEqual([
20
- { slug: "a", frontmatter: { title: "A" } },
21
- { slug: "b", frontmatter: { title: "B" } },
22
- { slug: "c", frontmatter: { title: "C" } },
23
- ]);
24
- expect(load).toHaveBeenCalledWith("TemplatePage", "a", "en");
25
- });
26
- });
27
-
28
- describe("insertBeforeClosingCtas", () => {
29
- const section = (type: string, id: string) => ({ type, id }) as never;
30
-
31
- it("places the section before a trailing run of two cta sections", () => {
32
- const result = insertBeforeClosingCtas(
33
- [section("hero", "h"), section("cta", "c1"), section("cta", "c2")],
34
- section("items", "new"),
35
- );
36
- expect(result.map((s: { id: string }) => s.id)).toEqual([
37
- "h",
38
- "new",
39
- "c1",
40
- "c2",
41
- ]);
42
- });
43
-
44
- it("appends when the page does not end in a cta", () => {
45
- const result = insertBeforeClosingCtas(
46
- [section("cta", "c1"), section("hero", "h")],
47
- section("items", "new"),
48
- );
49
- expect(result.map((s: { id: string }) => s.id)).toEqual(["c1", "h", "new"]);
50
- });
51
-
52
- it("appends to an empty page", () => {
53
- expect(insertBeforeClosingCtas([], section("items", "new"))).toHaveLength(
54
- 1,
55
- );
56
- });
57
- });
@@ -1,111 +0,0 @@
1
- /**
2
- * @jest-environment node
3
- */
4
- // #10043 D8, AC-6 — the services listing: a service's public path, a
5
- // category's list of its services and the hub's re-pointed links.
6
- import { PageSectionsSchema } from "@working-theory/validation";
7
-
8
- type Mod = typeof import("../service-listing");
9
-
10
- function load(value: string | undefined): Mod {
11
- const saved = process.env.NEXT_PUBLIC_AILK_SERVICES_PATH;
12
- if (value === undefined) delete process.env.NEXT_PUBLIC_AILK_SERVICES_PATH;
13
- else process.env.NEXT_PUBLIC_AILK_SERVICES_PATH = value;
14
- let mod: Mod | undefined;
15
- try {
16
- jest.isolateModules(() => {
17
- mod = require("../service-listing") as Mod;
18
- });
19
- } finally {
20
- if (saved === undefined) delete process.env.NEXT_PUBLIC_AILK_SERVICES_PATH;
21
- else process.env.NEXT_PUBLIC_AILK_SERVICES_PATH = saved;
22
- }
23
- return mod!;
24
- }
25
-
26
- const labels = {
27
- childrenHeading: "Services in this area",
28
- viewService: "View service",
29
- };
30
-
31
- const pages = [
32
- {
33
- slug: "a",
34
- frontmatter: {
35
- title: "A",
36
- description: "A desc.",
37
- summary: "A sum.",
38
- parent: "ai",
39
- },
40
- },
41
- { slug: "ai", frontmatter: { title: "AI", description: "AI desc." } },
42
- {
43
- slug: "b",
44
- frontmatter: { title: "B", description: "B desc.", parent: "ai" },
45
- },
46
- {
47
- slug: "c",
48
- frontmatter: { title: "C", description: "C desc.", parent: "other" },
49
- },
50
- ];
51
-
52
- describe("service-listing with services.path /capabilities", () => {
53
- const mod = load("/capabilities");
54
-
55
- it("builds the public path under the base and the category", () => {
56
- expect(mod.servicePublicPath("x")).toBe("/capabilities/x");
57
- expect(mod.servicePublicPath("x", "ai")).toBe("/capabilities/ai/x");
58
- });
59
-
60
- it("lists a category's services in slug order, summary else description", () => {
61
- const children = mod.childServices(pages, "ai");
62
- const section = mod.serviceChildrenSection(children, labels);
63
- expect(section.data.headline).toBe("Services in this area");
64
- expect(section.data.items).toEqual([
65
- {
66
- title: "A",
67
- description: "A sum.",
68
- link: { label: "View service", href: "/capabilities/ai/a" },
69
- },
70
- {
71
- title: "B",
72
- description: "B desc.",
73
- link: { label: "View service", href: "/capabilities/ai/b" },
74
- },
75
- ]);
76
- expect(PageSectionsSchema.safeParse([section]).success).toBe(true);
77
- });
78
-
79
- it("re-points a hub section link onto the base and leaves an absolute URL", () => {
80
- const sections = [
81
- {
82
- type: "items",
83
- id: "s",
84
- data: {
85
- items: [
86
- { title: "X", link: { label: "Go", href: "/services/x" } },
87
- {
88
- title: "Y",
89
- link: { label: "Go", href: "https://example.com/services" },
90
- },
91
- ],
92
- },
93
- },
94
- ];
95
- const mapped = mod.withPublicServicesSections(sections);
96
- expect(mapped[0]?.data.items.map((i) => i.link.href)).toEqual([
97
- "/capabilities/x",
98
- "https://example.com/services",
99
- ]);
100
- });
101
- });
102
-
103
- describe("service-listing with no services.path", () => {
104
- const mod = load(undefined);
105
-
106
- it("returns the same sections array", () => {
107
- const sections = [{ type: "items", id: "s", data: { items: [] } }];
108
- expect(mod.withPublicServicesSections(sections)).toBe(sections);
109
- expect(mod.servicePublicPath("x", "ai")).toBe("/services/ai/x");
110
- });
111
- });
@@ -1,158 +0,0 @@
1
- /**
2
- * The template-listing mapping (#10051 D6, AC-6) — a TemplatePage's
3
- * frontmatter to a hub card, an action label and the detail page's
4
- * generated sections. Pure; no I/O.
5
- */
6
- import { PageSectionsSchema } from "@working-theory/validation";
7
-
8
- import {
9
- templateActionLabel,
10
- templateCard,
11
- templateDetailSections,
12
- type TemplateLabels,
13
- } from "../template-listing";
14
-
15
- const labels: TemplateLabels = {
16
- getIt: "Get it",
17
- startFree: "Start free",
18
- viewDemo: "View demo",
19
- viewTemplate: "View template",
20
- included: "What's included",
21
- demoBadge: "Live demo",
22
- moreCategories: (count) => `+${count} more`,
23
- };
24
-
25
- const full = {
26
- slug: "a",
27
- frontmatter: {
28
- title: "Template A",
29
- description: "Description A.",
30
- summary: "Summary A.",
31
- thumbnail: "/img/a.png",
32
- categories: ["accounting", "not-a-category", "legal"],
33
- demoUrl: "https://a.salessmyth.com",
34
- getItUrl: "/contact",
35
- price: 0,
36
- includes: [
37
- { title: "Base site", description: "Pages and structured data." },
38
- ],
39
- },
40
- };
41
-
42
- const bare = {
43
- slug: "b",
44
- frontmatter: {
45
- title: "Template B",
46
- description: "Description B.",
47
- getItUrl: "https://buy.example.com/b",
48
- includes: [
49
- { title: "Base site", description: "Pages and structured data." },
50
- ],
51
- },
52
- };
53
-
54
- describe("templateCard", () => {
55
- it("maps every present field", () => {
56
- expect(templateCard(full, labels)).toEqual({
57
- title: "Template A",
58
- description: "Summary A.",
59
- image: { src: "/img/a.png", alt: "Template A" },
60
- eyebrow: "Accounting · Legal",
61
- badge: "Live demo",
62
- link: { label: "View template", href: "/templates/a" },
63
- });
64
- });
65
-
66
- it("omits image, eyebrow and badge when their fields are absent, and falls back to description", () => {
67
- expect(templateCard(bare, labels)).toEqual({
68
- title: "Template B",
69
- description: "Description B.",
70
- link: { label: "View template", href: "/templates/b" },
71
- });
72
- });
73
-
74
- it("omits the eyebrow when every category slug is unknown", () => {
75
- const card = templateCard(
76
- { slug: "c", frontmatter: { ...bare.frontmatter, categories: ["nope"] } },
77
- labels,
78
- );
79
- expect(card).not.toHaveProperty("eyebrow");
80
- });
81
-
82
- it("shows at most three category names, then +N more", () => {
83
- const card = templateCard(
84
- {
85
- slug: "d",
86
- frontmatter: {
87
- ...bare.frontmatter,
88
- categories: ["accounting", "legal", "consulting", "hvac", "roofing"],
89
- },
90
- },
91
- labels,
92
- );
93
- expect(card.eyebrow).toBe("Accounting · Legal · Consulting · +2 more");
94
- });
95
- });
96
-
97
- describe("templateActionLabel", () => {
98
- it("is Start free only for a price of exactly 0", () => {
99
- expect(templateActionLabel(0, labels)).toBe("Start free");
100
- expect(templateActionLabel(undefined, labels)).toBe("Get it");
101
- expect(templateActionLabel(5, labels)).toBe("Get it");
102
- });
103
- });
104
-
105
- describe("templateDetailSections", () => {
106
- it("builds a hero and a What's included section", () => {
107
- const [hero, included] = templateDetailSections(full.frontmatter, labels);
108
- expect(hero).toMatchObject({
109
- type: "hero",
110
- data: {
111
- headline: "Template A",
112
- subheadline: "Summary A.",
113
- eyebrow: "Accounting · Legal",
114
- image: { src: "/img/a.png", alt: "Template A" },
115
- primaryCta: { label: "Start free", href: "/contact" },
116
- secondaryCta: {
117
- label: "View demo",
118
- href: "https://a.salessmyth.com",
119
- variant: "outline",
120
- },
121
- },
122
- });
123
- expect(included).toEqual({
124
- type: "items",
125
- id: "template-included",
126
- data: {
127
- headline: "What's included",
128
- variant: "minimal",
129
- items: [
130
- { title: "Base site", description: "Pages and structured data." },
131
- ],
132
- },
133
- });
134
- });
135
-
136
- it("omits the demo link, image and eyebrow when absent", () => {
137
- const [hero] = templateDetailSections(bare.frontmatter, labels);
138
- const data = (hero as { data: Record<string, unknown> }).data;
139
- expect(data.primaryCta).toEqual({
140
- label: "Get it",
141
- href: "https://buy.example.com/b",
142
- });
143
- expect(data).not.toHaveProperty("secondaryCta");
144
- expect(data).not.toHaveProperty("image");
145
- expect(data).not.toHaveProperty("eyebrow");
146
- expect(data.subheadline).toBe("Description B.");
147
- });
148
-
149
- it.each([
150
- ["full", full.frontmatter],
151
- ["bare", bare.frontmatter],
152
- ])("the %s result parses PageSectionsSchema", (_label, frontmatter) => {
153
- expect(
154
- PageSectionsSchema.safeParse(templateDetailSections(frontmatter, labels))
155
- .success,
156
- ).toBe(true);
157
- });
158
- });