create-ailk 0.39.0 → 0.40.1
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/component-catalog.json +1 -1
- package/component-catalog.md +1 -1
- 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 +19 -2
- 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 +42 -25
- package/templates/apps/web/app/api/revalidate/__tests__/route.test.ts +56 -1
- package/templates/apps/web/app/api/revalidate/route.ts +45 -4
- package/templates/apps/web/app/llms.txt/__tests__/site-listing.test.ts +53 -0
- package/templates/apps/web/app/llms.txt/route.ts +5 -2
- 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__/hub-site-config.test.ts +239 -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__/profile-back-link.test.ts +58 -0
- package/templates/apps/web/lib/__tests__/served-pages.test.ts +163 -20
- package/templates/apps/web/lib/__tests__/site-brand.test.ts +77 -0
- package/templates/apps/web/{app/[locale]/contact → lib}/__tests__/site-contact-lines.test.ts +64 -0
- package/templates/apps/web/lib/__tests__/site-identity-feature-list.test.ts +115 -3
- package/templates/apps/web/lib/__tests__/structured-data.test.tsx +17 -4
- package/templates/apps/web/lib/hub-site-config.ts +151 -0
- 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/lib/profile-back-link.ts +49 -12
- package/templates/apps/web/lib/served-pages.ts +144 -39
- package/templates/apps/web/lib/site-brand.tsx +66 -0
- package/templates/apps/web/{app/[locale]/contact → lib}/site-contact-email.ts +25 -5
- package/templates/apps/web/{app/[locale]/contact → lib}/site-contact-lines.ts +21 -5
- package/templates/apps/web/lib/site-header.ts +1 -1
- package/templates/apps/web/lib/site-identity.ts +38 -2
- package/templates/apps/web/messages/en.json +3 -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
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* /[locale]/unsubscribe — the one unsubscribe landing every signed link
|
|
3
|
-
* calls (#8438 D17, NEW). Public, `noindex`, `referrer: no-referrer` so the
|
|
4
|
-
* `?t=` token never leaks through a Referer header off this page (D17,
|
|
5
|
-
* SEC-8438-9).
|
|
6
|
-
*
|
|
7
|
-
* RSC: reads `?t=` and renders the heading, the line and the one
|
|
8
|
-
* interactive piece (`UnsubscribeButton`, "use client") that posts
|
|
9
|
-
* `unsubscribeAction(token)` ON CLICK — never on this GET, so a mail
|
|
10
|
-
* scanner's prefetch writes nothing. The island gets the token and three
|
|
11
|
-
* strings: anything callable handed across this server→client edge fails
|
|
12
|
-
* Flight serialization (the scaffold matrix's `GET /unsubscribe -> 500`;
|
|
13
|
-
* `__tests__/unsubscribe-rsc-boundary.test.tsx`).
|
|
14
|
-
*
|
|
15
|
-
* #8847 D12 — the title, line, button and done message come from the
|
|
16
|
-
* newsletter magnet's `unsubscribe` block (`readServedMagnet`, shared like
|
|
17
|
-
* /contact's read), else the seeded `newsletterFlowConfig`'s. The token states
|
|
18
|
-
* (already, invalid, unavailable) keep their catalog lines: they describe
|
|
19
|
-
* the link, not the newsletter. The frame is /contact's `column` look. The
|
|
20
|
-
* page renders on every request.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
import { SectionFrame } from "@working-theory/ui";
|
|
24
|
-
import { Heading, Text } from "@working-theory/ui/primitives";
|
|
25
|
-
import {
|
|
26
|
-
NEWSLETTER_FLOW_SLUG,
|
|
27
|
-
newsletterFlowConfig,
|
|
28
|
-
resolveLocalizedString,
|
|
29
|
-
type FlowUnsubscribeCopy,
|
|
30
|
-
} from "@working-theory/validation";
|
|
31
|
-
import type { Metadata } from "next";
|
|
32
|
-
import type { ReactElement } from "react";
|
|
33
|
-
|
|
34
|
-
import { readServedMagnet } from "../../../lib/in-page-magnet";
|
|
35
|
-
|
|
36
|
-
import { UnsubscribeButton } from "./unsubscribe-button";
|
|
37
|
-
|
|
38
|
-
export const dynamic = "force-dynamic";
|
|
39
|
-
|
|
40
|
-
interface Props {
|
|
41
|
-
params: Promise<{ locale: string }>;
|
|
42
|
-
searchParams: Promise<{ t?: string }>;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
interface UnsubscribeCopy {
|
|
46
|
-
title: string;
|
|
47
|
-
body?: string;
|
|
48
|
-
cta: string;
|
|
49
|
-
doneHeadline: string;
|
|
50
|
-
doneBody?: string;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/** The newsletter magnet's unsubscribe copy, else the seeded config's. */
|
|
54
|
-
async function unsubscribeCopy(locale: string): Promise<UnsubscribeCopy> {
|
|
55
|
-
const served = await readServedMagnet(NEWSLETTER_FLOW_SLUG);
|
|
56
|
-
const config = served?.unsubscribe ? served : newsletterFlowConfig;
|
|
57
|
-
const block = config.unsubscribe as FlowUnsubscribeCopy;
|
|
58
|
-
const resolve = (value: Record<string, string>): string =>
|
|
59
|
-
resolveLocalizedString(value, locale, config.defaultLocale);
|
|
60
|
-
return {
|
|
61
|
-
title: resolve(block.title),
|
|
62
|
-
...(block.body !== undefined && { body: resolve(block.body) }),
|
|
63
|
-
cta: resolve(block.cta),
|
|
64
|
-
doneHeadline: resolve(block.done.headline),
|
|
65
|
-
...(block.done.body !== undefined && { doneBody: resolve(block.done.body) }),
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
|
70
|
-
const { locale } = await params;
|
|
71
|
-
const copy = await unsubscribeCopy(locale);
|
|
72
|
-
return {
|
|
73
|
-
title: copy.title,
|
|
74
|
-
robots: { index: false, follow: true },
|
|
75
|
-
referrer: "no-referrer",
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export default async function UnsubscribePage({ params, searchParams }: Props): Promise<ReactElement> {
|
|
80
|
-
const { locale } = await params;
|
|
81
|
-
const { t: token } = await searchParams;
|
|
82
|
-
const copy = await unsubscribeCopy(locale);
|
|
83
|
-
|
|
84
|
-
return (
|
|
85
|
-
<SectionFrame sectionId="unsubscribe" className="ailk-contact-frame" data-testid="unsubscribe-page">
|
|
86
|
-
<div className="ailk-contact-column text-center">
|
|
87
|
-
<Heading level={1} visual="display" className="ailk-contact-heading text-center">
|
|
88
|
-
{copy.title}
|
|
89
|
-
</Heading>
|
|
90
|
-
{copy.body !== undefined && (
|
|
91
|
-
<Text as="p" tone="muted" className="mx-auto mt-block-tight ailk-contact-measure text-balance">
|
|
92
|
-
{copy.body}
|
|
93
|
-
</Text>
|
|
94
|
-
)}
|
|
95
|
-
<div className="ailk-contact-slot mx-auto mt-block-loose flex w-full ailk-contact-measure flex-col items-center">
|
|
96
|
-
<UnsubscribeButton
|
|
97
|
-
token={token ?? null}
|
|
98
|
-
cta={copy.cta}
|
|
99
|
-
doneHeadline={copy.doneHeadline}
|
|
100
|
-
{...(copy.doneBody !== undefined && { doneBody: copy.doneBody })}
|
|
101
|
-
/>
|
|
102
|
-
</div>
|
|
103
|
-
</div>
|
|
104
|
-
</SectionFrame>
|
|
105
|
-
);
|
|
106
|
-
}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
"use client"; // owns the click → unsubscribeAction → result state
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* UnsubscribeButton — the unsubscribe page's one interactive piece (#8438
|
|
5
|
-
* D17). Posts `unsubscribeAction(token)` on click only — never on render,
|
|
6
|
-
* so a mail scanner's GET prefetch of the page writes nothing.
|
|
7
|
-
*
|
|
8
|
-
* The button label and the done message are the newsletter magnet's
|
|
9
|
-
* (#8847 D12), passed as STRINGS: a formatting FUNCTION handed across from the
|
|
10
|
-
* page (a Server Component) cannot be serialized into the Flight payload —
|
|
11
|
-
* the scaffold matrix's `GET /unsubscribe -> 500`
|
|
12
|
-
* (`unsubscribe-rsc-boundary.test.tsx` holds the regression). The token
|
|
13
|
-
* states (invalid, already, unavailable) read their own catalog lines
|
|
14
|
-
* through `useTranslations`.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import { Button, InlineMessage } from "@working-theory/ui/primitives";
|
|
18
|
-
import { useTranslations } from "next-intl";
|
|
19
|
-
import { useState, useTransition, type ReactElement } from "react";
|
|
20
|
-
|
|
21
|
-
import { unsubscribeAction, type UnsubscribeResult } from "./unsubscribe.actions";
|
|
22
|
-
|
|
23
|
-
interface UnsubscribeButtonProps {
|
|
24
|
-
token: string | null;
|
|
25
|
-
/** The button label (the magnet's `unsubscribe.cta`). */
|
|
26
|
-
cta: string;
|
|
27
|
-
/** The done message (the magnet's `unsubscribe.done`). */
|
|
28
|
-
doneHeadline: string;
|
|
29
|
-
doneBody?: string;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function UnsubscribeButton({
|
|
33
|
-
token,
|
|
34
|
-
cta,
|
|
35
|
-
doneHeadline,
|
|
36
|
-
doneBody,
|
|
37
|
-
}: UnsubscribeButtonProps): ReactElement {
|
|
38
|
-
const t = useTranslations("unsubscribe");
|
|
39
|
-
const [result, setResult] = useState<UnsubscribeResult | null>(null);
|
|
40
|
-
const [pending, startTransition] = useTransition();
|
|
41
|
-
|
|
42
|
-
if (token === null || result?.kind === "invalid") {
|
|
43
|
-
return (
|
|
44
|
-
<InlineMessage variant="error" role="alert" data-testid="unsubscribe-invalid">
|
|
45
|
-
{t("invalid")}
|
|
46
|
-
</InlineMessage>
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (result?.kind === "done") {
|
|
51
|
-
return (
|
|
52
|
-
<InlineMessage variant="success" role="status" data-testid="unsubscribe-done">
|
|
53
|
-
{/* Headline over body, as the /contact ending stacks them (#8847 D12). */}
|
|
54
|
-
<span className="flex flex-col">
|
|
55
|
-
<span className="font-semibold" data-testid="unsubscribe-done-headline">
|
|
56
|
-
{doneHeadline}
|
|
57
|
-
</span>
|
|
58
|
-
{doneBody !== undefined && <span className="mt-1">{doneBody}</span>}
|
|
59
|
-
</span>
|
|
60
|
-
</InlineMessage>
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (result?.kind === "already") {
|
|
65
|
-
return (
|
|
66
|
-
<InlineMessage variant="success" role="status" data-testid="unsubscribe-already">
|
|
67
|
-
{t("already")}
|
|
68
|
-
</InlineMessage>
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (result?.kind === "unavailable") {
|
|
73
|
-
return (
|
|
74
|
-
<InlineMessage variant="error" role="alert" data-testid="unsubscribe-unavailable">
|
|
75
|
-
{t("unavailable")}
|
|
76
|
-
</InlineMessage>
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return (
|
|
81
|
-
<Button
|
|
82
|
-
type="button"
|
|
83
|
-
disabled={pending}
|
|
84
|
-
onClick={() => {
|
|
85
|
-
startTransition(async () => {
|
|
86
|
-
setResult(await unsubscribeAction(token));
|
|
87
|
-
});
|
|
88
|
-
}}
|
|
89
|
-
data-testid="unsubscribe-button"
|
|
90
|
-
>
|
|
91
|
-
{cta}
|
|
92
|
-
</Button>
|
|
93
|
-
);
|
|
94
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use server";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* unsubscribeAction — the unsubscribe page's one write (#8438 D9, D17).
|
|
5
|
-
*
|
|
6
|
-
* Calls `POST /v1/consent/unsubscribe` (`consent.unsubscribe`) through
|
|
7
|
-
* `@working-theory/api-client`, carrying the visitor-forward headers a
|
|
8
|
-
* spoke attaches today — the same idiom `contact.actions.ts` uses. Never
|
|
9
|
-
* writes anything on its own: the page's GET never calls this, so a mail
|
|
10
|
-
* scanner's prefetch of the link changes nothing (D17).
|
|
11
|
-
*
|
|
12
|
-
* The token is the only authority (D9) — this action never names an email,
|
|
13
|
-
* a workspace or a person.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
import { consent, visitorForwardHeaders } from "@working-theory/api-client";
|
|
17
|
-
import { headers } from "next/headers";
|
|
18
|
-
|
|
19
|
-
export type UnsubscribeResult =
|
|
20
|
-
| { kind: "done"; description: string }
|
|
21
|
-
| { kind: "already" }
|
|
22
|
-
| { kind: "invalid" }
|
|
23
|
-
| { kind: "unavailable" };
|
|
24
|
-
|
|
25
|
-
export async function unsubscribeAction(token: string): Promise<UnsubscribeResult> {
|
|
26
|
-
let init: { headers: Record<string, string> } | undefined;
|
|
27
|
-
try {
|
|
28
|
-
const forwarded = visitorForwardHeaders(
|
|
29
|
-
await headers(),
|
|
30
|
-
process.env.AILK_VISITOR_FORWARD_KEY,
|
|
31
|
-
);
|
|
32
|
-
if (forwarded) init = { headers: forwarded };
|
|
33
|
-
} catch {
|
|
34
|
-
// No request scope to read — call with no forwarding.
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
try {
|
|
38
|
-
const res = init
|
|
39
|
-
? await consent.unsubscribe({ token }, init)
|
|
40
|
-
: await consent.unsubscribe({ token });
|
|
41
|
-
if (!res.ok) {
|
|
42
|
-
// 429 is transient (a rate limit), never the token's fault — "invalid"
|
|
43
|
-
// would tell a visitor the link itself is bad when retrying would work.
|
|
44
|
-
if (res.status >= 400 && res.status < 500 && res.status !== 429) return { kind: "invalid" };
|
|
45
|
-
return { kind: "unavailable" };
|
|
46
|
-
}
|
|
47
|
-
if (!res.body.changed) return { kind: "already" };
|
|
48
|
-
return { kind: "done", description: res.body.purpose.description };
|
|
49
|
-
} catch (err) {
|
|
50
|
-
// The api-client never attaches the request payload to a thrown error,
|
|
51
|
-
// so logging `err` carries no token.
|
|
52
|
-
console.error("[unsubscribeAction]", err);
|
|
53
|
-
return { kind: "unavailable" };
|
|
54
|
-
}
|
|
55
|
-
}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for /vs/[slug] (#6878 D9) — the ComparisonPage detail route.
|
|
3
|
-
* `renderPage`/`renderPageMetadata` are mocked at the
|
|
4
|
-
* `@working-theory/page-renderer` boundary; `getMdxSource` is supplied
|
|
5
|
-
* per-call through the route's DI prop.
|
|
6
|
-
*/
|
|
7
|
-
// The mock return value is never rendered — every assertion below inspects
|
|
8
|
-
// `mockRenderPage.mock.calls` directly — so it carries no `ReactElement`
|
|
9
|
-
// cast; `renderPage`'s real return type is `Promise<ReactElement>` in
|
|
10
|
-
// production, unaffected by this mock's loose type here.
|
|
11
|
-
const mockRenderPage = jest.fn(async (..._args: unknown[]) => "<rendered/>");
|
|
12
|
-
const mockRenderPageMetadata = jest.fn((..._args: unknown[]) => undefined);
|
|
13
|
-
|
|
14
|
-
jest.mock("@working-theory/page-renderer", () => ({
|
|
15
|
-
__esModule: true,
|
|
16
|
-
renderPage: (...args: unknown[]) => mockRenderPage(...args),
|
|
17
|
-
renderPageMetadata: (...args: unknown[]) => mockRenderPageMetadata(...args),
|
|
18
|
-
getMdxSource: jest.fn(),
|
|
19
|
-
}));
|
|
20
|
-
|
|
21
|
-
import ComparisonPage, { generateMetadata } from "../page";
|
|
22
|
-
|
|
23
|
-
beforeEach(() => jest.clearAllMocks());
|
|
24
|
-
|
|
25
|
-
describe("ComparisonPage detail — metadata", () => {
|
|
26
|
-
it("resolves metadata for the given slug", async () => {
|
|
27
|
-
await generateMetadata({
|
|
28
|
-
params: Promise.resolve({ locale: "en", slug: "acme" }),
|
|
29
|
-
});
|
|
30
|
-
expect(mockRenderPageMetadata).toHaveBeenCalledWith({
|
|
31
|
-
type: "ComparisonPage",
|
|
32
|
-
slug: "acme",
|
|
33
|
-
locale: "en",
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
describe("ComparisonPage detail — sections vs mdx-body", () => {
|
|
39
|
-
it("renders in sections mode (D10: hero, decision-split, comparison-table, cta) when frontmatter carries sections", async () => {
|
|
40
|
-
const getMdxSource = jest.fn().mockResolvedValue({
|
|
41
|
-
frontmatter: {
|
|
42
|
-
type: "ComparisonPage",
|
|
43
|
-
slug: "acme",
|
|
44
|
-
title: "vs. Acme",
|
|
45
|
-
description: "How we compare to Acme.",
|
|
46
|
-
sections: [
|
|
47
|
-
{ id: "hero", type: "hero", data: {} },
|
|
48
|
-
{ id: "compare", type: "decision-split", data: {} },
|
|
49
|
-
{ id: "table", type: "comparison-table", data: {} },
|
|
50
|
-
{
|
|
51
|
-
id: "cta",
|
|
52
|
-
type: "cta",
|
|
53
|
-
data: { primaryCta: { label: "See all alternatives", href: "/alternatives" } },
|
|
54
|
-
},
|
|
55
|
-
],
|
|
56
|
-
},
|
|
57
|
-
body: "",
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
await ComparisonPage({
|
|
61
|
-
params: Promise.resolve({ locale: "en", slug: "acme" }),
|
|
62
|
-
getMdxSource,
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
const passedInput = mockRenderPage.mock.calls[0]?.[0] as {
|
|
66
|
-
type: string;
|
|
67
|
-
slug: string;
|
|
68
|
-
bodyMode?: string;
|
|
69
|
-
};
|
|
70
|
-
expect(passedInput.type).toBe("ComparisonPage");
|
|
71
|
-
expect(passedInput.slug).toBe("acme");
|
|
72
|
-
expect(passedInput.bodyMode).toBeUndefined();
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it("falls back to mdx-body mode for a prose-only comparison page", async () => {
|
|
76
|
-
const getMdxSource = jest.fn().mockResolvedValue({
|
|
77
|
-
frontmatter: {
|
|
78
|
-
type: "ComparisonPage",
|
|
79
|
-
slug: "acme",
|
|
80
|
-
title: "vs. Acme",
|
|
81
|
-
description: "How we compare to Acme.",
|
|
82
|
-
},
|
|
83
|
-
body: "Prose comparison.",
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
await ComparisonPage({
|
|
87
|
-
params: Promise.resolve({ locale: "en", slug: "acme" }),
|
|
88
|
-
getMdxSource,
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
const passedInput = mockRenderPage.mock.calls[0]?.[0] as {
|
|
92
|
-
bodyMode?: string;
|
|
93
|
-
populatedDescriptionTestId?: string;
|
|
94
|
-
};
|
|
95
|
-
expect(passedInput.bodyMode).toBe("mdx-body");
|
|
96
|
-
expect(passedInput.populatedDescriptionTestId).toBe(
|
|
97
|
-
"comparison-description",
|
|
98
|
-
);
|
|
99
|
-
});
|
|
100
|
-
});
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
// ComparisonPage detail (#6878 D9) — one head-to-head comparison at
|
|
2
|
-
// /vs/<slug>, listed by the /alternatives hub. Reads the ComparisonPage MDX
|
|
3
|
-
// for the given slug, renders via @working-theory/page-renderer, and emits a
|
|
4
|
-
// JSON-LD WebPage. Unknown slugs 404. Composed `sections[]` (D10 — the
|
|
5
|
-
// generic detail chassis, no dedicated comparison section: hero,
|
|
6
|
-
// decision-split, comparison-table, cta) render as sections; a prose page
|
|
7
|
-
// renders its MDX body — the same rule the /for detail page applies.
|
|
8
|
-
//
|
|
9
|
-
// Gated off by default (surfaces.ts `alternatives` surface): no roster names
|
|
10
|
-
// this route, so a fresh scaffold excludes it. `add-page` installs it (D11)
|
|
11
|
-
// the first time a site adds a comparison.
|
|
12
|
-
import type { getMdxSource as defaultGetMdxSource } from "@working-theory/page-renderer";
|
|
13
|
-
import {
|
|
14
|
-
getMdxSource as loadMdxSource,
|
|
15
|
-
renderPage,
|
|
16
|
-
renderPageMetadata,
|
|
17
|
-
} from "@working-theory/page-renderer";
|
|
18
|
-
import type { Metadata } from "next";
|
|
19
|
-
import type { ReactElement } from "react";
|
|
20
|
-
|
|
21
|
-
interface Props {
|
|
22
|
-
params: Promise<{ locale: string; slug: string }>;
|
|
23
|
-
getMdxSource?: typeof defaultGetMdxSource;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export async function generateMetadata({
|
|
27
|
-
params,
|
|
28
|
-
}: Pick<Props, "params">): Promise<Metadata> {
|
|
29
|
-
const { locale, slug } = await params;
|
|
30
|
-
return renderPageMetadata({ type: "ComparisonPage", slug, locale });
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export default async function Page({
|
|
34
|
-
params,
|
|
35
|
-
getMdxSource,
|
|
36
|
-
}: Props): Promise<ReactElement> {
|
|
37
|
-
const { locale, slug } = await params;
|
|
38
|
-
const source = await (getMdxSource ?? loadMdxSource)(
|
|
39
|
-
"ComparisonPage",
|
|
40
|
-
slug,
|
|
41
|
-
locale,
|
|
42
|
-
);
|
|
43
|
-
const composed =
|
|
44
|
-
source !== null &&
|
|
45
|
-
Array.isArray((source.frontmatter as { sections?: unknown[] }).sections) &&
|
|
46
|
-
((source.frontmatter as { sections?: unknown[] }).sections?.length ?? 0) >
|
|
47
|
-
0;
|
|
48
|
-
return renderPage({
|
|
49
|
-
type: "ComparisonPage",
|
|
50
|
-
slug,
|
|
51
|
-
locale,
|
|
52
|
-
...(composed
|
|
53
|
-
? {}
|
|
54
|
-
: {
|
|
55
|
-
bodyMode: "mdx-body" as const,
|
|
56
|
-
populatedDescriptionTestId: "comparison-description",
|
|
57
|
-
}),
|
|
58
|
-
...(getMdxSource !== undefined && { getMdxSource }),
|
|
59
|
-
});
|
|
60
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
// Whitepaper detail page. Reads the Whitepaper MDX for the given slug, renders via
|
|
2
|
-
// @working-theory/page-renderer, and emits a JSON-LD <script>. Unknown slugs trigger 404.
|
|
3
|
-
import type { getMdxSource as defaultGetMdxSource } from "@working-theory/page-renderer";
|
|
4
|
-
import {
|
|
5
|
-
getMdxSource as loadMdxSource,
|
|
6
|
-
renderPage,
|
|
7
|
-
renderPageMetadata,
|
|
8
|
-
} from "@working-theory/page-renderer";
|
|
9
|
-
import type { Metadata } from "next";
|
|
10
|
-
import type { ReactElement } from "react";
|
|
11
|
-
|
|
12
|
-
interface Props {
|
|
13
|
-
params: Promise<{ locale: string; slug: string }>;
|
|
14
|
-
getMdxSource?: typeof defaultGetMdxSource;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export async function generateMetadata({
|
|
18
|
-
params,
|
|
19
|
-
}: Pick<Props, "params">): Promise<Metadata> {
|
|
20
|
-
const { locale, slug } = await params;
|
|
21
|
-
return renderPageMetadata({ type: "Whitepaper", slug, locale });
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export default async function Page({
|
|
25
|
-
params,
|
|
26
|
-
getMdxSource,
|
|
27
|
-
}: Props): Promise<ReactElement> {
|
|
28
|
-
const { locale, slug } = await params;
|
|
29
|
-
// A page that composes `sections[]` renders them (JSON-LD is built from
|
|
30
|
-
// the same sections); a prose page renders its MDX body — the rule
|
|
31
|
-
// /vs/[slug] applies (#10122).
|
|
32
|
-
const source = await (getMdxSource ?? loadMdxSource)(
|
|
33
|
-
"Whitepaper",
|
|
34
|
-
slug,
|
|
35
|
-
locale,
|
|
36
|
-
);
|
|
37
|
-
const composed =
|
|
38
|
-
source !== null &&
|
|
39
|
-
Array.isArray((source.frontmatter as { sections?: unknown[] }).sections) &&
|
|
40
|
-
((source.frontmatter as { sections?: unknown[] }).sections?.length ?? 0) >
|
|
41
|
-
0;
|
|
42
|
-
return renderPage({
|
|
43
|
-
type: "Whitepaper",
|
|
44
|
-
slug,
|
|
45
|
-
locale,
|
|
46
|
-
...(composed
|
|
47
|
-
? {}
|
|
48
|
-
: {
|
|
49
|
-
bodyMode: "mdx-body" as const,
|
|
50
|
-
populatedDescriptionTestId: "whitepaper-description",
|
|
51
|
-
}),
|
|
52
|
-
...(getMdxSource !== undefined && { getMdxSource }),
|
|
53
|
-
});
|
|
54
|
-
}
|
package/templates/apps/web/app/[locale]/whitepapers/__tests__/page-renderer-migration.test.tsx
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HTML snapshot regression tests for whitepapers/[slug] — @working-theory/page-renderer migration.
|
|
3
|
-
*
|
|
4
|
-
* Node version: captured against Node 22.x (same as CI).
|
|
5
|
-
* MDX seed content: DI-injected stub — no fs reads, deterministic.
|
|
6
|
-
*
|
|
7
|
-
* Two-commit strategy:
|
|
8
|
-
* Commit 1: this file added; snapshots captured against pre-migration routes.
|
|
9
|
-
* Commit 2: routes migrated; same snapshots verify diff=0.
|
|
10
|
-
*
|
|
11
|
-
* Routes covered:
|
|
12
|
-
* - whitepapers/[slug] (populated: populated state)
|
|
13
|
-
* - whitepapers/[slug] (notFound: unknown slug triggers notFound())
|
|
14
|
-
*
|
|
15
|
-
* Note: whitepapers/page.tsx is a slug-listing route (not MDX-body); only the
|
|
16
|
-
* import path changes. No snapshot tests needed for whitepapers/page.
|
|
17
|
-
*
|
|
18
|
-
* Failure = snapshot diff > 0 bytes. DO NOT regenerate snapshots to pass.
|
|
19
|
-
* A non-zero diff indicates a behavior regression in the migration. Escalate.
|
|
20
|
-
*/
|
|
21
|
-
import React from "react";
|
|
22
|
-
import { render } from "@testing-library/react";
|
|
23
|
-
|
|
24
|
-
jest.mock("next-mdx-remote/rsc", () => ({
|
|
25
|
-
__esModule: true,
|
|
26
|
-
MDXRemote: ({ source }: { source: string }): React.ReactElement =>
|
|
27
|
-
React.createElement("div", { "data-testid": "mdx-rendered" }, source),
|
|
28
|
-
}));
|
|
29
|
-
|
|
30
|
-
jest.mock("next/navigation", () => ({
|
|
31
|
-
__esModule: true,
|
|
32
|
-
notFound: jest.fn(() => {
|
|
33
|
-
throw new Error("NEXT_NOT_FOUND");
|
|
34
|
-
}),
|
|
35
|
-
}));
|
|
36
|
-
|
|
37
|
-
import WhitepaperSlugPage from "../[slug]/page";
|
|
38
|
-
import { notFound } from "next/navigation";
|
|
39
|
-
|
|
40
|
-
const mockNotFound = notFound as jest.MockedFunction<typeof notFound>;
|
|
41
|
-
|
|
42
|
-
describe("whitepapers/[slug] — snapshot regression", () => {
|
|
43
|
-
beforeEach(() => {
|
|
44
|
-
mockNotFound.mockClear();
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it("populated state renders deterministic HTML", async () => {
|
|
48
|
-
const getMdxSource = jest.fn().mockResolvedValue({
|
|
49
|
-
frontmatter: {
|
|
50
|
-
type: "Whitepaper" as const,
|
|
51
|
-
slug: "ailk-aeo-strategy-2026",
|
|
52
|
-
title: "AILK AEO Strategy 2026",
|
|
53
|
-
description:
|
|
54
|
-
"In-depth research on answer engine optimization for AILK products.",
|
|
55
|
-
},
|
|
56
|
-
body: "## Executive Summary\n\nBody content.",
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
const element = await WhitepaperSlugPage({
|
|
60
|
-
params: Promise.resolve({ locale: "en", slug: "ailk-aeo-strategy-2026" }),
|
|
61
|
-
getMdxSource,
|
|
62
|
-
});
|
|
63
|
-
const { container } = render(element);
|
|
64
|
-
expect(container.innerHTML).toMatchInlineSnapshot(`
|
|
65
|
-
"<script type="application/ld+json" data-testid="json-ld">{"@context":"https://schema.org","@graph":[{"@context":"https://schema.org","@type":"WebPage","inLanguage":"en","name":"AILK AEO Strategy 2026","description":"In-depth research on answer engine optimization for AILK products.","mainEntity":{"@context":"https://schema.org","@type":"Article","headline":"AILK AEO Strategy 2026","description":"In-depth research on answer engine optimization for AILK products."}},{"@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":"Whitepapers","item":"http://localhost:3000/en/whitepapers"},{"@type":"ListItem","position":3,"name":"AILK AEO Strategy 2026","item":"http://localhost:3000/en/whitepapers/ailk-aeo-strategy-2026"}]}]}</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-rendered">## Executive Summary
|
|
66
|
-
|
|
67
|
-
Body content.</div></div></article></div></div></div></main>"
|
|
68
|
-
`);
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it("unknown slug triggers notFound()", async () => {
|
|
72
|
-
const getMdxSource = jest.fn().mockResolvedValue(null);
|
|
73
|
-
|
|
74
|
-
await expect(
|
|
75
|
-
WhitepaperSlugPage({
|
|
76
|
-
params: Promise.resolve({ locale: "en", slug: "unknown-slug" }),
|
|
77
|
-
getMdxSource,
|
|
78
|
-
}),
|
|
79
|
-
).rejects.toThrow("NEXT_NOT_FOUND");
|
|
80
|
-
expect(mockNotFound).toHaveBeenCalled();
|
|
81
|
-
});
|
|
82
|
-
});
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
// Whitepapers list page. Enumerates Whitepaper slugs via the content adapter
|
|
2
|
-
// and renders a directory listing. No dedicated list MDX type exists for Whitepaper.
|
|
3
|
-
import { getMdxSlugs as defaultGetMdxSlugs } from "@working-theory/page-renderer";
|
|
4
|
-
import { LinkListItem, RowGroup } from "@working-theory/ui/blocks";
|
|
5
|
-
import { Container, Heading, Text } from "@working-theory/ui/primitives";
|
|
6
|
-
import { getTranslations } from "next-intl/server";
|
|
7
|
-
import type { ReactElement } from "react";
|
|
8
|
-
|
|
9
|
-
interface Props {
|
|
10
|
-
params: Promise<{ locale: string }>;
|
|
11
|
-
getMdxSlugs?: typeof defaultGetMdxSlugs;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export default async function Page({
|
|
15
|
-
params,
|
|
16
|
-
getMdxSlugs = defaultGetMdxSlugs,
|
|
17
|
-
}: Props): Promise<ReactElement> {
|
|
18
|
-
const { locale } = await params;
|
|
19
|
-
const t = await getTranslations("whitepapers");
|
|
20
|
-
const slugs = await getMdxSlugs("Whitepaper", locale);
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<main>
|
|
24
|
-
<Container className="py-section">
|
|
25
|
-
<Heading level={1}>{t("heading")}</Heading>
|
|
26
|
-
<div data-testid="whitepapers-description">
|
|
27
|
-
<Text>{t("description")}</Text>
|
|
28
|
-
</div>
|
|
29
|
-
{slugs.length === 0 ? (
|
|
30
|
-
<div data-testid="section-empty-state">
|
|
31
|
-
<Text>{t("emptyState")}</Text>
|
|
32
|
-
</div>
|
|
33
|
-
) : (
|
|
34
|
-
<RowGroup data-testid="whitepapers-list">
|
|
35
|
-
{slugs.map((slug) => (
|
|
36
|
-
<LinkListItem
|
|
37
|
-
key={slug}
|
|
38
|
-
href={`/${locale}/whitepapers/${slug}`}
|
|
39
|
-
label={slug}
|
|
40
|
-
className="px-4"
|
|
41
|
-
data-testid={`whitepapers-list-item-${slug}`}
|
|
42
|
-
/>
|
|
43
|
-
))}
|
|
44
|
-
</RowGroup>
|
|
45
|
-
)}
|
|
46
|
-
</Container>
|
|
47
|
-
</main>
|
|
48
|
-
);
|
|
49
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for /working-agreement (#8661 D10, AC-6) — the twin of /terms and
|
|
3
|
-
* /privacy, serving the registered `WorkingAgreementPage` type so the
|
|
4
|
-
* contact form's terms statement never links a 404.
|
|
5
|
-
*
|
|
6
|
-
* `renderPage`/`renderPageMetadata` are mocked at the
|
|
7
|
-
* `@working-theory/page-renderer` boundary (the /reports suite's shape); each
|
|
8
|
-
* assertion inspects the calls directly.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
const mockRenderPage = jest.fn(async (..._args: unknown[]) => "<rendered/>");
|
|
12
|
-
const mockRenderPageMetadata = jest.fn((..._args: unknown[]) => undefined);
|
|
13
|
-
|
|
14
|
-
jest.mock("@working-theory/page-renderer", () => ({
|
|
15
|
-
__esModule: true,
|
|
16
|
-
renderPage: (...args: unknown[]) => mockRenderPage(...args),
|
|
17
|
-
renderPageMetadata: (...args: unknown[]) => mockRenderPageMetadata(...args),
|
|
18
|
-
getMdxSource: jest.fn(),
|
|
19
|
-
getPageSections: jest.fn(),
|
|
20
|
-
}));
|
|
21
|
-
|
|
22
|
-
import WorkingAgreementPage, { generateMetadata } from "../page";
|
|
23
|
-
|
|
24
|
-
beforeEach(() => jest.clearAllMocks());
|
|
25
|
-
|
|
26
|
-
describe("WorkingAgreementPage", () => {
|
|
27
|
-
it("renders the WorkingAgreementPage type at slug working-agreement, in its own namespace", async () => {
|
|
28
|
-
await WorkingAgreementPage({ params: Promise.resolve({ locale: "en" }) });
|
|
29
|
-
|
|
30
|
-
expect(mockRenderPage).toHaveBeenCalledTimes(1);
|
|
31
|
-
expect(mockRenderPage).toHaveBeenCalledWith({
|
|
32
|
-
type: "WorkingAgreementPage",
|
|
33
|
-
slug: "working-agreement",
|
|
34
|
-
locale: "en",
|
|
35
|
-
translationsNamespace: "workingAgreement",
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it("passes injected content loaders through", async () => {
|
|
40
|
-
const getMdxSource = jest.fn();
|
|
41
|
-
const getPageSections = jest.fn();
|
|
42
|
-
|
|
43
|
-
await WorkingAgreementPage({
|
|
44
|
-
params: Promise.resolve({ locale: "fr" }),
|
|
45
|
-
getMdxSource,
|
|
46
|
-
getPageSections,
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
expect(mockRenderPage).toHaveBeenCalledWith(
|
|
50
|
-
expect.objectContaining({ locale: "fr", getMdxSource, getPageSections }),
|
|
51
|
-
);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it("builds metadata from the same type and slug", async () => {
|
|
55
|
-
await generateMetadata({ params: Promise.resolve({ locale: "en" }) });
|
|
56
|
-
|
|
57
|
-
expect(mockRenderPageMetadata).toHaveBeenCalledWith({
|
|
58
|
-
type: "WorkingAgreementPage",
|
|
59
|
-
slug: "working-agreement",
|
|
60
|
-
locale: "en",
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
});
|