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.
- package/dist/add-route.js +15 -0
- package/dist/body-heading.d.ts +2 -1
- package/dist/body-heading.js +31 -3
- package/dist/module-architecture.js +0 -3
- package/dist/remove-module.js +13 -4
- package/dist/routes.d.ts +7 -0
- package/dist/routes.js +1 -1
- package/dist/site-roster.js +7 -1
- package/dist/surfaces.d.ts +2 -0
- package/dist/surfaces.js +59 -172
- package/package.json +3 -3
- package/templates/apps/web/CLAUDE.md +7 -1
- package/templates/apps/web/__tests__/__mocks__/next-intl-server.ts +3 -2
- package/templates/apps/web/__tests__/__mocks__/next-intl.ts +3 -2
- package/templates/apps/web/app/[locale]/layout.tsx +1 -1
- package/templates/apps/web/i18n/request.ts +5 -1
- package/templates/apps/web/jest.config.cjs +6 -0
- package/templates/apps/web/lib/__tests__/deck-page.test.ts +9 -0
- package/templates/apps/web/lib/__tests__/in-page-magnet-self-request.test.ts +1 -1
- package/templates/apps/web/lib/__tests__/in-page-magnet.test.ts +2 -2
- package/templates/apps/web/lib/__tests__/pricing-page.test.ts +1 -1
- package/templates/apps/web/lib/__tests__/structured-data.test.tsx +17 -4
- package/templates/apps/web/lib/in-page-magnet.ts +2 -2
- package/templates/apps/web/lib/pricing-page.ts +3 -3
- package/templates/apps/web/{app/[locale]/contact → lib}/site-contact-email.ts +1 -1
- package/templates/apps/web/{app/[locale]/contact → lib}/site-contact-lines.ts +1 -1
- package/templates/apps/web/lib/site-header.ts +1 -1
- package/templates/apps/web/messages/en.json +0 -119
- package/templates/apps/web/next.config.mjs +7 -0
- package/templates/apps/web/package.json +1 -0
- package/templates/apps/web/site-pages.config.tsx +85 -0
- package/templates/tools/body-heading.ts +30 -3
- package/versions.json +50 -49
- package/templates/apps/web/app/[locale]/(authed)/leads/__tests__/page.test.tsx +0 -205
- package/templates/apps/web/app/[locale]/(authed)/leads/components/LeadsTable.tsx +0 -137
- package/templates/apps/web/app/[locale]/(authed)/leads/page.tsx +0 -122
- package/templates/apps/web/app/[locale]/(authed)/waitlist/components/ForbiddenState.tsx +0 -24
- package/templates/apps/web/app/[locale]/(authed)/waitlist/format.ts +0 -111
- package/templates/apps/web/app/[locale]/[slug]/[detail]/__tests__/page.test.tsx +0 -402
- package/templates/apps/web/app/[locale]/[slug]/[detail]/page.tsx +0 -143
- package/templates/apps/web/app/[locale]/[slug]/__tests__/page.test.tsx +0 -148
- package/templates/apps/web/app/[locale]/[slug]/page.tsx +0 -109
- package/templates/apps/web/app/[locale]/about/[slug]/page.tsx +0 -46
- package/templates/apps/web/app/[locale]/about/__tests__/about-routes.test.tsx +0 -353
- package/templates/apps/web/app/[locale]/about/page.tsx +0 -122
- package/templates/apps/web/app/[locale]/alternatives/__tests__/page.test.tsx +0 -161
- package/templates/apps/web/app/[locale]/alternatives/page.tsx +0 -112
- package/templates/apps/web/app/[locale]/careers/[slug]/[action]/page.tsx +0 -244
- package/templates/apps/web/app/[locale]/careers/[slug]/apply.actions.ts +0 -325
- package/templates/apps/web/app/[locale]/careers/[slug]/job-application-form.ts +0 -120
- package/templates/apps/web/app/[locale]/careers/[slug]/page.tsx +0 -73
- package/templates/apps/web/app/[locale]/careers/__tests__/apply.actions.test.ts +0 -497
- package/templates/apps/web/app/[locale]/careers/__tests__/careers-hub.test.tsx +0 -172
- package/templates/apps/web/app/[locale]/careers/__tests__/careers-set.test.tsx +0 -153
- package/templates/apps/web/app/[locale]/careers/__tests__/job-application-form.test.ts +0 -141
- package/templates/apps/web/app/[locale]/careers/__tests__/job-apply-page.test.tsx +0 -546
- package/templates/apps/web/app/[locale]/careers/__tests__/page-renderer-migration.test.tsx +0 -189
- package/templates/apps/web/app/[locale]/careers/page.tsx +0 -165
- package/templates/apps/web/app/[locale]/case-studies/[slug]/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/case-studies/__tests__/hub-children.test.tsx +0 -65
- package/templates/apps/web/app/[locale]/case-studies/__tests__/page-renderer-migration.test.tsx +0 -125
- package/templates/apps/web/app/[locale]/case-studies/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/clients/__tests__/page-renderer-migration.test.tsx +0 -85
- package/templates/apps/web/app/[locale]/clients/page.tsx +0 -47
- package/templates/apps/web/app/[locale]/contact/ConversationalIntakeWrapper.tsx +0 -249
- package/templates/apps/web/app/[locale]/contact/__tests__/ConversationalIntakeWrapper.test.tsx +0 -400
- package/templates/apps/web/app/[locale]/contact/__tests__/contact-form-magnet.test.ts +0 -138
- package/templates/apps/web/app/[locale]/contact/__tests__/contact-form-text.test.ts +0 -49
- package/templates/apps/web/app/[locale]/contact/__tests__/contact-magnet-page.test.tsx +0 -494
- package/templates/apps/web/app/[locale]/contact/__tests__/contact.actions.test.ts +0 -1122
- package/templates/apps/web/app/[locale]/contact/__tests__/intake-analytics.test.ts +0 -51
- package/templates/apps/web/app/[locale]/contact/__tests__/page-renderer-migration.test.tsx +0 -319
- package/templates/apps/web/app/[locale]/contact/contact-form-magnet.ts +0 -77
- package/templates/apps/web/app/[locale]/contact/contact-form-text.ts +0 -52
- package/templates/apps/web/app/[locale]/contact/contact.actions.ts +0 -403
- package/templates/apps/web/app/[locale]/contact/intake-analytics.ts +0 -49
- package/templates/apps/web/app/[locale]/contact/intake-script.ts +0 -92
- package/templates/apps/web/app/[locale]/contact/page.tsx +0 -267
- package/templates/apps/web/app/[locale]/courses/[slug]/page.tsx +0 -50
- package/templates/apps/web/app/[locale]/courses/__tests__/hub-children.test.tsx +0 -32
- package/templates/apps/web/app/[locale]/courses/__tests__/page-renderer-migration.test.tsx +0 -123
- package/templates/apps/web/app/[locale]/courses/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/events/[slug]/page.tsx +0 -57
- package/templates/apps/web/app/[locale]/events/__tests__/hub-children.test.tsx +0 -32
- package/templates/apps/web/app/[locale]/events/__tests__/page-renderer-migration.test.tsx +0 -164
- package/templates/apps/web/app/[locale]/events/__tests__/program-event.test.tsx +0 -120
- package/templates/apps/web/app/[locale]/events/page.tsx +0 -60
- package/templates/apps/web/app/[locale]/faq/page.tsx +0 -54
- package/templates/apps/web/app/[locale]/features/[slug]/page.tsx +0 -54
- package/templates/apps/web/app/[locale]/features/__tests__/hub-children.test.tsx +0 -32
- package/templates/apps/web/app/[locale]/features/page.tsx +0 -50
- package/templates/apps/web/app/[locale]/for/[slug]/page.tsx +0 -54
- package/templates/apps/web/app/[locale]/for/__tests__/hub-children.test.tsx +0 -32
- package/templates/apps/web/app/[locale]/for/__tests__/page-renderer-migration.test.tsx +0 -90
- package/templates/apps/web/app/[locale]/for/page.tsx +0 -51
- package/templates/apps/web/app/[locale]/glossary/page.tsx +0 -53
- package/templates/apps/web/app/[locale]/how-to/[slug]/page.tsx +0 -50
- package/templates/apps/web/app/[locale]/how-to/__tests__/page-renderer-migration.test.tsx +0 -78
- package/templates/apps/web/app/[locale]/how-to/page.tsx +0 -50
- package/templates/apps/web/app/[locale]/integrations/[slug]/page.tsx +0 -54
- package/templates/apps/web/app/[locale]/integrations/__tests__/hub-children.test.tsx +0 -38
- package/templates/apps/web/app/[locale]/integrations/__tests__/page-renderer-migration.test.tsx +0 -141
- package/templates/apps/web/app/[locale]/integrations/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/launch-service/page.tsx +0 -44
- package/templates/apps/web/app/[locale]/newsletter/__tests__/page.test.tsx +0 -236
- package/templates/apps/web/app/[locale]/newsletter/page.tsx +0 -179
- package/templates/apps/web/app/[locale]/page.tsx +0 -147
- package/templates/apps/web/app/[locale]/partners/[slug]/page.tsx +0 -45
- package/templates/apps/web/app/[locale]/partners/__tests__/hub-children.test.tsx +0 -32
- package/templates/apps/web/app/[locale]/partners/__tests__/page-renderer-migration.test.tsx +0 -125
- package/templates/apps/web/app/[locale]/partners/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/portfolio/[slug]/page.tsx +0 -46
- package/templates/apps/web/app/[locale]/portfolio/__tests__/hub-children.test.tsx +0 -38
- package/templates/apps/web/app/[locale]/portfolio/page.tsx +0 -50
- package/templates/apps/web/app/[locale]/pricing/[slug]/__tests__/page.test.tsx +0 -324
- package/templates/apps/web/app/[locale]/pricing/[slug]/page.tsx +0 -87
- package/templates/apps/web/app/[locale]/pricing/__tests__/__snapshots__/unconnected.test.tsx.snap +0 -7
- package/templates/apps/web/app/[locale]/pricing/__tests__/offerings.test.tsx +0 -605
- package/templates/apps/web/app/[locale]/pricing/__tests__/page.test.tsx +0 -219
- package/templates/apps/web/app/[locale]/pricing/__tests__/pricing-pages.test.tsx +0 -215
- package/templates/apps/web/app/[locale]/pricing/__tests__/unconnected.test.tsx +0 -282
- package/templates/apps/web/app/[locale]/pricing/page.tsx +0 -120
- package/templates/apps/web/app/[locale]/privacy/page.tsx +0 -40
- package/templates/apps/web/app/[locale]/products/[slug]/page.tsx +0 -50
- package/templates/apps/web/app/[locale]/products/__tests__/hub-children.test.tsx +0 -32
- package/templates/apps/web/app/[locale]/products/__tests__/page-renderer-migration.test.tsx +0 -141
- package/templates/apps/web/app/[locale]/products/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/projects/[slug]/page.tsx +0 -37
- package/templates/apps/web/app/[locale]/projects/__tests__/hub-children.test.tsx +0 -32
- package/templates/apps/web/app/[locale]/projects/__tests__/page-renderer-migration.test.tsx +0 -157
- package/templates/apps/web/app/[locale]/projects/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/purchase-policy/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/resources/[slug]/page.tsx +0 -54
- package/templates/apps/web/app/[locale]/resources/__tests__/hub-children.test.tsx +0 -38
- package/templates/apps/web/app/[locale]/resources/__tests__/page-renderer-migration.test.tsx +0 -151
- package/templates/apps/web/app/[locale]/resources/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/services/[slug]/[child]/page.tsx +0 -68
- package/templates/apps/web/app/[locale]/services/[slug]/page.tsx +0 -88
- package/templates/apps/web/app/[locale]/services/__tests__/hub-children.test.tsx +0 -158
- package/templates/apps/web/app/[locale]/services/__tests__/page-renderer-migration.test.tsx +0 -187
- package/templates/apps/web/app/[locale]/services/__tests__/service-detail-sections.test.tsx +0 -224
- package/templates/apps/web/app/[locale]/services/__tests__/service-families.test.tsx +0 -368
- package/templates/apps/web/app/[locale]/services/page.tsx +0 -71
- package/templates/apps/web/app/[locale]/software/[slug]/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/software/__tests__/page-renderer-migration.test.tsx +0 -81
- package/templates/apps/web/app/[locale]/software/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/team/[slug]/page.tsx +0 -45
- package/templates/apps/web/app/[locale]/team/__tests__/hub-children.test.tsx +0 -32
- package/templates/apps/web/app/[locale]/team/__tests__/team-routes.test.tsx +0 -161
- package/templates/apps/web/app/[locale]/team/page.tsx +0 -50
- package/templates/apps/web/app/[locale]/tech-articles/[slug]/page.tsx +0 -54
- package/templates/apps/web/app/[locale]/tech-articles/__tests__/page-renderer-migration.test.tsx +0 -82
- package/templates/apps/web/app/[locale]/tech-articles/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/templates/[slug]/__tests__/page.test.tsx +0 -203
- package/templates/apps/web/app/[locale]/templates/[slug]/page.tsx +0 -81
- package/templates/apps/web/app/[locale]/templates/__tests__/page.test.tsx +0 -237
- package/templates/apps/web/app/[locale]/templates/page.tsx +0 -114
- package/templates/apps/web/app/[locale]/terms/page.tsx +0 -40
- package/templates/apps/web/app/[locale]/testimonials/__tests__/page-renderer-migration.test.tsx +0 -85
- package/templates/apps/web/app/[locale]/testimonials/page.tsx +0 -51
- package/templates/apps/web/app/[locale]/thanks/[slug]/__tests__/page.test.tsx +0 -136
- package/templates/apps/web/app/[locale]/thanks/[slug]/page.tsx +0 -39
- package/templates/apps/web/app/[locale]/unsubscribe/__tests__/unsubscribe-rsc-boundary.test.tsx +0 -226
- package/templates/apps/web/app/[locale]/unsubscribe/__tests__/unsubscribe.test.tsx +0 -217
- package/templates/apps/web/app/[locale]/unsubscribe/page.tsx +0 -106
- package/templates/apps/web/app/[locale]/unsubscribe/unsubscribe-button.tsx +0 -94
- package/templates/apps/web/app/[locale]/unsubscribe/unsubscribe.actions.ts +0 -55
- package/templates/apps/web/app/[locale]/vs/[slug]/__tests__/page.test.tsx +0 -100
- package/templates/apps/web/app/[locale]/vs/[slug]/page.tsx +0 -60
- package/templates/apps/web/app/[locale]/whitepapers/[slug]/page.tsx +0 -54
- package/templates/apps/web/app/[locale]/whitepapers/__tests__/page-renderer-migration.test.tsx +0 -82
- package/templates/apps/web/app/[locale]/whitepapers/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/working-agreement/__tests__/page.test.tsx +0 -63
- package/templates/apps/web/app/[locale]/working-agreement/page.tsx +0 -41
- package/templates/apps/web/lib/__tests__/hub-children.fixtures.ts +0 -279
- package/templates/apps/web/lib/__tests__/route-family.test.ts +0 -57
- package/templates/apps/web/lib/__tests__/service-listing.test.ts +0 -111
- package/templates/apps/web/lib/__tests__/template-listing.test.ts +0 -158
- package/templates/apps/web/lib/hub-children.tsx +0 -351
- package/templates/apps/web/lib/meet-placeholder.ts +0 -5
- package/templates/apps/web/lib/posting-title.ts +0 -39
- package/templates/apps/web/lib/route-family.ts +0 -69
- package/templates/apps/web/lib/service-listing.ts +0 -89
- package/templates/apps/web/lib/template-listing.ts +0 -169
- package/templates/apps/web/src/lib/__tests__/lead-write.test.ts +0 -187
- package/templates/apps/web/src/lib/lead-write.ts +0 -90
- /package/templates/apps/web/{app/[locale]/contact → lib}/__tests__/site-contact-lines.test.ts +0 -0
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HTML snapshot regression tests for the services catalog routes
|
|
3
|
-
* apps/web → @working-theory/page-renderer migration (Spec 1.5.1).
|
|
4
|
-
*
|
|
5
|
-
* Node version: captured against Node 22.x (same as CI).
|
|
6
|
-
* MDX seed content: DI-injected stub — no fs reads, deterministic across environments.
|
|
7
|
-
*
|
|
8
|
-
* Two-commit strategy (per spec §6):
|
|
9
|
-
* Commit 1: this file added; snapshots captured against pre-migration routes.
|
|
10
|
-
* Commit 2: routes migrated; same snapshots verify diff=0 (GREEN).
|
|
11
|
-
*
|
|
12
|
-
* Routes under test:
|
|
13
|
-
* - services/page.tsx (index — empty-state + populated)
|
|
14
|
-
* - services/[slug]/page.tsx (detail — populated + null→notFound)
|
|
15
|
-
*
|
|
16
|
-
* Failure = snapshot diff > 0 bytes. DO NOT regenerate snapshots to pass.
|
|
17
|
-
* A non-zero diff indicates a behavior regression in the migration. Escalate.
|
|
18
|
-
*/
|
|
19
|
-
import React from "react";
|
|
20
|
-
import { render } from "@testing-library/react";
|
|
21
|
-
|
|
22
|
-
jest.mock("next/navigation", () => ({
|
|
23
|
-
__esModule: true,
|
|
24
|
-
notFound: jest.fn(() => {
|
|
25
|
-
throw new Error("NEXT_NOT_FOUND");
|
|
26
|
-
}),
|
|
27
|
-
}));
|
|
28
|
-
|
|
29
|
-
import { notFound } from "next/navigation";
|
|
30
|
-
import ServicesPage from "../page";
|
|
31
|
-
import ServiceSlugPage from "../[slug]/page";
|
|
32
|
-
import * as pageRenderer from "@working-theory/page-renderer";
|
|
33
|
-
|
|
34
|
-
// #10704 — a fixture suite: its content is shaped for the mdx source, whatever the site serves from.
|
|
35
|
-
process.env.CONTENT_ADAPTER = "mdx";
|
|
36
|
-
|
|
37
|
-
const mockNotFound = notFound as jest.MockedFunction<typeof notFound>;
|
|
38
|
-
|
|
39
|
-
// ── Shared stub helpers ────────────────────────────────────────────────────────
|
|
40
|
-
|
|
41
|
-
function makeServicesListSource() {
|
|
42
|
-
return {
|
|
43
|
-
frontmatter: {
|
|
44
|
-
type: "ServicesList" as const,
|
|
45
|
-
slug: "services",
|
|
46
|
-
title: "Services",
|
|
47
|
-
description: "All services.",
|
|
48
|
-
},
|
|
49
|
-
body: "# Services\n\nBody.",
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function makeServiceSource(slug: string) {
|
|
54
|
-
return {
|
|
55
|
-
frontmatter: {
|
|
56
|
-
type: "Service" as const,
|
|
57
|
-
slug,
|
|
58
|
-
title: "Implementation consulting",
|
|
59
|
-
description: "Help adapting AI Launch Kit.",
|
|
60
|
-
},
|
|
61
|
-
body: "# Implementation consulting\n\nBody.",
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// ── services/page.tsx — index ──────────────────────────────────────────────────
|
|
66
|
-
|
|
67
|
-
describe("ServicesPage — snapshot regression", () => {
|
|
68
|
-
beforeEach(() => {
|
|
69
|
-
mockNotFound.mockClear();
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it("empty state renders deterministic HTML", async () => {
|
|
73
|
-
const getMdxSourceEmpty = jest.fn().mockResolvedValue(null);
|
|
74
|
-
const element = await ServicesPage({
|
|
75
|
-
params: Promise.resolve({ locale: "en" }),
|
|
76
|
-
// No child pages: this snapshot pins the hub's own render (#10121).
|
|
77
|
-
getMdxSlugs: async () => [],
|
|
78
|
-
getMdxSource: getMdxSourceEmpty,
|
|
79
|
-
});
|
|
80
|
-
const { container } = render(element);
|
|
81
|
-
expect(container.innerHTML).toMatchInlineSnapshot(
|
|
82
|
-
`"<main id="main"><h1 class="text-heading-1 lg:text-display-sm font-display text-fg hero-type-display">Services</h1><p data-testid="section-empty-state">Services listing coming soon.</p></main>"`,
|
|
83
|
-
);
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it("populated state renders deterministic HTML", async () => {
|
|
87
|
-
const source = makeServicesListSource();
|
|
88
|
-
const getMdxSourcePopulated = jest.fn().mockResolvedValue(source);
|
|
89
|
-
const element = await ServicesPage({
|
|
90
|
-
params: Promise.resolve({ locale: "en" }),
|
|
91
|
-
// No child pages: this snapshot pins the hub's own render (#10121).
|
|
92
|
-
getMdxSlugs: async () => [],
|
|
93
|
-
getMdxSource: getMdxSourcePopulated,
|
|
94
|
-
});
|
|
95
|
-
const { container } = render(element);
|
|
96
|
-
expect(container.innerHTML).toMatchInlineSnapshot(`
|
|
97
|
-
"<script type="application/ld+json" data-testid="json-ld">{"@context":"https://schema.org","@type":"CollectionPage","inLanguage":"en","name":"Services","description":"All services.","mainEntity":{"@type":"ItemList","itemListElement":[{"@type":"Service"}]}}</script><main id="main"><div class="mx-auto w-full max-w-container-xl px-4 md:px-6 lg:px-8 py-section"><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 [&>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 [&>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 class="ailk-prose max-w-none text-(--color-text-muted) text-body-sm leading-relaxed [&>*:first-child]:mt-0 [&_h2]:mt-block-loose [&_h2]:scroll-mt-24 [&_h2]:text-heading-3 [&_h2]:font-display [&_h2]:text-(--color-fg) [&_h3]:mt-block-loose [&_h3]:scroll-mt-24 [&_h3]:text-heading-4 [&_h3]:font-display [&_h3]:text-(--color-fg) [&_h4]:mt-block-tight [&_h4]:scroll-mt-24 [&_h4]:text-heading-4 [&_h4]:font-display [&_h4]:text-(--color-fg) [&_h5]:mt-block-tight [&_h5]:scroll-mt-24 [&_h5]:text-heading-4 [&_h5]:font-display [&_h5]:text-(--color-fg) [&_h6]:mt-block-tight [&_h6]:scroll-mt-24 [&_h6]:text-heading-4 [&_h6]:font-display [&_h6]:text-(--color-fg) [&_p]:mt-paragraph [&_strong]:font-semibold [&_strong]:text-(--color-fg) [&_em]:italic [&_ul]:mt-paragraph [&_ul]:list-disc [&_ul]:ps-6 [&_ol]:mt-paragraph [&_ol]:list-decimal [&_ol]:ps-6 [&_li]:mt-1 [&_li]:ps-1 [&_li]:marker:text-(--color-text-muted) [&_li>ul]:mt-1 [&_li>ol]:mt-1 [&_blockquote]:mt-paragraph [&_blockquote]:border-s-4 [&_blockquote]:border-(--color-border-strong) [&_blockquote]:ps-4 [&_blockquote]:italic [&_blockquote]:text-(--color-text-muted) [&_hr]:my-block-loose [&_hr]:border-(--color-border) [&_a]:text-(--color-accent) [&_a]:underline [&_a]:underline-offset-4 [&_:not(pre)>code]:rounded [&_:not(pre)>code]:bg-(--color-surface-secondary) [&_:not(pre)>code]:px-1.5 [&_:not(pre)>code]:py-0.5 [&_:not(pre)>code]:text-code [&_:not(pre)>code]:font-mono [&_:not(pre)>code]:text-(--color-fg) [&_pre]:mt-paragraph [&_pre]:overflow-auto [&_pre]:rounded-md [&_pre]:border-hairline [&_pre]:border-(--color-border) [&_pre]:bg-(--color-bg) [&_pre]:p-4 [&_pre]:font-mono [&_pre]:text-body-sm [&_img]:mt-paragraph [&_img]:h-auto [&_img]:max-w-full [&_img]:rounded-lg [&_table]:mt-paragraph [&_table]:w-full [&_table]:border-collapse [&_table]:text-body-sm [&_th]:border-b [&_th]:border-(--color-border) [&_th]:bg-(--color-surface-secondary) [&_th]:px-3 [&_th]:py-2 [&_th]:text-start [&_th]:font-semibold [&_th]:text-(--color-fg) [&_td]:border-b [&_td]:border-(--color-border) [&_td]:px-3 [&_td]:py-2 [&_kbd]:rounded [&_kbd]:border-hairline [&_kbd]:border-(--color-border) [&_kbd]:bg-(--color-surface-secondary) [&_kbd]:px-1.5 [&_kbd]:py-0.5 [&_kbd]:text-caption [&_kbd]:font-mono" data-testid="mdx-content"><div data-testid="mdx-remote" data-source="# Services
|
|
98
|
-
|
|
99
|
-
Body."></div></div></article></div></div></div></main>"
|
|
100
|
-
`);
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
// ── #7745 D2: a ServicesList page that authors sections renders them ──────────
|
|
105
|
-
|
|
106
|
-
describe("ServicesPage — authored sections (#7745)", () => {
|
|
107
|
-
it("renders a sectioned page in sections mode, with no mdx-body", async () => {
|
|
108
|
-
const renderPageSpy = jest.spyOn(pageRenderer, "renderPage");
|
|
109
|
-
const source = {
|
|
110
|
-
...makeServicesListSource(),
|
|
111
|
-
frontmatter: {
|
|
112
|
-
...makeServicesListSource().frontmatter,
|
|
113
|
-
sections: [
|
|
114
|
-
{
|
|
115
|
-
id: "hero-1",
|
|
116
|
-
type: "hero",
|
|
117
|
-
data: { headline: "Get on AILK fast" },
|
|
118
|
-
},
|
|
119
|
-
],
|
|
120
|
-
},
|
|
121
|
-
};
|
|
122
|
-
const element = await ServicesPage({
|
|
123
|
-
params: Promise.resolve({ locale: "en" }),
|
|
124
|
-
// No child pages: this snapshot pins the hub's own render (#10121).
|
|
125
|
-
getMdxSlugs: async () => [],
|
|
126
|
-
getMdxSource: jest.fn().mockResolvedValue(source),
|
|
127
|
-
});
|
|
128
|
-
const { container } = render(element);
|
|
129
|
-
expect(renderPageSpy).toHaveBeenCalledTimes(1);
|
|
130
|
-
expect(renderPageSpy.mock.calls[0]![0].bodyMode).toBeUndefined();
|
|
131
|
-
renderPageSpy.mockRestore();
|
|
132
|
-
expect(container.querySelector('[data-testid="mdx-body"]')).toBeNull();
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
it("keeps the mdx-body render for a prose-only page", async () => {
|
|
136
|
-
const element = await ServicesPage({
|
|
137
|
-
params: Promise.resolve({ locale: "en" }),
|
|
138
|
-
// No child pages: this snapshot pins the hub's own render (#10121).
|
|
139
|
-
getMdxSlugs: async () => [],
|
|
140
|
-
getMdxSource: jest.fn().mockResolvedValue(makeServicesListSource()),
|
|
141
|
-
});
|
|
142
|
-
const { container } = render(element);
|
|
143
|
-
expect(container.querySelector('[data-testid="mdx-body"]')).not.toBeNull();
|
|
144
|
-
});
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
// ── services/[slug]/page.tsx — detail ─────────────────────────────────────────
|
|
148
|
-
|
|
149
|
-
describe("ServiceSlugPage — snapshot regression", () => {
|
|
150
|
-
beforeEach(() => {
|
|
151
|
-
mockNotFound.mockClear();
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
it("populated state renders deterministic HTML", async () => {
|
|
155
|
-
const slug = "consulting";
|
|
156
|
-
const source = makeServiceSource(slug);
|
|
157
|
-
const getMdxSourcePopulated = jest.fn().mockResolvedValue(source);
|
|
158
|
-
const element = await ServiceSlugPage({
|
|
159
|
-
params: Promise.resolve({ locale: "en", slug }),
|
|
160
|
-
getMdxSource: getMdxSourcePopulated,
|
|
161
|
-
});
|
|
162
|
-
const { container } = render(element);
|
|
163
|
-
expect(container.innerHTML).toMatchInlineSnapshot(`
|
|
164
|
-
"<script type="application/ld+json" data-testid="json-ld">{"@context":"https://schema.org","@graph":[{"@context":"https://schema.org","@type":"WebPage","inLanguage":"en","name":"Implementation consulting","description":"Help adapting AI Launch Kit.","mainEntity":{"@context":"https://schema.org","@type":"Service","name":"Implementation consulting","description":"Help adapting AI Launch Kit."}},{"@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":"Services","item":"http://localhost:3000/en/services"},{"@type":"ListItem","position":3,"name":"Implementation consulting","item":"http://localhost:3000/en/services/consulting"}]}]}</script><main id="main"><div class="mx-auto w-full max-w-container-xl px-4 md:px-6 lg:px-8 py-section"><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 [&>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 [&>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 class="ailk-prose max-w-none text-(--color-text-muted) text-body-sm leading-relaxed [&>*:first-child]:mt-0 [&_h2]:mt-block-loose [&_h2]:scroll-mt-24 [&_h2]:text-heading-3 [&_h2]:font-display [&_h2]:text-(--color-fg) [&_h3]:mt-block-loose [&_h3]:scroll-mt-24 [&_h3]:text-heading-4 [&_h3]:font-display [&_h3]:text-(--color-fg) [&_h4]:mt-block-tight [&_h4]:scroll-mt-24 [&_h4]:text-heading-4 [&_h4]:font-display [&_h4]:text-(--color-fg) [&_h5]:mt-block-tight [&_h5]:scroll-mt-24 [&_h5]:text-heading-4 [&_h5]:font-display [&_h5]:text-(--color-fg) [&_h6]:mt-block-tight [&_h6]:scroll-mt-24 [&_h6]:text-heading-4 [&_h6]:font-display [&_h6]:text-(--color-fg) [&_p]:mt-paragraph [&_strong]:font-semibold [&_strong]:text-(--color-fg) [&_em]:italic [&_ul]:mt-paragraph [&_ul]:list-disc [&_ul]:ps-6 [&_ol]:mt-paragraph [&_ol]:list-decimal [&_ol]:ps-6 [&_li]:mt-1 [&_li]:ps-1 [&_li]:marker:text-(--color-text-muted) [&_li>ul]:mt-1 [&_li>ol]:mt-1 [&_blockquote]:mt-paragraph [&_blockquote]:border-s-4 [&_blockquote]:border-(--color-border-strong) [&_blockquote]:ps-4 [&_blockquote]:italic [&_blockquote]:text-(--color-text-muted) [&_hr]:my-block-loose [&_hr]:border-(--color-border) [&_a]:text-(--color-accent) [&_a]:underline [&_a]:underline-offset-4 [&_:not(pre)>code]:rounded [&_:not(pre)>code]:bg-(--color-surface-secondary) [&_:not(pre)>code]:px-1.5 [&_:not(pre)>code]:py-0.5 [&_:not(pre)>code]:text-code [&_:not(pre)>code]:font-mono [&_:not(pre)>code]:text-(--color-fg) [&_pre]:mt-paragraph [&_pre]:overflow-auto [&_pre]:rounded-md [&_pre]:border-hairline [&_pre]:border-(--color-border) [&_pre]:bg-(--color-bg) [&_pre]:p-4 [&_pre]:font-mono [&_pre]:text-body-sm [&_img]:mt-paragraph [&_img]:h-auto [&_img]:max-w-full [&_img]:rounded-lg [&_table]:mt-paragraph [&_table]:w-full [&_table]:border-collapse [&_table]:text-body-sm [&_th]:border-b [&_th]:border-(--color-border) [&_th]:bg-(--color-surface-secondary) [&_th]:px-3 [&_th]:py-2 [&_th]:text-start [&_th]:font-semibold [&_th]:text-(--color-fg) [&_td]:border-b [&_td]:border-(--color-border) [&_td]:px-3 [&_td]:py-2 [&_kbd]:rounded [&_kbd]:border-hairline [&_kbd]:border-(--color-border) [&_kbd]:bg-(--color-surface-secondary) [&_kbd]:px-1.5 [&_kbd]:py-0.5 [&_kbd]:text-caption [&_kbd]:font-mono" data-testid="mdx-content"><div data-testid="mdx-remote" data-source="# Implementation consulting
|
|
165
|
-
|
|
166
|
-
Body."></div></div></article></div></div></div></main>"
|
|
167
|
-
`);
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
it("null source calls notFound()", async () => {
|
|
171
|
-
const renderPageSpy = jest.spyOn(pageRenderer, "renderPage");
|
|
172
|
-
const getMdxSourceNull = jest.fn().mockResolvedValue(null);
|
|
173
|
-
await expect(
|
|
174
|
-
ServiceSlugPage({
|
|
175
|
-
params: Promise.resolve({ locale: "en", slug: "unknown-slug" }),
|
|
176
|
-
getMdxSource: getMdxSourceNull,
|
|
177
|
-
}),
|
|
178
|
-
).rejects.toThrow("NEXT_NOT_FOUND");
|
|
179
|
-
// The 404 is renderPage's detail branch, not a route pre-check (#7537).
|
|
180
|
-
expect(renderPageSpy).toHaveBeenCalledTimes(1);
|
|
181
|
-
expect(
|
|
182
|
-
renderPageSpy.mock.calls[0]![0].translationsNamespace,
|
|
183
|
-
).toBeUndefined();
|
|
184
|
-
renderPageSpy.mockRestore();
|
|
185
|
-
expect(mockNotFound).toHaveBeenCalled();
|
|
186
|
-
});
|
|
187
|
-
});
|
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The services detail routes render composed `sections[]` (#10122) — the rule
|
|
3
|
-
* /vs/[slug] (#6878 D10) and the eleven detail routes of PR #10125 apply,
|
|
4
|
-
* here on /services/[slug] and #10043's /services/[slug]/[child]: a page
|
|
5
|
-
* whose frontmatter carries a non-empty `sections[]` renders through
|
|
6
|
-
* renderPage in sections mode (so its JSON-LD is built from the same
|
|
7
|
-
* sections); any other page keeps its MDX body exactly as before. #10043's
|
|
8
|
-
* parent redirect, category children list and one-URL 404 are unchanged.
|
|
9
|
-
*
|
|
10
|
-
* `renderPage` is mocked at the `@working-theory/page-renderer` boundary;
|
|
11
|
-
* `getMdxSource` is supplied per call through each route's DI prop, and the
|
|
12
|
-
* category's child list through a mocked `listDetailPages`.
|
|
13
|
-
*/
|
|
14
|
-
import { isValidElement } from "react";
|
|
15
|
-
|
|
16
|
-
const mockRenderPage = jest.fn(async (..._args: unknown[]) => "<rendered/>");
|
|
17
|
-
const mockListDetailPages = jest.fn(
|
|
18
|
-
async (..._args: unknown[]) => [] as unknown[],
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
jest.mock("@working-theory/page-renderer", () => ({
|
|
22
|
-
__esModule: true,
|
|
23
|
-
renderPage: (...args: unknown[]) => mockRenderPage(...args),
|
|
24
|
-
renderPageMetadata: jest.fn(),
|
|
25
|
-
getMdxSource: jest.fn(),
|
|
26
|
-
}));
|
|
27
|
-
|
|
28
|
-
// eslint-disable-next-line no-restricted-syntax -- #507: the route passes no `listSlugs`, so `listDetailPages` would list the real content tree; the category's child list is this test's fixture.
|
|
29
|
-
jest.mock("../../../../lib/route-family", () => ({
|
|
30
|
-
__esModule: true,
|
|
31
|
-
listDetailPages: (...args: unknown[]) => mockListDetailPages(...args),
|
|
32
|
-
}));
|
|
33
|
-
|
|
34
|
-
jest.mock("next-intl/server", () => ({
|
|
35
|
-
__esModule: true,
|
|
36
|
-
getTranslations: jest.fn(async () => (key: string) => key),
|
|
37
|
-
}));
|
|
38
|
-
|
|
39
|
-
jest.mock("next/navigation", () => ({
|
|
40
|
-
__esModule: true,
|
|
41
|
-
notFound: jest.fn(() => {
|
|
42
|
-
throw new Error("NEXT_NOT_FOUND");
|
|
43
|
-
}),
|
|
44
|
-
permanentRedirect: jest.fn(() => {
|
|
45
|
-
throw new Error("NEXT_REDIRECT");
|
|
46
|
-
}),
|
|
47
|
-
}));
|
|
48
|
-
|
|
49
|
-
import ServiceChildPage from "../[slug]/[child]/page";
|
|
50
|
-
import ServiceSlugPage from "../[slug]/page";
|
|
51
|
-
|
|
52
|
-
const nav = jest.requireMock("next/navigation") as {
|
|
53
|
-
notFound: jest.Mock;
|
|
54
|
-
permanentRedirect: jest.Mock;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const SECTIONS = [
|
|
58
|
-
{ id: "hero", type: "hero", data: {} },
|
|
59
|
-
{ id: "cta", type: "cta", data: {} },
|
|
60
|
-
];
|
|
61
|
-
|
|
62
|
-
type Frontmatter = Record<string, unknown>;
|
|
63
|
-
|
|
64
|
-
function service(slug: string, extra: Frontmatter = {}) {
|
|
65
|
-
return {
|
|
66
|
-
frontmatter: {
|
|
67
|
-
type: "Service",
|
|
68
|
-
slug,
|
|
69
|
-
title: slug,
|
|
70
|
-
description: `${slug} description.`,
|
|
71
|
-
...extra,
|
|
72
|
-
},
|
|
73
|
-
body: "Prose body.",
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/** A `getMdxSource` over a slug → source table; anything else is null. */
|
|
78
|
-
function sources(table: Record<string, ReturnType<typeof service>>): jest.Mock {
|
|
79
|
-
return jest.fn(async (_type: string, slug: string) => table[slug] ?? null);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function passedInput(): Record<string, unknown> {
|
|
83
|
-
return mockRenderPage.mock.calls[0]?.[0] as Record<string, unknown>;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
beforeEach(() => {
|
|
87
|
-
jest.clearAllMocks();
|
|
88
|
-
mockListDetailPages.mockResolvedValue([]);
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
describe("/services/[slug]", () => {
|
|
92
|
-
const params = Promise.resolve({ locale: "en", slug: "positioning" });
|
|
93
|
-
|
|
94
|
-
it("renders a page with a non-empty sections[] as sections", async () => {
|
|
95
|
-
const getMdxSource = sources({
|
|
96
|
-
positioning: service("positioning", { sections: SECTIONS }),
|
|
97
|
-
});
|
|
98
|
-
await ServiceSlugPage({ params, getMdxSource });
|
|
99
|
-
|
|
100
|
-
const input = passedInput();
|
|
101
|
-
expect(input.type).toBe("Service");
|
|
102
|
-
expect(input.slug).toBe("positioning");
|
|
103
|
-
expect(input.bodyMode).toBeUndefined();
|
|
104
|
-
expect(input.populatedDescriptionTestId).toBeUndefined();
|
|
105
|
-
expect(input.getMdxSource).toBe(getMdxSource);
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
it("renders a page without sections as its MDX body, as before", async () => {
|
|
109
|
-
await ServiceSlugPage({
|
|
110
|
-
params,
|
|
111
|
-
getMdxSource: sources({ positioning: service("positioning") }),
|
|
112
|
-
});
|
|
113
|
-
expect(passedInput().bodyMode).toBe("mdx-body");
|
|
114
|
-
expect(passedInput().populatedDescriptionTestId).toBe(
|
|
115
|
-
"service-description",
|
|
116
|
-
);
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
it("treats an empty sections[] as a prose page", async () => {
|
|
120
|
-
await ServiceSlugPage({
|
|
121
|
-
params,
|
|
122
|
-
getMdxSource: sources({
|
|
123
|
-
positioning: service("positioning", { sections: [] }),
|
|
124
|
-
}),
|
|
125
|
-
});
|
|
126
|
-
expect(passedInput().bodyMode).toBe("mdx-body");
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
it("leaves an unknown slug to renderPage's 404 (mdx-body mode)", async () => {
|
|
130
|
-
await ServiceSlugPage({ params, getMdxSource: sources({}) });
|
|
131
|
-
expect(passedInput().bodyMode).toBe("mdx-body");
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
it("a sections category still lists its child services after its sections", async () => {
|
|
135
|
-
mockListDetailPages.mockResolvedValue([
|
|
136
|
-
{
|
|
137
|
-
slug: "audit",
|
|
138
|
-
frontmatter: { ...service("audit").frontmatter, parent: "positioning" },
|
|
139
|
-
},
|
|
140
|
-
]);
|
|
141
|
-
await ServiceSlugPage({
|
|
142
|
-
params,
|
|
143
|
-
getMdxSource: sources({
|
|
144
|
-
positioning: service("positioning", { sections: SECTIONS }),
|
|
145
|
-
}),
|
|
146
|
-
});
|
|
147
|
-
expect(passedInput().bodyMode).toBeUndefined();
|
|
148
|
-
expect(isValidElement(passedInput().trailing)).toBe(true);
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
it("a sections service with a parent still redirects to its category URL", async () => {
|
|
152
|
-
await expect(
|
|
153
|
-
ServiceSlugPage({
|
|
154
|
-
params,
|
|
155
|
-
getMdxSource: sources({
|
|
156
|
-
positioning: service("positioning", {
|
|
157
|
-
parent: "strategy",
|
|
158
|
-
sections: SECTIONS,
|
|
159
|
-
}),
|
|
160
|
-
}),
|
|
161
|
-
}),
|
|
162
|
-
).rejects.toThrow("NEXT_REDIRECT");
|
|
163
|
-
expect(nav.permanentRedirect).toHaveBeenCalledWith(
|
|
164
|
-
"/services/strategy/positioning",
|
|
165
|
-
);
|
|
166
|
-
expect(mockRenderPage).not.toHaveBeenCalled();
|
|
167
|
-
});
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
describe("/services/[slug]/[child]", () => {
|
|
171
|
-
const params = Promise.resolve({
|
|
172
|
-
locale: "en",
|
|
173
|
-
slug: "strategy",
|
|
174
|
-
child: "positioning",
|
|
175
|
-
});
|
|
176
|
-
const category = service("strategy");
|
|
177
|
-
|
|
178
|
-
it("renders a child with a non-empty sections[] as sections", async () => {
|
|
179
|
-
const getMdxSource = sources({
|
|
180
|
-
strategy: category,
|
|
181
|
-
positioning: service("positioning", {
|
|
182
|
-
parent: "strategy",
|
|
183
|
-
sections: SECTIONS,
|
|
184
|
-
}),
|
|
185
|
-
});
|
|
186
|
-
await ServiceChildPage({ params, getMdxSource });
|
|
187
|
-
|
|
188
|
-
const input = passedInput();
|
|
189
|
-
expect(input.type).toBe("Service");
|
|
190
|
-
expect(input.slug).toBe("positioning");
|
|
191
|
-
expect(input.bodyMode).toBeUndefined();
|
|
192
|
-
expect(input.populatedDescriptionTestId).toBeUndefined();
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
it("renders a child without sections as its MDX body, as before", async () => {
|
|
196
|
-
await ServiceChildPage({
|
|
197
|
-
params,
|
|
198
|
-
getMdxSource: sources({
|
|
199
|
-
strategy: category,
|
|
200
|
-
positioning: service("positioning", { parent: "strategy" }),
|
|
201
|
-
}),
|
|
202
|
-
});
|
|
203
|
-
expect(passedInput().bodyMode).toBe("mdx-body");
|
|
204
|
-
expect(passedInput().populatedDescriptionTestId).toBe(
|
|
205
|
-
"service-description",
|
|
206
|
-
);
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
it("a sections child under the wrong category is still a 404", async () => {
|
|
210
|
-
await expect(
|
|
211
|
-
ServiceChildPage({
|
|
212
|
-
params,
|
|
213
|
-
getMdxSource: sources({
|
|
214
|
-
strategy: category,
|
|
215
|
-
positioning: service("positioning", {
|
|
216
|
-
parent: "other",
|
|
217
|
-
sections: SECTIONS,
|
|
218
|
-
}),
|
|
219
|
-
}),
|
|
220
|
-
}),
|
|
221
|
-
).rejects.toThrow("NEXT_NOT_FOUND");
|
|
222
|
-
expect(mockRenderPage).not.toHaveBeenCalled();
|
|
223
|
-
});
|
|
224
|
-
});
|