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,148 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for the generic `[slug]` content route (#5469 D2).
|
|
3
|
-
*
|
|
4
|
-
* - Populated: getMdxSource returns a LandingPage source → renderPage
|
|
5
|
-
* sections mode composes the page (JSON-LD + SectionRenderer), no
|
|
6
|
-
* notFound() call, and the frontmatter `schema` override reaches the
|
|
7
|
-
* emitted JSON-LD (the escape hatch, proven with a `HowTo` fixture).
|
|
8
|
-
* - Unknown slug: getMdxSource returns null → renderPage's own detail-route
|
|
9
|
-
* branch (no translationsNamespace passed) calls notFound().
|
|
10
|
-
* - Resolution: the route asks the adapter for `LandingPage` first and, only
|
|
11
|
-
* when that is null, `BlogList` (the Free /blog teaser — the one list type
|
|
12
|
-
* that cannot own a route directory, since the docs-blog module owns
|
|
13
|
-
* `blog/`). A BlogList source renders through renderPage with its own type,
|
|
14
|
-
* so the JSON-LD is the BlogList builder's `Blog`.
|
|
15
|
-
*/
|
|
16
|
-
import React from "react";
|
|
17
|
-
import { render } from "@testing-library/react";
|
|
18
|
-
|
|
19
|
-
jest.mock("next/navigation", () => ({
|
|
20
|
-
__esModule: true,
|
|
21
|
-
notFound: jest.fn(() => {
|
|
22
|
-
throw new Error("NEXT_NOT_FOUND");
|
|
23
|
-
}),
|
|
24
|
-
}));
|
|
25
|
-
|
|
26
|
-
jest.mock("@working-theory/ui", () => ({
|
|
27
|
-
// #7789: renderPage's fallback page head renders inside the section Container.
|
|
28
|
-
Container: ({ children }: { children?: React.ReactNode }) =>
|
|
29
|
-
React.createElement("div", null, children),
|
|
30
|
-
Heading: ({
|
|
31
|
-
children,
|
|
32
|
-
level,
|
|
33
|
-
}: {
|
|
34
|
-
children: React.ReactNode;
|
|
35
|
-
level: number;
|
|
36
|
-
}): React.ReactElement =>
|
|
37
|
-
React.createElement(`h${level}`, null, children),
|
|
38
|
-
SectionRenderer: ({ sections }: { sections: unknown[] }) =>
|
|
39
|
-
React.createElement("div", {
|
|
40
|
-
"data-testid": "section-renderer",
|
|
41
|
-
"data-section-count": String(sections.length),
|
|
42
|
-
}),
|
|
43
|
-
}));
|
|
44
|
-
|
|
45
|
-
import { notFound } from "next/navigation";
|
|
46
|
-
import SlugPage from "../page";
|
|
47
|
-
|
|
48
|
-
// #10704 — a fixture suite: its content is shaped for the mdx source, whatever the site serves from.
|
|
49
|
-
process.env.CONTENT_ADAPTER = "mdx";
|
|
50
|
-
|
|
51
|
-
const mockNotFound = notFound as jest.MockedFunction<typeof notFound>;
|
|
52
|
-
|
|
53
|
-
function makeSource(slug: string, schema?: Record<string, unknown>) {
|
|
54
|
-
return {
|
|
55
|
-
frontmatter: {
|
|
56
|
-
type: "LandingPage" as const,
|
|
57
|
-
slug,
|
|
58
|
-
title: `Title for ${slug}`,
|
|
59
|
-
description: `Description for ${slug}`,
|
|
60
|
-
...(schema !== undefined && { schema }),
|
|
61
|
-
sections: [
|
|
62
|
-
{
|
|
63
|
-
id: "hero",
|
|
64
|
-
type: "hero" as const,
|
|
65
|
-
data: { headline: `Title for ${slug}` },
|
|
66
|
-
},
|
|
67
|
-
],
|
|
68
|
-
},
|
|
69
|
-
body: "",
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
describe("[slug] — the generic content route (LandingPage, then BlogList)", () => {
|
|
74
|
-
beforeEach(() => {
|
|
75
|
-
mockNotFound.mockClear();
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it("resolves the slug against LandingPage and renders through renderPage sections mode", async () => {
|
|
79
|
-
const getMdxSource = jest.fn().mockResolvedValue(makeSource("how-it-works"));
|
|
80
|
-
|
|
81
|
-
const element = await SlugPage({
|
|
82
|
-
params: Promise.resolve({ locale: "en", slug: "how-it-works" }),
|
|
83
|
-
getMdxSource,
|
|
84
|
-
});
|
|
85
|
-
const { container } = render(element);
|
|
86
|
-
|
|
87
|
-
expect(getMdxSource).toHaveBeenCalledWith("LandingPage", "how-it-works", "en");
|
|
88
|
-
expect(container.querySelector("[data-testid='section-renderer']")).not.toBeNull();
|
|
89
|
-
expect(container.querySelector("script[type='application/ld+json']")).not.toBeNull();
|
|
90
|
-
expect(mockNotFound).not.toHaveBeenCalled();
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it("emits the frontmatter `schema` override in the JSON-LD (the HowTo escape hatch)", async () => {
|
|
94
|
-
const getMdxSource = jest
|
|
95
|
-
.fn()
|
|
96
|
-
.mockResolvedValue(makeSource("how-it-works", { "@type": "HowTo" }));
|
|
97
|
-
|
|
98
|
-
const element = await SlugPage({
|
|
99
|
-
params: Promise.resolve({ locale: "en", slug: "how-it-works" }),
|
|
100
|
-
getMdxSource,
|
|
101
|
-
});
|
|
102
|
-
const { container } = render(element);
|
|
103
|
-
|
|
104
|
-
const script = container.querySelector("script[type='application/ld+json']");
|
|
105
|
-
expect(script).not.toBeNull();
|
|
106
|
-
expect(script?.textContent ?? "").toContain('"HowTo"');
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
it("falls back to BlogList when no LandingPage source exists (the Free /blog teaser)", async () => {
|
|
110
|
-
const blog = {
|
|
111
|
-
frontmatter: {
|
|
112
|
-
type: "BlogList" as const,
|
|
113
|
-
slug: "blog",
|
|
114
|
-
title: "Blog",
|
|
115
|
-
description: "This template does not include a blog.",
|
|
116
|
-
sections: [{ id: "hero", type: "hero" as const, data: { headline: "Blog" } }],
|
|
117
|
-
},
|
|
118
|
-
body: "",
|
|
119
|
-
};
|
|
120
|
-
const getMdxSource = jest
|
|
121
|
-
.fn()
|
|
122
|
-
.mockImplementation(async (type: string) => (type === "BlogList" ? blog : null));
|
|
123
|
-
|
|
124
|
-
const element = await SlugPage({
|
|
125
|
-
params: Promise.resolve({ locale: "en", slug: "blog" }),
|
|
126
|
-
getMdxSource,
|
|
127
|
-
});
|
|
128
|
-
const { container } = render(element);
|
|
129
|
-
|
|
130
|
-
expect(getMdxSource).toHaveBeenNthCalledWith(1, "LandingPage", "blog", "en");
|
|
131
|
-
expect(getMdxSource).toHaveBeenNthCalledWith(2, "BlogList", "blog", "en");
|
|
132
|
-
const script = container.querySelector("script[type='application/ld+json']");
|
|
133
|
-
expect(script?.textContent ?? "").toContain('"@type":"Blog"');
|
|
134
|
-
expect(mockNotFound).not.toHaveBeenCalled();
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
it("calls notFound() for a slug with neither a LandingPage nor a BlogList source", async () => {
|
|
138
|
-
const getMdxSource = jest.fn().mockResolvedValue(null);
|
|
139
|
-
|
|
140
|
-
await expect(
|
|
141
|
-
SlugPage({
|
|
142
|
-
params: Promise.resolve({ locale: "en", slug: "not-a-page" }),
|
|
143
|
-
getMdxSource,
|
|
144
|
-
}),
|
|
145
|
-
).rejects.toThrow("NEXT_NOT_FOUND");
|
|
146
|
-
expect(mockNotFound).toHaveBeenCalledTimes(1);
|
|
147
|
-
});
|
|
148
|
-
});
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
// The one generic content route (#5469 D2). Serves the Free marketing-site
|
|
2
|
-
// template's /blog teaser — and any other
|
|
3
|
-
// `content/<locale>/LandingPage/<slug>.mdx` a site adds — through exactly the
|
|
4
|
-
// render path the static routes use (`renderPage`, sections mode, JSON-LD
|
|
5
|
-
// from frontmatter — a page's `schema:` override rides the escape hatch,
|
|
6
|
-
// though the structured-data gate only accepts a `WebPage` primary block
|
|
7
|
-
// for a LandingPage, so the Free template's pages set none).
|
|
8
|
-
//
|
|
9
|
-
// Precedence, not gating: Next.js resolves a static segment before a dynamic
|
|
10
|
-
// one, so this route never shadows a scaffolded route directory. That is what
|
|
11
|
-
// lets /blog degrade — keyless there is no `blog/` directory and the teaser
|
|
12
|
-
// renders here; with the docs-blog module its `blog/[[...slug]]` directory
|
|
13
|
-
// wins and the teaser file is inert (#5469 D3).
|
|
14
|
-
//
|
|
15
|
-
// Two content types, in a fixed order: `LandingPage` first (the coined
|
|
16
|
-
// slug-keyed landing surface whose builder emits a `WebPage` envelope), then
|
|
17
|
-
// `BlogList` — the one list type that cannot have a route directory of its
|
|
18
|
-
// own, because the docs-blog module owns `blog/` (`blog/[[...slug]]`) and
|
|
19
|
-
// Next.js refuses a `blog/page.tsx` beside an optional catch-all. So the
|
|
20
|
-
// Free `/blog` teaser is a `BlogList` page (schema `Blog` + an empty
|
|
21
|
-
// `ItemList` — the correct page type, not a LandingPage wearing a `schema:`
|
|
22
|
-
// override the structured-data gate rejects) served here, and still yields
|
|
23
|
-
// to the module's directory by the same precedence. Every other list type
|
|
24
|
-
// has its own route directory (`/features` → ProductsList, `/for` →
|
|
25
|
-
// UseCasesList) and never reaches this route.
|
|
26
|
-
//
|
|
27
|
-
// Unknown slug → `notFound()` (renderPage's own detail-route branch: no
|
|
28
|
-
// `translationsNamespace` is passed, so a null source 404s rather than
|
|
29
|
-
// rendering an empty-state placeholder).
|
|
30
|
-
//
|
|
31
|
-
// Deliberately NO `generateStaticParams`: the locale layout reads cookies()
|
|
32
|
-
// and headers() (theme, session), so every route under it renders on
|
|
33
|
-
// request. A static-params export would make Next try to prerender this
|
|
34
|
-
// segment and fail any slug outside the build-time list with
|
|
35
|
-
// DYNAMIC_SERVER_USAGE (a 500, not the 404 an unknown slug must get).
|
|
36
|
-
import type { getMdxSource as defaultGetMdxSource } from "@working-theory/page-renderer";
|
|
37
|
-
import {
|
|
38
|
-
getMdxSource as loadMdxSource,
|
|
39
|
-
renderPage,
|
|
40
|
-
renderPageMetadata,
|
|
41
|
-
} from "@working-theory/page-renderer";
|
|
42
|
-
import type { Metadata } from "next";
|
|
43
|
-
import type { ReactElement } from "react";
|
|
44
|
-
|
|
45
|
-
import { honourNavOnly } from "../../../lib/hub-children";
|
|
46
|
-
|
|
47
|
-
// The content type is written as a literal in both renderPage calls below
|
|
48
|
-
// (not a shared constant): `lib/__tests__/structured-data.test.tsx` and
|
|
49
|
-
// tools/lint-check-content-renders.ts read `renderPage({ type: "…" })` off
|
|
50
|
-
// the source to know which content this route emits JSON-LD for.
|
|
51
|
-
|
|
52
|
-
interface Props {
|
|
53
|
-
params: Promise<{ locale: string; slug: string }>;
|
|
54
|
-
/** Test-only DI override for getMdxSource. Production callers leave undefined. */
|
|
55
|
-
getMdxSource?: typeof defaultGetMdxSource;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Which of the two content types carries this slug. `LandingPage` wins when
|
|
60
|
-
* it exists; `BlogList` is probed only when it does not, so a LandingPage
|
|
61
|
-
* slug never pays a second adapter read. Neither → `LandingPage`, whose null
|
|
62
|
-
* source is what makes renderPage 404.
|
|
63
|
-
*/
|
|
64
|
-
async function resolveType(
|
|
65
|
-
slug: string,
|
|
66
|
-
locale: string,
|
|
67
|
-
getMdxSource: typeof defaultGetMdxSource,
|
|
68
|
-
): Promise<"LandingPage" | "BlogList"> {
|
|
69
|
-
if ((await getMdxSource("LandingPage", slug, locale)) !== null) return "LandingPage";
|
|
70
|
-
if ((await getMdxSource("BlogList", slug, locale)) !== null) return "BlogList";
|
|
71
|
-
return "LandingPage";
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export async function generateMetadata({
|
|
75
|
-
params,
|
|
76
|
-
getMdxSource,
|
|
77
|
-
}: Pick<Props, "params" | "getMdxSource">): Promise<Metadata> {
|
|
78
|
-
const { locale, slug } = await params;
|
|
79
|
-
const load = getMdxSource ?? loadMdxSource;
|
|
80
|
-
const type = await resolveType(slug, locale, load);
|
|
81
|
-
return renderPageMetadata({ type, slug, locale });
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export default async function Page({
|
|
85
|
-
params,
|
|
86
|
-
getMdxSource,
|
|
87
|
-
}: Props): Promise<ReactElement> {
|
|
88
|
-
const { locale, slug } = await params;
|
|
89
|
-
const load = getMdxSource ?? loadMdxSource;
|
|
90
|
-
const type = await resolveType(slug, locale, load);
|
|
91
|
-
if (type === "BlogList") {
|
|
92
|
-
const source = await load("BlogList", slug, locale);
|
|
93
|
-
honourNavOnly(source?.frontmatter, locale, []);
|
|
94
|
-
return renderPage({
|
|
95
|
-
type: "BlogList",
|
|
96
|
-
slug,
|
|
97
|
-
locale,
|
|
98
|
-
populatedDescriptionTestId: `${slug}-description`,
|
|
99
|
-
...(getMdxSource !== undefined && { getMdxSource }),
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
return renderPage({
|
|
103
|
-
type: "LandingPage",
|
|
104
|
-
slug,
|
|
105
|
-
locale,
|
|
106
|
-
populatedDescriptionTestId: `${slug}-description`,
|
|
107
|
-
...(getMdxSource !== undefined && { getMdxSource }),
|
|
108
|
-
});
|
|
109
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
// A person's own page (#8650 D3). Reads the Person MDX for the given slug and
|
|
2
|
-
// emits a JSON-LD <script>. Unknown slugs 404 through renderPage. Renders
|
|
3
|
-
// `sections[]` when the frontmatter carries them (the /for composed
|
|
4
|
-
// pattern), MDX prose otherwise.
|
|
5
|
-
import {
|
|
6
|
-
getMdxSource as defaultGetMdxSource,
|
|
7
|
-
renderPage,
|
|
8
|
-
renderPageMetadata,
|
|
9
|
-
} from "@working-theory/page-renderer";
|
|
10
|
-
import type { Metadata } from "next";
|
|
11
|
-
import type { ReactElement } from "react";
|
|
12
|
-
|
|
13
|
-
interface Props {
|
|
14
|
-
params: Promise<{ locale: string; slug: string }>;
|
|
15
|
-
getMdxSource?: typeof defaultGetMdxSource;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export async function generateMetadata({
|
|
19
|
-
params,
|
|
20
|
-
}: Pick<Props, "params">): Promise<Metadata> {
|
|
21
|
-
const { locale, slug } = await params;
|
|
22
|
-
return renderPageMetadata({ type: "Person", slug, locale });
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export default async function Page({
|
|
26
|
-
params,
|
|
27
|
-
getMdxSource = defaultGetMdxSource,
|
|
28
|
-
}: Props): Promise<ReactElement> {
|
|
29
|
-
const { locale, slug } = await params;
|
|
30
|
-
// Read once to pick the body mode. A null source still goes to renderPage,
|
|
31
|
-
// which owns the unknown-slug branch (#7537).
|
|
32
|
-
const source = await getMdxSource("Person", slug, locale);
|
|
33
|
-
|
|
34
|
-
const composed =
|
|
35
|
-
source !== null &&
|
|
36
|
-
Array.isArray((source.frontmatter as { sections?: unknown[] }).sections) &&
|
|
37
|
-
((source.frontmatter as { sections?: unknown[] }).sections?.length ?? 0) > 0;
|
|
38
|
-
|
|
39
|
-
return renderPage({
|
|
40
|
-
type: "Person",
|
|
41
|
-
slug,
|
|
42
|
-
locale,
|
|
43
|
-
...(composed ? {} : { bodyMode: "mdx-body" as const }),
|
|
44
|
-
getMdxSource: async () => source,
|
|
45
|
-
});
|
|
46
|
-
}
|
|
@@ -1,353 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The about routes (#8650 spec, AC-1 through AC-4):
|
|
3
|
-
*
|
|
4
|
-
* - AC-1: `/about/<slug>` renders a `ProfilePage` whose `mainEntity` is a
|
|
5
|
-
* `Person`, valid under the schema validator, with an About breadcrumb; an
|
|
6
|
-
* unknown slug 404s through `renderPage`.
|
|
7
|
-
* - AC-2: `/about` lists every `Person` page as a generated `team` section,
|
|
8
|
-
* each member linking to its own `/about/<slug>` page, before a trailing
|
|
9
|
-
* `cta` section.
|
|
10
|
-
* - AC-3: the routes map, sitemap and `llms.txt` all advertise a `Person`
|
|
11
|
-
* page at `/about/<slug>`, never a bare `/<slug>`.
|
|
12
|
-
* - AC-4: with zero `Person` pages, `/about` renders byte-identical to
|
|
13
|
-
* calling `renderPage` directly (C5 — a fresh scaffold is such a site).
|
|
14
|
-
*
|
|
15
|
-
* MDX sources are inline stubs (no fs reads) for AC-2/AC-4, and a real
|
|
16
|
-
* `createMdxAdapter` over a temp content root for AC-1 (the spec's own
|
|
17
|
-
* method) — both run unchanged inside a scaffold.
|
|
18
|
-
*/
|
|
19
|
-
import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
|
|
20
|
-
import { tmpdir } from "node:os";
|
|
21
|
-
import { join } from "node:path";
|
|
22
|
-
|
|
23
|
-
import { render } from "@testing-library/react";
|
|
24
|
-
import { createMdxAdapter } from "@working-theory/content-adapters";
|
|
25
|
-
import * as pageRenderer from "@working-theory/page-renderer";
|
|
26
|
-
import { validatePageGraph } from "@working-theory/schema-validator";
|
|
27
|
-
import React from "react";
|
|
28
|
-
|
|
29
|
-
jest.mock("next/navigation", () => ({
|
|
30
|
-
__esModule: true,
|
|
31
|
-
notFound: jest.fn(() => {
|
|
32
|
-
throw new Error("NEXT_NOT_FOUND");
|
|
33
|
-
}),
|
|
34
|
-
}));
|
|
35
|
-
|
|
36
|
-
jest.mock("next-mdx-remote/rsc", () => ({
|
|
37
|
-
__esModule: true,
|
|
38
|
-
MDXRemote: ({ source }: { source: string }) =>
|
|
39
|
-
React.createElement("div", { "data-testid": "mdx-rendered" }, source),
|
|
40
|
-
}));
|
|
41
|
-
|
|
42
|
-
import AboutPage from "../page";
|
|
43
|
-
import AboutPersonPage from "../[slug]/page";
|
|
44
|
-
import { createSitemapHandler } from "../../../sitemap.xml/route";
|
|
45
|
-
import { createLlmsHandler } from "../../../llms.txt/route";
|
|
46
|
-
import type { ContentAdapter } from "@working-theory/content-adapters";
|
|
47
|
-
|
|
48
|
-
// #10704 — a fixture suite: its content is shaped for the mdx source, whatever the site serves from.
|
|
49
|
-
process.env.CONTENT_ADAPTER = "mdx";
|
|
50
|
-
|
|
51
|
-
type JsonLd = Record<string, unknown>;
|
|
52
|
-
|
|
53
|
-
function jsonLdScripts(container: HTMLElement): JsonLd[] {
|
|
54
|
-
return [
|
|
55
|
-
...container.querySelectorAll("script[type='application/ld+json']"),
|
|
56
|
-
].map((s) => JSON.parse(s.textContent ?? "") as JsonLd);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
describe("about/[slug] — a person's own page (AC-1)", () => {
|
|
60
|
-
let root: string;
|
|
61
|
-
|
|
62
|
-
beforeAll(() => {
|
|
63
|
-
root = mkdtempSync(join(tmpdir(), "ailk-8650-"));
|
|
64
|
-
mkdirSync(join(root, "en", "Person"), { recursive: true });
|
|
65
|
-
writeFileSync(
|
|
66
|
-
join(root, "en", "Person", "sam-henry.mdx"),
|
|
67
|
-
[
|
|
68
|
-
"---",
|
|
69
|
-
"type: Person",
|
|
70
|
-
"slug: sam-henry",
|
|
71
|
-
"title: Sam Henry",
|
|
72
|
-
"description: Co-founder and partner.",
|
|
73
|
-
"schema:",
|
|
74
|
-
" jobTitle: Partner",
|
|
75
|
-
"---",
|
|
76
|
-
"",
|
|
77
|
-
"Sam Henry, co-founder and partner.",
|
|
78
|
-
"",
|
|
79
|
-
].join("\n"),
|
|
80
|
-
);
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
afterAll(() => {
|
|
84
|
-
rmSync(root, { recursive: true, force: true });
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it("emits one ProfilePage graph whose Person carries @id #person, valid under the schema validator", async () => {
|
|
88
|
-
const adapter = createMdxAdapter({ contentRoot: root, defaultLocale: "en" });
|
|
89
|
-
const element = await AboutPersonPage({
|
|
90
|
-
params: Promise.resolve({ locale: "en", slug: "sam-henry" }),
|
|
91
|
-
getMdxSource: (type, slug, locale) =>
|
|
92
|
-
adapter.getPageSource(type, slug, locale),
|
|
93
|
-
});
|
|
94
|
-
const { container } = render(element);
|
|
95
|
-
const scripts = jsonLdScripts(container);
|
|
96
|
-
expect(scripts).toHaveLength(1);
|
|
97
|
-
const graph = scripts[0]!["@graph"] as JsonLd[];
|
|
98
|
-
expect(validatePageGraph(graph as never, "Person")).toEqual(
|
|
99
|
-
expect.objectContaining({ valid: true }),
|
|
100
|
-
);
|
|
101
|
-
|
|
102
|
-
const profile = graph.find((b) => b["@type"] === "ProfilePage")!;
|
|
103
|
-
const person = profile["mainEntity"] as JsonLd;
|
|
104
|
-
expect(person["@type"]).toBe("Person");
|
|
105
|
-
expect(person["@id"]).toBe("#person");
|
|
106
|
-
expect(person["name"]).toBe("Sam Henry");
|
|
107
|
-
expect(person["jobTitle"]).toBe("Partner");
|
|
108
|
-
|
|
109
|
-
const breadcrumb = graph.find((b) => b["@type"] === "BreadcrumbList")!;
|
|
110
|
-
const items = breadcrumb["itemListElement"] as Array<{ item: string }>;
|
|
111
|
-
expect(items[1]!.item).toMatch(/\/en\/about$/);
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it("404s an unknown slug through renderPage, with no translations namespace", async () => {
|
|
115
|
-
const renderPageSpy = jest.spyOn(pageRenderer, "renderPage");
|
|
116
|
-
const adapter = createMdxAdapter({ contentRoot: root, defaultLocale: "en" });
|
|
117
|
-
await expect(
|
|
118
|
-
AboutPersonPage({
|
|
119
|
-
params: Promise.resolve({ locale: "en", slug: "nobody" }),
|
|
120
|
-
getMdxSource: (type, slug, locale) =>
|
|
121
|
-
adapter.getPageSource(type, slug, locale),
|
|
122
|
-
}),
|
|
123
|
-
).rejects.toThrow("NEXT_NOT_FOUND");
|
|
124
|
-
expect(renderPageSpy).toHaveBeenCalledTimes(1);
|
|
125
|
-
expect(
|
|
126
|
-
renderPageSpy.mock.calls[0]![0].translationsNamespace,
|
|
127
|
-
).toBeUndefined();
|
|
128
|
-
renderPageSpy.mockRestore();
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
const ABOUT_WITH_CTA = {
|
|
133
|
-
frontmatter: {
|
|
134
|
-
type: "AboutPage",
|
|
135
|
-
slug: "about",
|
|
136
|
-
title: "About",
|
|
137
|
-
description: "About us.",
|
|
138
|
-
sections: [
|
|
139
|
-
{
|
|
140
|
-
id: "intro",
|
|
141
|
-
type: "content-block",
|
|
142
|
-
data: { headline: "About us", body: "We build things." },
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
id: "closing",
|
|
146
|
-
type: "cta",
|
|
147
|
-
data: {
|
|
148
|
-
headline: "Let's talk",
|
|
149
|
-
primaryCta: { label: "Contact us", href: "/contact" },
|
|
150
|
-
},
|
|
151
|
-
},
|
|
152
|
-
],
|
|
153
|
-
},
|
|
154
|
-
body: "",
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
const SAM_SOURCE = {
|
|
158
|
-
frontmatter: {
|
|
159
|
-
type: "Person",
|
|
160
|
-
slug: "sam-henry",
|
|
161
|
-
title: "Sam Henry",
|
|
162
|
-
description: "Co-founder and partner.",
|
|
163
|
-
schema: { jobTitle: "Partner" },
|
|
164
|
-
},
|
|
165
|
-
body: "",
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
const WENDI_SOURCE = {
|
|
169
|
-
frontmatter: {
|
|
170
|
-
type: "Person",
|
|
171
|
-
slug: "wendi-henry",
|
|
172
|
-
title: "About Wendi",
|
|
173
|
-
description: "Co-founder and partner.",
|
|
174
|
-
schema: { name: "Wendi Henry" },
|
|
175
|
-
},
|
|
176
|
-
body: "",
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
describe("about — the generated people list (AC-2)", () => {
|
|
180
|
-
it("lists every Person page as one team section, before the closing cta, linking to /about/<slug>", async () => {
|
|
181
|
-
const getMdxSource = jest.fn(
|
|
182
|
-
async (type: string, slug: string): Promise<unknown> => {
|
|
183
|
-
if (type === "AboutPage") return ABOUT_WITH_CTA;
|
|
184
|
-
if (type === "Person" && slug === "sam-henry") return SAM_SOURCE;
|
|
185
|
-
if (type === "Person" && slug === "wendi-henry") return WENDI_SOURCE;
|
|
186
|
-
return null;
|
|
187
|
-
},
|
|
188
|
-
);
|
|
189
|
-
const getMdxSlugs = jest
|
|
190
|
-
.fn()
|
|
191
|
-
.mockResolvedValue(["wendi-henry", "sam-henry", "ghost-member"]);
|
|
192
|
-
|
|
193
|
-
const element = await AboutPage({
|
|
194
|
-
params: Promise.resolve({ locale: "en" }),
|
|
195
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- test double over a narrower DI surface than the real multi-type loader
|
|
196
|
-
getMdxSource: getMdxSource as any,
|
|
197
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- test double
|
|
198
|
-
getMdxSlugs: getMdxSlugs as any,
|
|
199
|
-
});
|
|
200
|
-
const { container } = render(element);
|
|
201
|
-
|
|
202
|
-
const cards = container.querySelectorAll('[data-testid="team-member-card"]');
|
|
203
|
-
// The null-source "ghost-member" slug is skipped — two cards, not three.
|
|
204
|
-
expect(cards).toHaveLength(2);
|
|
205
|
-
|
|
206
|
-
const links = container.querySelectorAll('[data-testid^="member-page-link-"]');
|
|
207
|
-
const hrefs = [...links].map((l) => l.getAttribute("href"));
|
|
208
|
-
expect(hrefs).toEqual(["/about/sam-henry", "/about/wendi-henry"]);
|
|
209
|
-
for (const link of links) {
|
|
210
|
-
expect(link.textContent).toBe("View profile");
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
// Wendi's card shows schema.name, not title; Sam's shows title (no
|
|
214
|
-
// schema.name override) with his jobTitle as the role.
|
|
215
|
-
expect(cards[0]!.textContent).toContain("Sam Henry");
|
|
216
|
-
expect(cards[0]!.textContent).toContain("Partner");
|
|
217
|
-
expect(cards[1]!.textContent).toContain("Wendi Henry");
|
|
218
|
-
expect(cards[1]!.textContent).not.toContain("About Wendi");
|
|
219
|
-
expect(cards[1]!.textContent).not.toContain("Partner");
|
|
220
|
-
|
|
221
|
-
// The team section sits before the closing cta section in document order.
|
|
222
|
-
const html = container.innerHTML;
|
|
223
|
-
expect(html.indexOf("team-member-card")).toBeLessThan(
|
|
224
|
-
html.indexOf("Let's talk"),
|
|
225
|
-
);
|
|
226
|
-
});
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
describe("about — unchanged with zero Person pages (AC-4, C5)", () => {
|
|
230
|
-
it("renders byte-identical to a direct renderPage call", async () => {
|
|
231
|
-
const aboutSource = {
|
|
232
|
-
frontmatter: {
|
|
233
|
-
type: "AboutPage",
|
|
234
|
-
slug: "about",
|
|
235
|
-
title: "About",
|
|
236
|
-
description: "About us.",
|
|
237
|
-
},
|
|
238
|
-
body: "About us copy.",
|
|
239
|
-
};
|
|
240
|
-
const getMdxSource = jest.fn().mockResolvedValue(aboutSource);
|
|
241
|
-
const getMdxSlugs = jest.fn().mockResolvedValue([]);
|
|
242
|
-
|
|
243
|
-
const element = await AboutPage({
|
|
244
|
-
params: Promise.resolve({ locale: "en" }),
|
|
245
|
-
getMdxSource,
|
|
246
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- test double over a narrower DI surface than the real multi-type loader
|
|
247
|
-
getMdxSlugs: getMdxSlugs as any,
|
|
248
|
-
});
|
|
249
|
-
const { container } = render(element);
|
|
250
|
-
|
|
251
|
-
const direct = await pageRenderer.renderPage({
|
|
252
|
-
type: "AboutPage",
|
|
253
|
-
slug: "about",
|
|
254
|
-
locale: "en",
|
|
255
|
-
translationsNamespace: "about",
|
|
256
|
-
getMdxSource,
|
|
257
|
-
});
|
|
258
|
-
const { container: directContainer } = render(direct);
|
|
259
|
-
|
|
260
|
-
expect(container.innerHTML).toBe(directContainer.innerHTML);
|
|
261
|
-
expect(
|
|
262
|
-
container.querySelectorAll('[data-testid="team-member-card"]'),
|
|
263
|
-
).toHaveLength(0);
|
|
264
|
-
});
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
describe("the sitemap and llms.txt advertise /about/<slug>, never a bare /<slug> (AC-3)", () => {
|
|
268
|
-
// The route handlers construct a Web `Response`, which jsdom (this file's
|
|
269
|
-
// test environment, needed by the React-rendering describes above) does
|
|
270
|
-
// not implement. A minimal same-shape stand-in, scoped to this describe,
|
|
271
|
-
// is enough for the one method these tests call: `.text()`.
|
|
272
|
-
let originalResponse: unknown;
|
|
273
|
-
|
|
274
|
-
beforeAll(() => {
|
|
275
|
-
originalResponse = (globalThis as { Response?: unknown }).Response;
|
|
276
|
-
class ResponseShim {
|
|
277
|
-
private readonly _body: string;
|
|
278
|
-
constructor(body: string, _init?: unknown) {
|
|
279
|
-
this._body = body;
|
|
280
|
-
}
|
|
281
|
-
async text(): Promise<string> {
|
|
282
|
-
return this._body;
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
(globalThis as { Response: unknown }).Response = ResponseShim;
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
afterAll(() => {
|
|
289
|
-
(globalThis as { Response?: unknown }).Response = originalResponse;
|
|
290
|
-
});
|
|
291
|
-
|
|
292
|
-
function makeStubAdapter(): ContentAdapter {
|
|
293
|
-
// eslint-disable-next-line no-restricted-syntax -- jest.fn() stubs are not assignable to ContentAdapter's generic return types; partial stub is intentional, tracked in #1073
|
|
294
|
-
return {
|
|
295
|
-
listPages: jest.fn().mockImplementation(async (type: string) => {
|
|
296
|
-
if (type === "Person") {
|
|
297
|
-
return [
|
|
298
|
-
{
|
|
299
|
-
type: "Person",
|
|
300
|
-
slug: "sam-henry",
|
|
301
|
-
title: "Sam Henry",
|
|
302
|
-
description: "Co-founder and partner.",
|
|
303
|
-
},
|
|
304
|
-
];
|
|
305
|
-
}
|
|
306
|
-
return [];
|
|
307
|
-
}),
|
|
308
|
-
listDetail: jest.fn().mockResolvedValue([]),
|
|
309
|
-
getPageBySlug: jest.fn().mockResolvedValue(null),
|
|
310
|
-
getDetailBySlug: jest.fn().mockResolvedValue(null),
|
|
311
|
-
searchPages: jest.fn().mockResolvedValue([]),
|
|
312
|
-
extractStructuredData: jest.fn().mockResolvedValue(null),
|
|
313
|
-
createPage: jest.fn(),
|
|
314
|
-
updatePage: jest.fn(),
|
|
315
|
-
deletePage: jest.fn(),
|
|
316
|
-
getPageVersion: jest.fn(),
|
|
317
|
-
} as unknown as ContentAdapter;
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
beforeEach(() => {
|
|
321
|
-
process.env.NEXT_PUBLIC_ENABLED_LOCALES = "en";
|
|
322
|
-
process.env.NEXT_PUBLIC_DEFAULT_LOCALE = "en";
|
|
323
|
-
process.env.NEXT_PUBLIC_BASE_URL = "https://site.example";
|
|
324
|
-
});
|
|
325
|
-
|
|
326
|
-
afterEach(() => {
|
|
327
|
-
delete process.env.NEXT_PUBLIC_ENABLED_LOCALES;
|
|
328
|
-
delete process.env.NEXT_PUBLIC_DEFAULT_LOCALE;
|
|
329
|
-
delete process.env.NEXT_PUBLIC_BASE_URL;
|
|
330
|
-
jest.resetAllMocks();
|
|
331
|
-
});
|
|
332
|
-
|
|
333
|
-
it("sitemap.xml: one <loc> ending in /about/sam-henry, none ending in a bare /sam-henry", async () => {
|
|
334
|
-
const stubAdapter = makeStubAdapter();
|
|
335
|
-
const GET = createSitemapHandler({ getContentAdapter: () => stubAdapter, getDocsPages: () => [], discoverable: async () => true });
|
|
336
|
-
const response = await GET();
|
|
337
|
-
const text = await response.text();
|
|
338
|
-
const locs = Array.from(text.matchAll(/<loc>([^<]*)<\/loc>/g)).map(
|
|
339
|
-
(m) => m[1],
|
|
340
|
-
);
|
|
341
|
-
expect(locs).toContain("https://site.example/about/sam-henry");
|
|
342
|
-
expect(locs).not.toContain("https://site.example/sam-henry");
|
|
343
|
-
});
|
|
344
|
-
|
|
345
|
-
it("llms.txt: names a URL ending in /about/sam-henry", async () => {
|
|
346
|
-
const stubAdapter = makeStubAdapter();
|
|
347
|
-
const GET = createLlmsHandler({ getContentAdapter: () => stubAdapter, getDocsPages: () => [], discoverable: async () => true });
|
|
348
|
-
const response = await GET();
|
|
349
|
-
const text = await response.text();
|
|
350
|
-
expect(text).toContain("URL: https://site.example/about/sam-henry");
|
|
351
|
-
expect(text).not.toContain("URL: https://site.example/sam-henry\n");
|
|
352
|
-
});
|
|
353
|
-
});
|