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,151 +0,0 @@
1
- /**
2
- * HTML snapshot regression tests for resources/page.tsx and resources/[slug]/page.tsx
3
- * → @working-theory/page-renderer migration.
4
- *
5
- * Two-commit strategy:
6
- * Commit 1: this file added; snapshots captured against pre-migration routes (RED-passing).
7
- * Commit 2: routes migrated; same snapshots verify diff=0 (GREEN).
8
- *
9
- * Four states tested:
10
- * - resources hub empty: getMdxSource returns null → empty-state branch
11
- * - resources hub populated: getMdxSource returns a minimal MdxPageSource → full render
12
- * - resource detail populated: getMdxSource returns populated source → full render
13
- * - resource detail notFound: getMdxSource returns null → notFound() called
14
- *
15
- * Failure = snapshot diff > 0 bytes. DO NOT regenerate snapshots to pass.
16
- */
17
- import React from "react";
18
- import { render } from "@testing-library/react";
19
-
20
- // ── @working-theory/ui mock ─────────────────────────────────────────────────────────────
21
- jest.mock("@working-theory/ui", () => ({
22
- // #7745: renderPage's mdx-body branch frames its head and body in the
23
- // section Container and renders the body through MDXContent + the shared map.
24
- Container: ({
25
- children,
26
- }: {
27
- children?: React.ReactNode;
28
- }): React.ReactElement => React.createElement("div", null, children),
29
- MDXContent: ({
30
- children,
31
- }: {
32
- children?: React.ReactNode;
33
- }): React.ReactElement => React.createElement(React.Fragment, null, children),
34
- getMDXComponents: (overrides?: Record<string, unknown>) => ({ ...overrides }),
35
- // #4446/#4447: renderPage's own fallback/empty-state title now composes
36
- // Heading (mobile type-budget classes, #4417) instead of a bare <h1>.
37
- Heading: ({
38
- children,
39
- level,
40
- }: {
41
- children: React.ReactNode;
42
- level: number;
43
- }): React.ReactElement => React.createElement(`h${level}`, null, children),
44
- SectionRenderer: ({ sections }: { sections: unknown[] }) =>
45
- React.createElement("div", {
46
- "data-testid": "section-renderer",
47
- "data-section-count": String(sections.length),
48
- }),
49
- }));
50
-
51
- // ── next/navigation mock ──────────────────────────────────────────────────────
52
- const mockNotFound = jest.fn(() => {
53
- throw new Error("NEXT_NOT_FOUND");
54
- });
55
- jest.mock("next/navigation", () => ({
56
- notFound: () => mockNotFound(),
57
- }));
58
-
59
- import ResourcesPage from "../page";
60
- import ResourceDetailPage from "../[slug]/page";
61
- import * as pageRenderer from "@working-theory/page-renderer";
62
-
63
- const getMdxSourceEmpty = jest.fn().mockResolvedValue(null);
64
-
65
- // ── Resources Hub ─────────────────────────────────────────────────────────────
66
-
67
- describe("ResourcesPage — snapshot regression", () => {
68
- it("empty state renders deterministic HTML", async () => {
69
- const element = await ResourcesPage({
70
- params: Promise.resolve({ locale: "en" }),
71
- // No child pages: this snapshot pins the hub's own render (#10121).
72
- getMdxSlugs: async () => [],
73
- getMdxSource: getMdxSourceEmpty,
74
- });
75
- const { container } = render(element);
76
- expect(container.innerHTML).toMatchInlineSnapshot(
77
- `"<main id="main"><h1>Resources</h1><p data-testid="section-empty-state">Resources listing coming soon.</p></main>"`,
78
- );
79
- });
80
-
81
- it("populated state renders deterministic HTML", async () => {
82
- const source = {
83
- frontmatter: {
84
- type: "ResourcesHub" as const,
85
- slug: "resources",
86
- title: "Resources",
87
- description: "Guides, templates, and tools.",
88
- },
89
- body: "",
90
- };
91
- const getMdxSourcePopulated = jest.fn().mockResolvedValue(source);
92
-
93
- const element = await ResourcesPage({
94
- params: Promise.resolve({ locale: "en" }),
95
- // No child pages: this snapshot pins the hub's own render (#10121).
96
- getMdxSlugs: async () => [],
97
- getMdxSource: getMdxSourcePopulated,
98
- });
99
- const { container } = render(element);
100
- expect(container.innerHTML).toMatchInlineSnapshot(
101
- `"<script type="application/ld+json" data-testid="json-ld">{"@context":"https://schema.org","@type":"CollectionPage","inLanguage":"en","name":"Resources","description":"Guides, templates, and tools.","mainEntity":{"@type":"ItemList"}}</script><main id="main"><div><div data-testid="markdown-view-toggle" class="ailk-markdown-view-toggle"><div class="flex justify-end mb-3"><div role="radiogroup" aria-label="Page view" data-testid="markdown-view-toggle" class="inline-flex items-center gap-0.5 rounded-lg p-1 bg-(--color-surface-secondary)"><button class="inline-flex items-center justify-center gap-2 font-medium motion-safe:transition motion-safe:duration-(--button-hover-duration) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--color-accent) focus-visible:ring-offset-1 disabled:cursor-not-allowed disabled:opacity-50 [&amp;>svg]:shrink-0 text-(--color-fg) not-disabled:hover:bg-(--button-hover-quiet-bg) not-disabled:hover:text-(--button-hover-quiet-fg) not-disabled:hover:opacity-(--button-hover-opacity) not-disabled:hover:transform-(--button-hover-transform) not-disabled:hover:shadow-(--button-hover-shadow) not-disabled:active:bg-gray-200 not-disabled:active:text-(--color-fg) rounded-control px-control-x h-(--control-height-thin) text-caption leading-none rounded-md px-3 text-body-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--color-accent) focus-visible:ring-offset-1 min-w-(--control-height-thin) min-h-(--control-height-big) bg-(--color-bg) text-(--color-fg) shadow-sm" type="button" role="radio" aria-checked="true" aria-label="Rendered" tabindex="0" data-testid="markdown-view-toggle-rendered">Rendered</button><button class="inline-flex items-center justify-center gap-2 font-medium motion-safe:transition motion-safe:duration-(--button-hover-duration) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--color-accent) focus-visible:ring-offset-1 disabled:cursor-not-allowed disabled:opacity-50 [&amp;>svg]:shrink-0 text-(--color-fg) not-disabled:hover:bg-(--button-hover-quiet-bg) not-disabled:hover:text-(--button-hover-quiet-fg) not-disabled:hover:opacity-(--button-hover-opacity) not-disabled:hover:transform-(--button-hover-transform) not-disabled:hover:shadow-(--button-hover-shadow) not-disabled:active:bg-gray-200 not-disabled:active:text-(--color-fg) rounded-control px-control-x h-(--control-height-thin) text-caption leading-none rounded-md px-3 text-body-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--color-accent) focus-visible:ring-offset-1 min-w-(--control-height-thin) min-h-(--control-height-big) text-(--color-text-muted) hover:text-(--color-fg)" type="button" role="radio" aria-checked="false" aria-label="Markdown" tabindex="-1" data-testid="markdown-view-toggle-markdown">Markdown</button></div></div><div role="status" aria-live="polite" aria-atomic="true" class="sr-only" data-testid="markdown-view-toggle-status">Showing Rendered view</div><div data-testid="markdown-view-rendered"><article data-testid="mdx-body"><div data-testid="mdx-remote" data-source=""></div></article></div></div></div></main>"`,
102
- );
103
- });
104
- });
105
-
106
- // ── Resource Detail ───────────────────────────────────────────────────────────
107
-
108
- describe("ResourceDetailPage — snapshot regression", () => {
109
- beforeEach(() => {
110
- mockNotFound.mockClear();
111
- });
112
-
113
- it("populated state renders deterministic HTML", async () => {
114
- const source = {
115
- frontmatter: {
116
- type: "ResourceDetail" as const,
117
- slug: "getting-started",
118
- title: "Getting Started",
119
- description: "A guide for new users.",
120
- },
121
- body: "",
122
- };
123
- const getMdxSourcePopulated = jest.fn().mockResolvedValue(source);
124
-
125
- const element = await ResourceDetailPage({
126
- params: Promise.resolve({ locale: "en", slug: "getting-started" }),
127
- getMdxSource: getMdxSourcePopulated,
128
- });
129
- const { container } = render(element);
130
- expect(container.innerHTML).toMatchInlineSnapshot(
131
- `"<script type="application/ld+json" data-testid="json-ld">{"@context":"https://schema.org","@graph":[{"@context":"https://schema.org","@type":"WebPage","inLanguage":"en","name":"Getting Started","description":"A guide for new users.","mainEntity":{"@context":"https://schema.org","@type":"Article","headline":"Getting Started","description":"A guide for new users."}},{"@context":"https://schema.org","@type":"BreadcrumbList","inLanguage":"en","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http://localhost:3000/en/"},{"@type":"ListItem","position":2,"name":"Resources","item":"http://localhost:3000/en/resources"},{"@type":"ListItem","position":3,"name":"Getting Started","item":"http://localhost:3000/en/resources/getting-started"}]}]}</script><main id="main"><div><div data-testid="markdown-view-toggle" class="ailk-markdown-view-toggle"><div class="flex justify-end mb-3"><div role="radiogroup" aria-label="Page view" data-testid="markdown-view-toggle" class="inline-flex items-center gap-0.5 rounded-lg p-1 bg-(--color-surface-secondary)"><button class="inline-flex items-center justify-center gap-2 font-medium motion-safe:transition motion-safe:duration-(--button-hover-duration) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--color-accent) focus-visible:ring-offset-1 disabled:cursor-not-allowed disabled:opacity-50 [&amp;>svg]:shrink-0 text-(--color-fg) not-disabled:hover:bg-(--button-hover-quiet-bg) not-disabled:hover:text-(--button-hover-quiet-fg) not-disabled:hover:opacity-(--button-hover-opacity) not-disabled:hover:transform-(--button-hover-transform) not-disabled:hover:shadow-(--button-hover-shadow) not-disabled:active:bg-gray-200 not-disabled:active:text-(--color-fg) rounded-control px-control-x h-(--control-height-thin) text-caption leading-none rounded-md px-3 text-body-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--color-accent) focus-visible:ring-offset-1 min-w-(--control-height-thin) min-h-(--control-height-big) bg-(--color-bg) text-(--color-fg) shadow-sm" type="button" role="radio" aria-checked="true" aria-label="Rendered" tabindex="0" data-testid="markdown-view-toggle-rendered">Rendered</button><button class="inline-flex items-center justify-center gap-2 font-medium motion-safe:transition motion-safe:duration-(--button-hover-duration) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--color-accent) focus-visible:ring-offset-1 disabled:cursor-not-allowed disabled:opacity-50 [&amp;>svg]:shrink-0 text-(--color-fg) not-disabled:hover:bg-(--button-hover-quiet-bg) not-disabled:hover:text-(--button-hover-quiet-fg) not-disabled:hover:opacity-(--button-hover-opacity) not-disabled:hover:transform-(--button-hover-transform) not-disabled:hover:shadow-(--button-hover-shadow) not-disabled:active:bg-gray-200 not-disabled:active:text-(--color-fg) rounded-control px-control-x h-(--control-height-thin) text-caption leading-none rounded-md px-3 text-body-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--color-accent) focus-visible:ring-offset-1 min-w-(--control-height-thin) min-h-(--control-height-big) text-(--color-text-muted) hover:text-(--color-fg)" type="button" role="radio" aria-checked="false" aria-label="Markdown" tabindex="-1" data-testid="markdown-view-toggle-markdown">Markdown</button></div></div><div role="status" aria-live="polite" aria-atomic="true" class="sr-only" data-testid="markdown-view-toggle-status">Showing Rendered view</div><div data-testid="markdown-view-rendered"><article data-testid="mdx-body"><div data-testid="mdx-remote" data-source=""></div></article></div></div></div></main>"`,
132
- );
133
- });
134
-
135
- it("notFound state calls notFound() when source is null", async () => {
136
- const renderPageSpy = jest.spyOn(pageRenderer, "renderPage");
137
- await expect(
138
- ResourceDetailPage({
139
- params: Promise.resolve({ locale: "en", slug: "missing" }),
140
- getMdxSource: getMdxSourceEmpty,
141
- }),
142
- ).rejects.toThrow("NEXT_NOT_FOUND");
143
- // The 404 is renderPage's detail branch, not a route pre-check (#7537).
144
- expect(renderPageSpy).toHaveBeenCalledTimes(1);
145
- expect(
146
- renderPageSpy.mock.calls[0]![0].translationsNamespace,
147
- ).toBeUndefined();
148
- renderPageSpy.mockRestore();
149
- expect(mockNotFound).toHaveBeenCalledTimes(1);
150
- });
151
- });
@@ -1,49 +0,0 @@
1
- // Resources hub page. Reads ResourcesHub MDX via the content adapter and emits
2
- // a JSON-LD CollectionPage via the dispatcher.
3
- // It lists every ResourceDetail page through one generated card section (#10121,
4
- // apps/web/lib/hub-children.tsx — the /alternatives and /templates shape).
5
- import type {
6
- getMdxSlugs as defaultGetMdxSlugs,
7
- getMdxSource as defaultGetMdxSource,
8
- getPageSections as defaultGetPageSections,
9
- } from "@working-theory/page-renderer";
10
- import { renderPage, renderPageMetadata } from "@working-theory/page-renderer";
11
- import type { Metadata } from "next";
12
- import type { ReactElement } from "react";
13
-
14
- import { type HubConfig, hubPageInput } from "../../../lib/hub-children";
15
-
16
- interface Props {
17
- params: Promise<{ locale: string }>;
18
- getMdxSource?: typeof defaultGetMdxSource;
19
- getPageSections?: typeof defaultGetPageSections;
20
- getMdxSlugs?: typeof defaultGetMdxSlugs;
21
- }
22
-
23
- const HUB: HubConfig = {
24
- listType: "ResourcesHub",
25
- slug: "resources",
26
- childType: "ResourceDetail",
27
- linkLabel: "Read the resource",
28
- sectionId: "resource-cards",
29
- body: "mdx-body",
30
- };
31
-
32
- export async function generateMetadata({
33
- params,
34
- }: Pick<Props, "params">): Promise<Metadata> {
35
- const { locale } = await params;
36
- return renderPageMetadata({ type: "ResourcesHub", slug: "resources", locale });
37
- }
38
-
39
- export default async function Page({
40
- params,
41
- ...loaders
42
- }: Props): Promise<ReactElement> {
43
- const { locale } = await params;
44
- return renderPage({
45
- type: "ResourcesHub",
46
- slug: "resources",
47
- ...(await hubPageInput(HUB, locale, loaders)),
48
- });
49
- }
@@ -1,68 +0,0 @@
1
- // A service under its category (#10043 D2/D7): `/services/<category>/<slug>`,
2
- // served at `<services base>/<category>/<slug>`. Gated with the `services`
3
- // surface. The service's `parent` must name this category, and the category
4
- // must be a Service with no parent of its own; anything else is a 404, so a
5
- // service is served at exactly one URL.
6
- import type { getMdxSource as defaultGetMdxSource } from "@working-theory/page-renderer";
7
- import {
8
- getMdxSource as loadMdxSource,
9
- renderPage,
10
- renderPageMetadata,
11
- } from "@working-theory/page-renderer";
12
- import type { Metadata } from "next";
13
- import { notFound } from "next/navigation";
14
- import type { ReactElement } from "react";
15
-
16
- interface Props {
17
- params: Promise<{ locale: string; slug: string; child: string }>;
18
- getMdxSource?: typeof defaultGetMdxSource;
19
- }
20
-
21
- export async function generateMetadata({
22
- params,
23
- }: Pick<Props, "params">): Promise<Metadata> {
24
- const { locale, child } = await params;
25
- return renderPageMetadata({ type: "Service", slug: child, locale });
26
- }
27
-
28
- export default async function Page({
29
- params,
30
- getMdxSource,
31
- }: Props): Promise<ReactElement> {
32
- const { locale, slug, child } = await params;
33
- const load = getMdxSource ?? loadMdxSource;
34
- const source = await load("Service", child, locale);
35
- // A page that composes `sections[]` renders them (JSON-LD is built from
36
- // the same sections); a prose page renders its MDX body — the rule
37
- // /vs/[slug] applies (#10122).
38
- const composed =
39
- source !== null &&
40
- Array.isArray((source.frontmatter as { sections?: unknown[] }).sections) &&
41
- ((source.frontmatter as { sections?: unknown[] }).sections?.length ?? 0) >
42
- 0;
43
- const render = () =>
44
- renderPage({
45
- type: "Service",
46
- slug: child,
47
- locale,
48
- ...(composed
49
- ? {}
50
- : {
51
- bodyMode: "mdx-body" as const,
52
- populatedDescriptionTestId: "service-description",
53
- }),
54
- ...(getMdxSource !== undefined && { getMdxSource }),
55
- });
56
- // A missing page is renderPage's to answer (#7537).
57
- if (source === null) return render();
58
-
59
- if (source.frontmatter.parent !== slug) notFound();
60
- const category = await load("Service", slug, locale);
61
- if (
62
- category === null ||
63
- category.frontmatter.parent !== undefined
64
- ) {
65
- notFound();
66
- }
67
- return render();
68
- }
@@ -1,88 +0,0 @@
1
- // Service detail page. Reads the Service MDX for the given slug, renders via
2
- // @working-theory/page-renderer, and emits a JSON-LD <script>. Unknown slugs 404 through renderPage.
3
- //
4
- // #10043 D7 — a service with a `parent` lives under its category, so its flat
5
- // URL answers a permanent redirect there; a service that is a category lists
6
- // its services after its body.
7
- import type { getMdxSource as defaultGetMdxSource } from "@working-theory/page-renderer";
8
- import {
9
- getMdxSource as loadMdxSource,
10
- renderPage,
11
- renderPageMetadata,
12
- } from "@working-theory/page-renderer";
13
- import { SectionRenderer } from "@working-theory/ui";
14
- import type { Metadata } from "next";
15
- import { permanentRedirect } from "next/navigation";
16
- import { getTranslations } from "next-intl/server";
17
- import type { ReactElement } from "react";
18
-
19
- import { listDetailPages } from "../../../../lib/route-family";
20
- import {
21
- childServices,
22
- serviceChildrenSection,
23
- servicePublicPath,
24
- } from "../../../../lib/service-listing";
25
-
26
- interface Props {
27
- params: Promise<{ locale: string; slug: string }>;
28
- getMdxSource?: typeof defaultGetMdxSource;
29
- }
30
-
31
- export async function generateMetadata({
32
- params,
33
- }: Pick<Props, "params">): Promise<Metadata> {
34
- const { locale, slug } = await params;
35
- return renderPageMetadata({ type: "Service", slug, locale });
36
- }
37
-
38
- export default async function Page({
39
- params,
40
- getMdxSource,
41
- }: Props): Promise<ReactElement> {
42
- const { locale, slug } = await params;
43
- const load = getMdxSource ?? loadMdxSource;
44
- const source = await load("Service", slug, locale);
45
- // A page that composes `sections[]` renders them (JSON-LD is built from
46
- // the same sections); a prose page renders its MDX body — the rule
47
- // /vs/[slug] applies (#10122).
48
- const composed =
49
- source !== null &&
50
- Array.isArray((source.frontmatter as { sections?: unknown[] }).sections) &&
51
- ((source.frontmatter as { sections?: unknown[] }).sections?.length ?? 0) >
52
- 0;
53
- // `trailing` is set only on a category (below), so every other render's
54
- // input is the one this route has always passed.
55
- const render = (trailing?: ReactElement) =>
56
- renderPage({
57
- type: "Service",
58
- slug,
59
- locale,
60
- ...(composed
61
- ? {}
62
- : {
63
- bodyMode: "mdx-body" as const,
64
- populatedDescriptionTestId: "service-description",
65
- }),
66
- ...(getMdxSource !== undefined && { getMdxSource }),
67
- ...(trailing !== undefined && { trailing }),
68
- });
69
- // A missing page is renderPage's to answer (#7537).
70
- if (source === null) return render();
71
-
72
- const parent = source.frontmatter.parent;
73
- if (parent !== undefined) {
74
- const defaultLocale = process.env.NEXT_PUBLIC_DEFAULT_LOCALE ?? "en";
75
- const prefix = locale === defaultLocale ? "" : `/${locale}`;
76
- permanentRedirect(`${prefix}${servicePublicPath(slug, parent)}`);
77
- }
78
-
79
- const children = childServices(await listDetailPages("Service", locale, load), slug);
80
- if (children.length === 0) return render();
81
-
82
- const t = await getTranslations({ namespace: "services", locale });
83
- const list = serviceChildrenSection(children, {
84
- childrenHeading: t("childrenHeading"),
85
- viewService: t("viewService"),
86
- });
87
- return render(<SectionRenderer sections={[list]} locale={locale} />);
88
- }
@@ -1,158 +0,0 @@
1
- /**
2
- * Hub child cards (#10121) for /services. The shared cases live in
3
- * `lib/__tests__/hub-children.fixtures.ts`; this file sits beside the route so
4
- * a scaffold without /services 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
- // The services hub reads its card labels from the `services` namespace.
24
- const SERVICE_MESSAGES: Record<string, string> = {
25
- childrenHeading: "Services in this area",
26
- viewService: "View service",
27
- };
28
- jest.mock("next-intl/server", () => ({
29
- __esModule: true,
30
- getTranslations: () =>
31
- Promise.resolve((key: string) => SERVICE_MESSAGES[key] ?? key),
32
- }));
33
-
34
- import ServicesPage from "../page";
35
- import {
36
- CLOSING,
37
- describeHub,
38
- HERO,
39
- type HubPage,
40
- loaders,
41
- renderInput,
42
- type Section,
43
- } from "../../../../lib/__tests__/hub-children.fixtures";
44
-
45
- describeHub(
46
- ["services", ServicesPage as HubPage, "ServicesList", "Service", "composed"],
47
- mockRenderPage,
48
- );
49
-
50
- describe("/services hub — the #10043 model", () => {
51
- const services = {
52
- consulting: {
53
- title: "Consulting",
54
- summary: "Short.",
55
- description: "Long.",
56
- },
57
- audit: { title: "Audit", parent: "consulting", description: "Child." },
58
- training: { title: "Training", description: "Flat." },
59
- // A blank parent reads as no category, as the category listing reads it.
60
- workshop: { title: "Workshop", parent: "", description: "Blank parent." },
61
- };
62
- const serviceLoaders = (declared: Section[] = [HERO, CLOSING]) => {
63
- const l = loaders("ServicesList", "Service", {}, declared);
64
- l.getMdxSlugs.mockResolvedValue(Object.keys(services));
65
- l.getMdxSource.mockImplementation(async (type: string, slug: string) =>
66
- type === "ServicesList"
67
- ? {
68
- frontmatter: { type, slug, title: "Hub", sections: declared },
69
- body: "",
70
- }
71
- : {
72
- frontmatter: {
73
- type,
74
- slug,
75
- ...services[slug as keyof typeof services],
76
- },
77
- body: "",
78
- },
79
- );
80
- return l;
81
- };
82
-
83
- it("lists categories and uncategorized services, never a service with a parent", async () => {
84
- const input = await renderInput(
85
- mockRenderPage,
86
- ServicesPage as HubPage,
87
- serviceLoaders(),
88
- );
89
- const sections = await input.getPageSections({});
90
- expect(sections.map((s) => s.type)).toEqual(["hero", "items", "cta"]);
91
- expect((sections[1]?.data as { items: unknown[] }).items).toEqual([
92
- // The category page's card shape: `summary` over `description`.
93
- {
94
- title: "Consulting",
95
- description: "Short.",
96
- link: { label: "View service", href: "/services/consulting" },
97
- },
98
- {
99
- title: "Training",
100
- description: "Flat.",
101
- link: { label: "View service", href: "/services/training" },
102
- },
103
- {
104
- title: "Workshop",
105
- description: "Blank parent.",
106
- link: { label: "View service", href: "/services/workshop" },
107
- },
108
- ]);
109
- });
110
-
111
- it("links the cards at the site's services base and re-points the hub's own links", async () => {
112
- const previous = process.env.NEXT_PUBLIC_AILK_SERVICES_PATH;
113
- process.env.NEXT_PUBLIC_AILK_SERVICES_PATH = "/capabilities";
114
- try {
115
- let MovedPage: HubPage | undefined;
116
- jest.isolateModules(() => {
117
- MovedPage = (require("../page") as { default: HubPage }).default;
118
- });
119
- const authored: Section = {
120
- type: "items",
121
- id: "authored",
122
- data: {
123
- items: [
124
- {
125
- title: "Consulting (hand-written)",
126
- link: { label: "Go", href: "/services/consulting" },
127
- },
128
- ],
129
- },
130
- };
131
- const input = await renderInput(
132
- mockRenderPage,
133
- MovedPage as HubPage,
134
- serviceLoaders([HERO, authored, CLOSING]),
135
- );
136
- const sections = await input.getPageSections({});
137
- // Consulting keeps its hand-written card; Training continues the grid.
138
- expect(sections.map((s) => s.id)).toEqual([
139
- "hero",
140
- "authored",
141
- "closing",
142
- ]);
143
- expect(
144
- (
145
- sections[1]?.data as { items: { link: { href: string } }[] }
146
- ).items.map((item) => item.link.href),
147
- ).toEqual([
148
- "/capabilities/consulting",
149
- "/capabilities/training",
150
- "/capabilities/workshop",
151
- ]);
152
- } finally {
153
- if (previous === undefined)
154
- delete process.env.NEXT_PUBLIC_AILK_SERVICES_PATH;
155
- else process.env.NEXT_PUBLIC_AILK_SERVICES_PATH = previous;
156
- }
157
- });
158
- });