create-ailk 0.34.0 → 0.35.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.
Files changed (55) hide show
  1. package/component-catalog.json +25 -3
  2. package/component-catalog.md +9 -8
  3. package/dist/add-module.js +7 -2
  4. package/dist/derive-architecture.js +2 -0
  5. package/dist/index.d.ts +1 -1
  6. package/dist/index.js +1 -1
  7. package/dist/module-architecture.js +9 -0
  8. package/dist/programmatic.js +5 -2
  9. package/dist/site-listing-path.d.ts +8 -0
  10. package/dist/site-listing-path.js +8 -0
  11. package/dist/surfaces.d.ts +20 -0
  12. package/dist/surfaces.js +26 -0
  13. package/dist/template-record.js +2 -0
  14. package/dist/update.js +11 -0
  15. package/package.json +3 -3
  16. package/templates/apps/api/CLAUDE.md +6 -6
  17. package/templates/apps/mcp/CLAUDE.md +16 -7
  18. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/item.test.tsx +43 -0
  19. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +6 -5
  20. package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +6 -1
  21. package/templates/apps/web/app/[locale]/flows/[slug]/FlowStepperClient.tsx +43 -4
  22. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.deliverable.test.tsx +23 -9
  23. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.invite.test.tsx +15 -0
  24. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.permalink.test.tsx +74 -0
  25. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.test.tsx +34 -1
  26. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/magnet-page.test.tsx +257 -4
  27. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/save.actions.test.ts +72 -92
  28. package/templates/apps/web/app/[locale]/flows/[slug]/email-moment.ts +2 -2
  29. package/templates/apps/web/app/[locale]/flows/[slug]/magnet-page.tsx +164 -65
  30. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/LevelChart.tsx +100 -0
  31. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsCard.tsx +99 -0
  32. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsClient.tsx +415 -253
  33. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsEmailStep.tsx +113 -32
  34. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.no-commerce.test.tsx +16 -17
  35. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.report.test.tsx +284 -0
  36. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/by-result.test.tsx +52 -19
  37. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/cards.test.tsx +402 -0
  38. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/page.test.tsx +100 -12
  39. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/score.test.tsx +153 -101
  40. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/meeting-seam.ts +36 -0
  41. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/page.tsx +121 -33
  42. package/templates/apps/web/app/[locale]/flows/[slug]/save.actions.ts +27 -17
  43. package/templates/apps/web/app/[locale]/flows/[slug]/served-flow.ts +91 -0
  44. package/templates/apps/web/app/[locale]/layout.tsx +18 -1
  45. package/templates/apps/web/app/api/auth/hub/authorize/__tests__/route.test.ts +24 -0
  46. package/templates/apps/web/app/api/auth/hub/authorize/route.ts +5 -1
  47. package/templates/apps/web/app/llms.txt/__tests__/site-listing.test.ts +122 -0
  48. package/templates/apps/web/app/llms.txt/route.ts +14 -2
  49. package/templates/apps/web/app/sitemap.xml/__tests__/site-listing.test.ts +98 -0
  50. package/templates/apps/web/app/sitemap.xml/route.ts +13 -2
  51. package/templates/apps/web/lib/account-config.ts +24 -9
  52. package/templates/apps/web/lib/hub-children.tsx +15 -11
  53. package/templates/apps/web/lib/site-listing.ts +7 -0
  54. package/templates/apps/web/messages/en.json +13 -1
  55. package/versions.json +47 -47
@@ -9,10 +9,13 @@
9
9
  * is shown. A draft (an offering not in the shown set) renders its card with
10
10
  * no price and no link, for either kind.
11
11
  *
12
+ * #11013 spec E, D-G (AC-5) — the by-result card is the same Product card
13
+ * `ResultsCard` draws for an Email-links-to offering, and it wins over one.
14
+ *
12
15
  * Mocks mirror `landing.test.tsx`; the clock moves 16 s between cases so the
13
16
  * page's 15 s shown-set read never carries over.
14
17
  */
15
- import { render, screen } from "@testing-library/react";
18
+ import { render, screen, within } from "@testing-library/react";
16
19
  import type { FlowConfig, FlowResultRow } from "@working-theory/validation";
17
20
  import {
18
21
  encodePermalink,
@@ -49,7 +52,10 @@ const SLUG = "readiness";
49
52
  const en = (s: string) => ({ en: s });
50
53
 
51
54
  /** A scored diagnostic — never 0, monthly 2, weekly 4 points — with rows only. */
52
- function config(byResult: FlowResultRow[]): FlowConfig {
55
+ function config(
56
+ byResult: FlowResultRow[],
57
+ weights: Record<"never" | "monthly" | "weekly", number> = { never: 0, monthly: 2, weekly: 4 },
58
+ ): FlowConfig {
53
59
  return {
54
60
  slug: SLUG,
55
61
  defaultLocale: "en",
@@ -78,7 +84,7 @@ function config(byResult: FlowResultRow[]): FlowConfig {
78
84
  name: "p_cadence",
79
85
  question: "cadence",
80
86
  kind: "optionWeights",
81
- weights: { never: 0, monthly: 2, weekly: 4 },
87
+ weights,
82
88
  },
83
89
  ],
84
90
  scores: { total: { sum: ["p_cadence"] } },
@@ -142,7 +148,7 @@ async function redirectOf(answers: Record<string, string>): Promise<string | nul
142
148
  }
143
149
 
144
150
  const checkoutRow = (offeringKey: string): FlowResultRow => ({
145
- when: { kind: "tier", op: "is", level: 4 },
151
+ when: { kind: "tier", op: "is", level: 5 },
146
152
  routeTo: { kind: "checkout", offeringKey },
147
153
  });
148
154
  const offeringRow = (offeringKey: string): FlowResultRow => ({
@@ -196,9 +202,9 @@ describe("#10827 — a checkout row sends the respondent to checkout", () => {
196
202
  expect(mockRedirect).not.toHaveBeenCalled();
197
203
  // jsdom performs no navigation; it reports each one it was asked for.
198
204
  expect(navigations()).toHaveLength(1);
199
- expect(screen.getByTestId("recommendation-card-growth-ops-growth_monthly-terminal-getStarted")).toBeInTheDocument();
205
+ expect(screen.getByTestId("flow-results-card-action")).toHaveTextContent("getStarted");
200
206
  // The card stays as the fallback, priced from the offering.
201
- expect(screen.getByTestId("recommendation-card-growth-ops-growth_monthly-price")).toBeInTheDocument();
207
+ expect(screen.getByTestId("flow-results-card-price")).toBeInTheDocument();
202
208
  });
203
209
 
204
210
  it.each<[string, Record<string, string> | undefined, boolean]>([
@@ -218,7 +224,7 @@ describe("#10827 — a checkout row sends the respondent to checkout", () => {
218
224
  }),
219
225
  );
220
226
  expect(navigations()).toEqual([]);
221
- expect(screen.getByTestId("recommendation-card-growth-ops-growth_monthly-terminal-getStarted")).toBeInTheDocument();
227
+ expect(screen.getByTestId("flow-results-card-action")).toHaveTextContent("getStarted");
222
228
  });
223
229
 
224
230
  it("a {plan} key → the /pricing?plan= landing", async () => {
@@ -226,14 +232,25 @@ describe("#10827 — a checkout row sends the respondent to checkout", () => {
226
232
  await expect(redirectOf({ cadence: "weekly" })).resolves.toBe("/en/pricing?plan=growth-ops-growth");
227
233
  });
228
234
 
235
+ it("a Level 4 row matches a 75% walk and not a 100% one (#11034)", async () => {
236
+ // monthly = 3 / 4 = 75% → Level 4; weekly = 100% → Level 5.
237
+ const level4: FlowResultRow = {
238
+ when: { kind: "tier", op: "is", level: 4 },
239
+ routeTo: { kind: "checkout", offeringKey: "growth-ops-growth" },
240
+ };
241
+ mockGet.mockResolvedValue({ ok: true, status: 200, body: config([level4], { never: 0, monthly: 3, weekly: 4 }) });
242
+ await expect(redirectOf({ cadence: "monthly" })).resolves.toBe("/en/pricing?plan=growth-ops-growth");
243
+ await expect(redirectOf({ cadence: "weekly" })).resolves.toBeNull();
244
+ });
245
+
229
246
  it("a key not shown (a draft) renders its card with no price and no checkout", async () => {
230
247
  mockGet.mockResolvedValue({ ok: true, status: 200, body: config([checkoutRow("ai-readiness-workshop_monthly")]) });
231
248
  render(await page({ cadence: "weekly" }));
232
249
  expect(mockRedirect).not.toHaveBeenCalled();
233
- const card = screen.getByTestId("recommendation-card-ai-readiness-workshop_monthly");
250
+ const card = screen.getByTestId("flow-results-card");
234
251
  expect(card).toHaveTextContent("Ai readiness workshop");
235
- expect(screen.queryByTestId("recommendation-card-ai-readiness-workshop_monthly-price")).toBeNull();
236
- expect(screen.queryByTestId("recommendation-card-ai-readiness-workshop_monthly-terminal-getStarted")).toBeNull();
252
+ expect(screen.queryByTestId("flow-results-card-price")).toBeNull();
253
+ expect(screen.queryByTestId("flow-results-card-action")).toBeNull();
237
254
  expect(navigations()).toEqual([]);
238
255
  });
239
256
  });
@@ -243,27 +260,43 @@ describe("#10827 — an offering row renders a card named from the offering", ()
243
260
  mockGet.mockResolvedValue({ ok: true, status: 200, body: config([offeringRow("growth-ops-growth")]) });
244
261
  render(await page({ cadence: "monthly" }));
245
262
  expect(mockRedirect).not.toHaveBeenCalled();
246
- expect(screen.getByTestId("recommendation-card-growth-ops-growth")).toHaveTextContent("Growth Ops - Growth");
247
- expect(screen.getByTestId("recommendation-card-growth-ops-growth-price")).toBeInTheDocument();
248
- expect(screen.getByTestId("recommendation-card-growth-ops-growth-terminal-getStarted")).toBeInTheDocument();
263
+ const card = screen.getByTestId("flow-results-card");
264
+ expect(within(card).getByRole("heading", { name: "Growth Ops - Growth" })).toBeInTheDocument();
265
+ expect(within(card).getByTestId("flow-results-card-price")).toBeInTheDocument();
266
+ expect(within(card).getByTestId("flow-results-card-action").getAttribute("href")).toBe(
267
+ "/en/pricing?plan=growth-ops-growth",
268
+ );
249
269
  expect(navigations()).toEqual([]);
250
270
  });
251
271
 
272
+ // #11013 decision 15 — a by-result row beats Email links to.
273
+ it("a by-result offering row and a conversionLink together render only the by-result card", async () => {
274
+ mockGet.mockResolvedValue({
275
+ ok: true,
276
+ status: 200,
277
+ body: { ...config([offeringRow("growth-ops-growth")]), conversionLink: { kind: "offering", id: "growth-ops-growth" } },
278
+ });
279
+ render(await page({ cadence: "monthly" }));
280
+ const cards = screen.getAllByTestId("flow-results-card");
281
+ expect(cards).toHaveLength(1);
282
+ expect(within(cards[0]!).getByRole("heading", { name: "Growth Ops - Growth" })).toBeInTheDocument();
283
+ // One read serves the row's card; the link never asks for a second.
284
+ expect(mockShown).toHaveBeenCalledTimes(1);
285
+ });
286
+
252
287
  it("a draft offering (not shown): the card with no price and no link", async () => {
253
288
  mockGet.mockResolvedValue({ ok: true, status: 200, body: config([offeringRow("ai-readiness-workshop")]) });
254
289
  render(await page({ cadence: "weekly" }));
255
- expect(screen.getByTestId("recommendation-card-ai-readiness-workshop")).toHaveTextContent(
256
- "Ai readiness workshop",
257
- );
258
- expect(screen.queryByTestId("recommendation-card-ai-readiness-workshop-price")).toBeNull();
259
- expect(screen.queryByTestId("recommendation-card-ai-readiness-workshop-terminal-getStarted")).toBeNull();
290
+ expect(screen.getByTestId("flow-results-card")).toHaveTextContent("Ai readiness workshop");
291
+ expect(screen.queryByTestId("flow-results-card-price")).toBeNull();
292
+ expect(screen.queryByTestId("flow-results-card-action")).toBeNull();
260
293
  });
261
294
 
262
295
  it("no row matches: the results page with no card and no redirect", async () => {
263
296
  mockGet.mockResolvedValue({ ok: true, status: 200, body: config([offeringRow("growth-ops-growth")]) });
264
297
  render(await page({ cadence: "never" }));
265
298
  expect(screen.getByTestId("flow-results")).toBeInTheDocument();
266
- expect(screen.queryByTestId("recommendation-card-growth-ops-growth")).toBeNull();
299
+ expect(screen.queryByTestId("flow-results-card")).toBeNull();
267
300
  expect(mockRedirect).not.toHaveBeenCalled();
268
301
  });
269
302
  });
@@ -0,0 +1,402 @@
1
+ // oss: false
2
+ /**
3
+ * One card, by decision 15's order, and the primary action that follows it
4
+ * (#11013 spec E, D-G, D-H, D-K; AC-5).
5
+ *
6
+ * The page resolves the Product card for an `offering` link from the shown
7
+ * set; `ResultsClient` resolves the Meeting card for an `appointment` link
8
+ * from the scheduling seam (`ResultsMeetingContext`), which the scheduling
9
+ * layout provides and a scaffold without scheduling never does. A by-result
10
+ * card beats a link's card, and with neither the top fit renders as one
11
+ * `RecommendationCard` — no second fit, no pairing, no side panel. With a
12
+ * card its button is the primary and Send it is an outline button; with none
13
+ * Send it is primary.
14
+ *
15
+ * Page mocks mirror `by-result.test.tsx`; client mocks mirror
16
+ * `ResultsClient.no-commerce.test.tsx`.
17
+ */
18
+ import { readFileSync } from "node:fs";
19
+ import { join } from "node:path";
20
+
21
+ import { render, screen, within } from "@testing-library/react";
22
+ import type { FlowConfig, FlowConversionLink } from "@working-theory/validation";
23
+ import {
24
+ encodePermalink,
25
+ PERMALINK_VERSION,
26
+ workspaceShownSetWireSchema,
27
+ } from "@working-theory/validation";
28
+ import type { ReactElement } from "react";
29
+
30
+ const mockGet = jest.fn();
31
+ const mockShown = jest.fn();
32
+ jest.mock("@working-theory/api-client", () => ({
33
+ __esModule: true,
34
+ flows: { get: (...args: unknown[]) => mockGet(...args) },
35
+ offerings: { shown: (...args: unknown[]) => mockShown(...args) },
36
+ }));
37
+
38
+ const mockRedirect = jest.fn((url: string) => {
39
+ throw new Error(`NEXT_REDIRECT:${url}`);
40
+ });
41
+ jest.mock("next/navigation", () => ({
42
+ __esModule: true,
43
+ redirect: (url: string) => mockRedirect(url),
44
+ }));
45
+
46
+ // eslint-disable-next-line no-restricted-syntax -- the boundary under test is the render, not the action (save.actions.test.ts)
47
+ jest.mock("../../../save.actions", () => ({ sendResultsEmailAction: jest.fn() }));
48
+
49
+ jest.mock("next-intl", () => ({
50
+ __esModule: true,
51
+ useTranslations:
52
+ () =>
53
+ (key: string, values?: Record<string, unknown>): string =>
54
+ values === undefined
55
+ ? key
56
+ : `${key}:${Object.entries(values)
57
+ .map(([k, v]) => `${k}=${String(v)}`)
58
+ .join(",")}`,
59
+ useMessages: () => ({}),
60
+ }));
61
+
62
+ import Page from "../page";
63
+ import type { ResultsMeeting } from "../meeting-seam";
64
+ import { ResultsMeetingContext } from "../meeting-seam";
65
+ import type { ResultsConversionCard, ResultsOfferingCard } from "../ResultsClient";
66
+ import { ResultsClient } from "../ResultsClient";
67
+
68
+ const SLUG = "readiness";
69
+ const en = (s: string) => ({ en: s });
70
+ const ANSWERS = { cadence: "weekly" };
71
+
72
+ type ServedConfig = FlowConfig & {
73
+ conversion?: "none" | "lead" | "lead-link" | "user";
74
+ conversionLink?: FlowConversionLink;
75
+ };
76
+
77
+ /** A recommending magnet with no rows and no ending; `offers` only when asked. */
78
+ function config(extra: Record<string, unknown> = {}, withOffers = false): ServedConfig {
79
+ return {
80
+ slug: SLUG,
81
+ defaultLocale: "en",
82
+ mode: "recommending",
83
+ steps: [
84
+ {
85
+ key: "q0",
86
+ type: "segmentation",
87
+ copy: { title: en("How often do you ship?") },
88
+ questions: [
89
+ {
90
+ name: "cadence",
91
+ options: [
92
+ { value: "monthly", label: en("Monthly") },
93
+ { value: "weekly", label: en("Weekly") },
94
+ ],
95
+ },
96
+ ],
97
+ },
98
+ ],
99
+ ...(withOffers
100
+ ? {
101
+ offers: [
102
+ {
103
+ key: "pro",
104
+ copy: { name: en("Pro") },
105
+ price: { kind: "label", label: en("On request") },
106
+ rules: [{ when: { answer: "cadence", eq: "weekly" }, reason: en("You ship weekly.") }],
107
+ },
108
+ {
109
+ key: "consult",
110
+ copy: { name: en("Consulting") },
111
+ price: { kind: "label", label: en("Ask us") },
112
+ rules: [{ when: { answer: "cadence", eq: "weekly" }, reason: en("Weekly shippers ask.") }],
113
+ },
114
+ ],
115
+ pairings: [
116
+ {
117
+ offers: ["pro", "consult"],
118
+ reason: en("Better together."),
119
+ when: { answer: "cadence", eq: "weekly" },
120
+ },
121
+ ],
122
+ }
123
+ : {}),
124
+ recommendation: { key: "result", copy: { title: en("Your result") } },
125
+ conversion: "lead-link",
126
+ ...extra,
127
+ } as ServedConfig;
128
+ }
129
+
130
+ const SHOWN_SET = workspaceShownSetWireSchema.parse({
131
+ productIds: ["prod_growth", "prod_scale"],
132
+ recommended: { plan: null, addon: null },
133
+ offerings: [
134
+ {
135
+ productId: "prod_growth",
136
+ plan: "growth",
137
+ name: "Growth",
138
+ description: "Hands-on growth, every month.",
139
+ marketingFeatures: ["Up to 40 hours a month", "Growth Hub"],
140
+ unitLabel: null,
141
+ note: null,
142
+ termsNote: null,
143
+ ailkGroup: "plan",
144
+ ailkOrder: null,
145
+ recommended: false,
146
+ prices: [
147
+ {
148
+ priceId: "price_growth_monthly",
149
+ lookupKey: "growth_monthly",
150
+ plan: "growth",
151
+ period: "monthly",
152
+ interval: "month",
153
+ amount: 120000,
154
+ currency: "usd",
155
+ },
156
+ ],
157
+ },
158
+ {
159
+ productId: "prod_scale",
160
+ plan: "scale",
161
+ name: "Scale",
162
+ description: null,
163
+ marketingFeatures: [],
164
+ unitLabel: null,
165
+ note: null,
166
+ termsNote: null,
167
+ ailkGroup: "plan",
168
+ ailkOrder: null,
169
+ recommended: false,
170
+ prices: [
171
+ {
172
+ priceId: "price_scale_monthly",
173
+ lookupKey: "scale_monthly",
174
+ plan: "scale",
175
+ period: "monthly",
176
+ interval: "month",
177
+ amount: 250000,
178
+ currency: "usd",
179
+ },
180
+ ],
181
+ },
182
+ ],
183
+ state: "current",
184
+ snapshotAt: "2026-11-04T12:00:00.000Z",
185
+ });
186
+
187
+ function page(cfg: ServedConfig): Promise<ReactElement> {
188
+ mockGet.mockResolvedValue({ ok: true, status: 200, body: cfg });
189
+ return Page({
190
+ params: Promise.resolve({
191
+ locale: "en",
192
+ slug: SLUG,
193
+ payload: encodePermalink({ version: PERMALINK_VERSION, flowSlug: SLUG, answers: ANSWERS }),
194
+ }),
195
+ });
196
+ }
197
+
198
+ const INTRO: ResultsMeeting = {
199
+ slug: "intro",
200
+ title: "Intro",
201
+ description: "Quick intro meeting",
202
+ href: "/en/meet/intro",
203
+ bookLabel: "Book 15 min",
204
+ };
205
+
206
+ function renderClient(
207
+ cfg: ServedConfig,
208
+ extra: { offeringCard?: ResultsOfferingCard; conversionCard?: ResultsConversionCard } = {},
209
+ meeting?: ResultsMeeting,
210
+ ): void {
211
+ const client = (
212
+ <ResultsClient config={cfg} locale="en" answers={ANSWERS} slug={SLUG} payload="v1-abc" {...extra} />
213
+ );
214
+ render(
215
+ meeting !== undefined ? (
216
+ <ResultsMeetingContext.Provider value={meeting}>{client}</ResultsMeetingContext.Provider>
217
+ ) : (
218
+ client
219
+ ),
220
+ );
221
+ }
222
+
223
+ const BRAND_FILL = "bg-(--color-brand)";
224
+ const OUTLINE_FILL = "bg-transparent";
225
+
226
+ beforeAll(() => {
227
+ jest.useFakeTimers({ now: new Date("2026-11-04T12:00:00.000Z") });
228
+ });
229
+
230
+ afterAll(() => {
231
+ jest.useRealTimers();
232
+ });
233
+
234
+ beforeEach(() => {
235
+ // The page shares its shown-set read for 15 s; each case starts later.
236
+ jest.setSystemTime(Date.now() + 16_000);
237
+ mockGet.mockReset();
238
+ mockShown.mockReset();
239
+ mockRedirect.mockClear();
240
+ window.sessionStorage.clear();
241
+ mockShown.mockResolvedValue({ ok: true, status: 200, body: { status: "shown", shownSet: SHOWN_SET } });
242
+ });
243
+
244
+ describe("AC-5 — Email links to an offering: the Product card (decision 14)", () => {
245
+ it("renders the shown product's name, price, description, features under What's included, and Get Started to /pricing?plan=", async () => {
246
+ render(await page(config({ conversionLink: { kind: "offering", id: "growth" } })));
247
+ expect(mockRedirect).not.toHaveBeenCalled();
248
+ const card = screen.getByTestId("flow-results-card");
249
+ expect(within(card).getByRole("heading", { name: "Growth" })).toBeInTheDocument();
250
+ expect(within(card).getByTestId("flow-results-card-price")).toHaveTextContent("monthly:amount=$1,200");
251
+ expect(within(card).getByTestId("flow-results-card-description")).toHaveTextContent(
252
+ "Hands-on growth, every month.",
253
+ );
254
+ expect(within(card).getByText("whatsIncluded")).toBeInTheDocument();
255
+ const features = within(card).getAllByRole("listitem").map((li) => li.textContent);
256
+ expect(features).toEqual(["Up to 40 hours a month", "Growth Hub"]);
257
+ const action = within(card).getByTestId("flow-results-card-action");
258
+ expect(action.getAttribute("href")).toBe("/en/pricing?plan=growth");
259
+ expect(action).toHaveTextContent("getStarted");
260
+ expect(within(card).getByText("priceCard.eyebrow")).toBeInTheDocument();
261
+ expect(screen.getAllByTestId("flow-results-card")).toHaveLength(1);
262
+ });
263
+
264
+ it("with a null description no description line renders", async () => {
265
+ render(await page(config({ conversionLink: { kind: "offering", id: "scale" } })));
266
+ const card = screen.getByTestId("flow-results-card");
267
+ expect(within(card).getByRole("heading", { name: "Scale" })).toBeInTheDocument();
268
+ expect(within(card).queryByTestId("flow-results-card-description")).not.toBeInTheDocument();
269
+ expect(within(card).queryByText("whatsIncluded")).not.toBeInTheDocument();
270
+ });
271
+
272
+ it("an offering not in the shown set gives no card", async () => {
273
+ render(await page(config({ conversionLink: { kind: "offering", id: "draft" } })));
274
+ expect(screen.getByTestId("flow-results")).toBeInTheDocument();
275
+ expect(screen.queryByTestId("flow-results-card")).not.toBeInTheDocument();
276
+ });
277
+
278
+ it.each(["results", "magnet"])("a %s link gives no card and no shown read", async (kind) => {
279
+ render(await page(config({ conversionLink: { kind, id: kind === "results" ? "flow_12345678-1234-1234-1234-123456789abc" : "other" } })));
280
+ expect(screen.queryByTestId("flow-results-card")).not.toBeInTheDocument();
281
+ expect(mockShown).not.toHaveBeenCalled();
282
+ });
283
+ });
284
+
285
+ describe("AC-5 — Email links to an appointment: the Meeting card from the scheduling seam (D-K)", () => {
286
+ it("under the provider renders the meeting's title, description and a link to its page labelled with its bookLabel", () => {
287
+ renderClient(config({ conversionLink: { kind: "appointment", id: "intro" } }), {}, INTRO);
288
+ const card = screen.getByTestId("flow-results-card");
289
+ expect(within(card).getByRole("heading", { name: "Intro" })).toBeInTheDocument();
290
+ expect(within(card).getByTestId("flow-results-card-description")).toHaveTextContent("Quick intro meeting");
291
+ const action = within(card).getByTestId("flow-results-card-action");
292
+ expect(action.getAttribute("href")).toBe("/en/meet/intro");
293
+ expect(action).toHaveTextContent("Book 15 min");
294
+ expect(within(card).queryByTestId("flow-results-card-price")).not.toBeInTheDocument();
295
+ });
296
+
297
+ it("a slug the provider does not hold renders no card", () => {
298
+ renderClient(config({ conversionLink: { kind: "appointment", id: "working" } }), {}, INTRO);
299
+ expect(screen.queryByTestId("flow-results-card")).not.toBeInTheDocument();
300
+ });
301
+
302
+ it("a results link renders no card even with a meeting provided", () => {
303
+ renderClient(config({ conversionLink: { kind: "results", id: "flow_12345678-1234-1234-1234-123456789abc" } }), {}, INTRO);
304
+ expect(screen.queryByTestId("flow-results-card")).not.toBeInTheDocument();
305
+ });
306
+
307
+ it("no scheduling (no provider): an appointment link renders no Meeting card — the top fit renders instead", () => {
308
+ renderClient(config({ conversionLink: { kind: "appointment", id: "intro" } }, true));
309
+ expect(screen.queryByTestId("flow-results-card")).not.toBeInTheDocument();
310
+ expect(screen.getByTestId("recommendation-card-pro")).toBeInTheDocument();
311
+ });
312
+ });
313
+
314
+ describe("AC-5 — the signal-collectors files name no scheduling file", () => {
315
+ const RESULTS_DIR = join(__dirname, "..");
316
+ it.each(["page.tsx", "ResultsClient.tsx", "ResultsCard.tsx", "meeting-seam.ts"])(
317
+ "%s imports neither lib/meetings nor the results layout",
318
+ (file) => {
319
+ const source = readFileSync(join(RESULTS_DIR, file), "utf8");
320
+ expect(source).not.toMatch(/from "[^"]*lib\/meetings/);
321
+ expect(source).not.toMatch(/from "\.\.\/layout"/);
322
+ expect(source).not.toMatch(/from "\.\.\/ResultsMeetingsProvider"/);
323
+ },
324
+ );
325
+ });
326
+
327
+ describe("AC-5 — one card, by decision 15's order", () => {
328
+ const OFFERING_CARD: ResultsOfferingCard = {
329
+ offeringKey: "growth",
330
+ title: "Growth (by result)",
331
+ price: { amount: 120000, currency: "usd", period: "monthly" },
332
+ href: "/en/pricing?plan=growth",
333
+ };
334
+ const PRODUCT_CARD: ResultsConversionCard = {
335
+ kind: "product",
336
+ name: "Scale (linked)",
337
+ features: [],
338
+ href: "/en/pricing?plan=scale",
339
+ };
340
+
341
+ it("a by-result offering row and a conversionLink together render only the by-result card", () => {
342
+ renderClient(config({ conversionLink: { kind: "offering", id: "scale" } }, true), {
343
+ offeringCard: OFFERING_CARD,
344
+ conversionCard: PRODUCT_CARD,
345
+ });
346
+ const cards = screen.getAllByTestId("flow-results-card");
347
+ expect(cards).toHaveLength(1);
348
+ expect(within(cards[0]!).getByRole("heading", { name: "Growth (by result)" })).toBeInTheDocument();
349
+ expect(screen.queryByText("Scale (linked)")).not.toBeInTheDocument();
350
+ expect(screen.queryByTestId("recommendation-card-pro")).not.toBeInTheDocument();
351
+ });
352
+
353
+ it("a link's card beats the older offer", () => {
354
+ renderClient(config({ conversionLink: { kind: "offering", id: "scale" } }, true), {
355
+ conversionCard: PRODUCT_CARD,
356
+ });
357
+ expect(screen.getByTestId("flow-results-card")).toBeInTheDocument();
358
+ expect(screen.queryByTestId("recommendation-card-pro")).not.toBeInTheDocument();
359
+ });
360
+
361
+ it("with neither, the top fit renders as one RecommendationCard and no other fit, pairing or side panel", () => {
362
+ renderClient(config({}, true));
363
+ expect(screen.getByTestId("recommendation-card-pro")).toBeInTheDocument();
364
+ expect(screen.queryByTestId("recommendation-card-consult")).not.toBeInTheDocument();
365
+ expect(screen.queryByTestId("recommendation-pairing")).not.toBeInTheDocument();
366
+ expect(screen.queryByTestId("flow-side-panel-safe-default")).not.toBeInTheDocument();
367
+ expect(screen.queryByTestId("flow-results-card")).not.toBeInTheDocument();
368
+ expect(screen.getAllByTestId(/^recommendation-card-[a-z_]+$/)).toHaveLength(1);
369
+ });
370
+
371
+ it("with no fit and no link, no card renders", () => {
372
+ renderClient(config());
373
+ expect(screen.queryByTestId("flow-results-card")).not.toBeInTheDocument();
374
+ expect(screen.queryAllByTestId(/^recommendation-card-[a-z_]+$/)).toHaveLength(0);
375
+ });
376
+ });
377
+
378
+ describe("AC-5 — the primary action follows the card (decision 16)", () => {
379
+ it("with a card, its button is the primary and Send it is an outline button", () => {
380
+ renderClient(config({ conversionLink: { kind: "appointment", id: "intro" } }), {}, INTRO);
381
+ expect(screen.getByTestId("flow-results-card-action").className).toContain(BRAND_FILL);
382
+ // Decision 16 — below `md:` the dock carries the card's button; the card's own shows from `md:`.
383
+ expect(screen.getByTestId("flow-results-card-action").parentElement?.className).toContain("hidden md:block");
384
+ const send = screen.getByTestId("flow-results-report-send");
385
+ expect(send.className).toContain(OUTLINE_FILL);
386
+ expect(send.className).not.toContain(BRAND_FILL);
387
+ });
388
+
389
+ it("with no card, Send it is the primary", () => {
390
+ renderClient(config());
391
+ const send = screen.getByTestId("flow-results-report-send");
392
+ expect(send.className).toContain(BRAND_FILL);
393
+ expect(send.className).not.toContain(OUTLINE_FILL);
394
+ });
395
+
396
+ it("the card comes before the form in DOM order", () => {
397
+ renderClient(config({ conversionLink: { kind: "appointment", id: "intro" } }), {}, INTRO);
398
+ const card = screen.getByTestId("flow-results-card");
399
+ const form = screen.getByTestId("flow-results-report");
400
+ expect(card.compareDocumentPosition(form) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
401
+ });
402
+ });