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.
- package/component-catalog.json +25 -3
- package/component-catalog.md +9 -8
- package/dist/add-module.js +7 -2
- package/dist/derive-architecture.js +2 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/module-architecture.js +9 -0
- package/dist/programmatic.js +5 -2
- package/dist/site-listing-path.d.ts +8 -0
- package/dist/site-listing-path.js +8 -0
- package/dist/surfaces.d.ts +20 -0
- package/dist/surfaces.js +26 -0
- package/dist/template-record.js +2 -0
- package/dist/update.js +11 -0
- package/package.json +3 -3
- package/templates/apps/api/CLAUDE.md +6 -6
- package/templates/apps/mcp/CLAUDE.md +16 -7
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/item.test.tsx +43 -0
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +6 -5
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +6 -1
- package/templates/apps/web/app/[locale]/flows/[slug]/FlowStepperClient.tsx +43 -4
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.deliverable.test.tsx +23 -9
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.invite.test.tsx +15 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.permalink.test.tsx +74 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.test.tsx +34 -1
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/magnet-page.test.tsx +257 -4
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/save.actions.test.ts +72 -92
- package/templates/apps/web/app/[locale]/flows/[slug]/email-moment.ts +2 -2
- package/templates/apps/web/app/[locale]/flows/[slug]/magnet-page.tsx +164 -65
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/LevelChart.tsx +100 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsCard.tsx +99 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsClient.tsx +415 -253
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsEmailStep.tsx +113 -32
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.no-commerce.test.tsx +16 -17
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.report.test.tsx +284 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/by-result.test.tsx +52 -19
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/cards.test.tsx +402 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/page.test.tsx +100 -12
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/score.test.tsx +153 -101
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/meeting-seam.ts +36 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/page.tsx +121 -33
- package/templates/apps/web/app/[locale]/flows/[slug]/save.actions.ts +27 -17
- package/templates/apps/web/app/[locale]/flows/[slug]/served-flow.ts +91 -0
- package/templates/apps/web/app/[locale]/layout.tsx +18 -1
- package/templates/apps/web/app/api/auth/hub/authorize/__tests__/route.test.ts +24 -0
- package/templates/apps/web/app/api/auth/hub/authorize/route.ts +5 -1
- package/templates/apps/web/app/llms.txt/__tests__/site-listing.test.ts +122 -0
- package/templates/apps/web/app/llms.txt/route.ts +14 -2
- package/templates/apps/web/app/sitemap.xml/__tests__/site-listing.test.ts +98 -0
- package/templates/apps/web/app/sitemap.xml/route.ts +13 -2
- package/templates/apps/web/lib/account-config.ts +24 -9
- package/templates/apps/web/lib/hub-children.tsx +15 -11
- package/templates/apps/web/lib/site-listing.ts +7 -0
- package/templates/apps/web/messages/en.json +13 -1
- package/versions.json +47 -47
package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/page.test.tsx
CHANGED
|
@@ -10,6 +10,10 @@
|
|
|
10
10
|
* AC4 — four cases `redirect()` to `/[locale]/flows/[slug]` and render no
|
|
11
11
|
* results markup: invalid payload, stale-version payload, a
|
|
12
12
|
* flowSlug-mismatched payload, and a non-recommending flow.
|
|
13
|
+
* #11013 spec E, D-C (AC-3) — the guard widens additively: a recommending
|
|
14
|
+
* flow with no offers and no rows renders whenever `hasResultsPage`
|
|
15
|
+
* holds (no ending); a cold permalink of a recommending flow with an
|
|
16
|
+
* ending and offers still renders, as at the pin.
|
|
13
17
|
*
|
|
14
18
|
* `next/navigation`'s `redirect` is mocked to throw (mirrors the sibling
|
|
15
19
|
* `thanks/[slug]` route's `notFound` test pattern) so a redirect is
|
|
@@ -259,12 +263,14 @@ describe("AC3 — a valid payload against a recommending flow renders exactly re
|
|
|
259
263
|
"en",
|
|
260
264
|
config.defaultLocale,
|
|
261
265
|
);
|
|
262
|
-
// #
|
|
263
|
-
//
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
fit.offerKey
|
|
267
|
-
|
|
266
|
+
// #11013 D-G — the top fit alone renders, as one card; the side panel
|
|
267
|
+
// and every other fit are gone from the results view.
|
|
268
|
+
if (fit.offerKey !== expected.fits[0]!.offerKey) {
|
|
269
|
+
expect(screen.queryByText(name)).not.toBeInTheDocument();
|
|
270
|
+
expect(screen.queryByTestId(`recommendation-card-${fit.offerKey}`)).not.toBeInTheDocument();
|
|
271
|
+
continue;
|
|
272
|
+
}
|
|
273
|
+
expect(screen.getAllByText(name)).toHaveLength(1);
|
|
268
274
|
if (offer.copy.description) {
|
|
269
275
|
expect(
|
|
270
276
|
screen.getByText(
|
|
@@ -292,6 +298,56 @@ describe("AC3 — a valid payload against a recommending flow renders exactly re
|
|
|
292
298
|
});
|
|
293
299
|
});
|
|
294
300
|
|
|
301
|
+
// ─── #11013 spec E, D-C (AC-3) — the widened guard ─────────────────────────
|
|
302
|
+
|
|
303
|
+
describe("#11013 D-C — the results page serves every flow with a results page", () => {
|
|
304
|
+
const validPayload = (): string =>
|
|
305
|
+
encodePermalink({ version: PERMALINK_VERSION, flowSlug: SLUG, answers: KNOWN_ANSWERS });
|
|
306
|
+
|
|
307
|
+
it("a recommending flow with no offers, no by-result rows and no ending renders ResultsClient", async () => {
|
|
308
|
+
const { offers: _offers, ...noOffers } = fixtureConfig();
|
|
309
|
+
mockGet.mockResolvedValueOnce({ ok: true, body: noOffers });
|
|
310
|
+
render(await Page({ params: Promise.resolve({ locale: "en", slug: SLUG, payload: validPayload() }) }));
|
|
311
|
+
expect(mockRedirect).not.toHaveBeenCalled();
|
|
312
|
+
expect(screen.getByTestId("flow-results")).toBeInTheDocument();
|
|
313
|
+
expect(screen.queryAllByTestId(/^recommendation-card-[a-z_]+$/)).toHaveLength(0);
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
it("a flow that is not recommending still redirects, offers or not", async () => {
|
|
317
|
+
mockGet.mockResolvedValueOnce({ ok: true, body: fixtureConfig({ mode: "qualifying" }) });
|
|
318
|
+
await expectRedirectTo(validPayload(), `/en/flows/${SLUG}`);
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
it("a recommending flow with an ending and offers still renders from a cold permalink (today's guard)", async () => {
|
|
322
|
+
mockGet.mockResolvedValueOnce({
|
|
323
|
+
ok: true,
|
|
324
|
+
body: fixtureConfig({ ending: { default: { kind: "screen", headline: { en: "Done" } } } } as Partial<FlowConfig>),
|
|
325
|
+
});
|
|
326
|
+
render(await Page({ params: Promise.resolve({ locale: "en", slug: SLUG, payload: validPayload() }) }));
|
|
327
|
+
expect(mockRedirect).not.toHaveBeenCalled();
|
|
328
|
+
expect(screen.getByTestId("flow-results")).toBeInTheDocument();
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
it("a recommending flow with an ending and no offers or rows redirects (no results page)", async () => {
|
|
332
|
+
const { offers: _offers, ...noOffers } = fixtureConfig();
|
|
333
|
+
mockGet.mockResolvedValueOnce({
|
|
334
|
+
ok: true,
|
|
335
|
+
body: { ...noOffers, ending: { default: { kind: "screen", headline: { en: "Done" } } } },
|
|
336
|
+
});
|
|
337
|
+
await expectRedirectTo(validPayload(), `/en/flows/${SLUG}`);
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
it("hands ResultsClient the frame's brand and the exit to the flow's landing", async () => {
|
|
341
|
+
mockGet.mockResolvedValueOnce({ ok: true, body: fixtureConfig() });
|
|
342
|
+
render(await Page({ params: Promise.resolve({ locale: "en", slug: SLUG, payload: validPayload() }) }));
|
|
343
|
+
expect(screen.getByTestId("flow-frame-exit-link").getAttribute("href")).toBe(`/en/flows/${SLUG}`);
|
|
344
|
+
expect(screen.getByTestId("flow-frame-title")).toHaveTextContent("Tell us about your team");
|
|
345
|
+
expect(screen.getByTestId("flow-frame-logomark")).toBeInTheDocument();
|
|
346
|
+
expect(screen.getByTestId("flow-frame-wordmark")).toBeInTheDocument();
|
|
347
|
+
expect(screen.queryByTestId("flow-frame-bar")).not.toBeInTheDocument();
|
|
348
|
+
});
|
|
349
|
+
});
|
|
350
|
+
|
|
295
351
|
describe("generateMetadata", () => {
|
|
296
352
|
it("resolves the page title from the compiled recommendation marker", async () => {
|
|
297
353
|
const payload = encodePermalink({
|
|
@@ -320,6 +376,41 @@ describe("generateMetadata", () => {
|
|
|
320
376
|
});
|
|
321
377
|
});
|
|
322
378
|
|
|
379
|
+
describe("#10990 AC-4 — a failed flow read redirects to the landing, never throws", () => {
|
|
380
|
+
const validPayload = (): string =>
|
|
381
|
+
encodePermalink({ version: PERMALINK_VERSION, flowSlug: SLUG, answers: KNOWN_ANSWERS });
|
|
382
|
+
|
|
383
|
+
it.each([
|
|
384
|
+
["a rejected read", () => mockGet.mockRejectedValue(new TypeError("fetch failed"))],
|
|
385
|
+
["a 2xx with no body", () => mockGet.mockResolvedValue({ ok: true, body: undefined })],
|
|
386
|
+
["a 2xx with {}", () => mockGet.mockResolvedValue({ ok: true, body: {} })],
|
|
387
|
+
["a 503", () => mockGet.mockResolvedValue({ ok: false, status: 503, body: null })],
|
|
388
|
+
["a 403", () => mockGet.mockResolvedValue({ ok: false, status: 403, body: null })],
|
|
389
|
+
])("%s: Page redirects to /en/flows/<slug> and generateMetadata is {}", async (_label, arrange) => {
|
|
390
|
+
arrange();
|
|
391
|
+
const payload = validPayload();
|
|
392
|
+
await expectRedirectTo(payload, `/en/flows/${SLUG}`);
|
|
393
|
+
await expect(
|
|
394
|
+
generateMetadata({ params: Promise.resolve({ locale: "en", slug: SLUG, payload }) }),
|
|
395
|
+
).resolves.toEqual({});
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
it("a read that never answers redirects after 5 seconds", async () => {
|
|
399
|
+
jest.useFakeTimers();
|
|
400
|
+
try {
|
|
401
|
+
mockGet.mockReturnValue(new Promise(() => undefined));
|
|
402
|
+
const rendering = Page({
|
|
403
|
+
params: Promise.resolve({ locale: "en", slug: SLUG, payload: validPayload() }),
|
|
404
|
+
});
|
|
405
|
+
const settled = expect(rendering).rejects.toThrow(`NEXT_REDIRECT:/en/flows/${SLUG}`);
|
|
406
|
+
await jest.advanceTimersByTimeAsync(5_000);
|
|
407
|
+
await settled;
|
|
408
|
+
} finally {
|
|
409
|
+
jest.useRealTimers();
|
|
410
|
+
}
|
|
411
|
+
});
|
|
412
|
+
});
|
|
413
|
+
|
|
323
414
|
// ─── #4842 AC-5 — the `?checkout=` return states (additive; the cases above
|
|
324
415
|
// are the regression floor and stay as they were) ───────────────────────────
|
|
325
416
|
|
|
@@ -358,12 +449,9 @@ describe("AC-5 (#4842) — ?checkout= return states render over the same recomme
|
|
|
358
449
|
|
|
359
450
|
function expectIdenticalFits(expected: ReturnType<typeof recommend>): void {
|
|
360
451
|
expect(expected.fits.length).toBeGreaterThan(0);
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
expect(screen.getAllByTestId(/^recommendation-card-[a-z_]+$/)).toHaveLength(
|
|
365
|
-
expected.fits.length,
|
|
366
|
-
);
|
|
452
|
+
// #11013 D-G — the top fit is the one card.
|
|
453
|
+
expect(screen.getByTestId(`recommendation-card-${expected.fits[0]!.offerKey}`)).toBeInTheDocument();
|
|
454
|
+
expect(screen.getAllByTestId(/^recommendation-card-[a-z_]+$/)).toHaveLength(1);
|
|
367
455
|
}
|
|
368
456
|
|
|
369
457
|
it("?checkout=success renders the success status line AND the identical fit cards", async () => {
|
package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/score.test.tsx
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
// oss: false
|
|
2
2
|
/**
|
|
3
|
-
* The respondent's own score on the results page (#10828
|
|
3
|
+
* The respondent's own score on the results page (#10828, redesigned by
|
|
4
|
+
* #11013 spec E, D-E; AC-3).
|
|
4
5
|
*
|
|
5
|
-
* A scored submission
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
6
|
+
* A scored submission opens with the points as a display number, "of {max}"
|
|
7
|
+
* and the total's Level name, the Level chart beside it — five columns
|
|
8
|
+
* numbered 01–05, the respondent's filled, a marker at their rounded share of
|
|
9
|
+
* all points — then Report Compiled over one `ScoreBar` per dimension in
|
|
10
|
+
* register order, each named by the stored Level name else "L{n}". An
|
|
11
|
+
* unscored magnet (no scoring, or no points to score) renders none of the
|
|
12
|
+
* three. The results view draws no bar.
|
|
10
13
|
*
|
|
11
14
|
* Mocks mirror `ResultsClient.no-commerce.test.tsx`; the translator echoes
|
|
12
|
-
* its
|
|
15
|
+
* its values so every interpolated message is observable.
|
|
13
16
|
*/
|
|
14
17
|
import { render, screen, within } from "@testing-library/react";
|
|
15
18
|
import type { FlowConfig } from "@working-theory/validation";
|
|
@@ -19,19 +22,23 @@ jest.mock("@working-theory/api-client", () => ({
|
|
|
19
22
|
flows: { get: jest.fn() },
|
|
20
23
|
}));
|
|
21
24
|
|
|
22
|
-
// The boundary under test is ResultsClient's render, not the
|
|
23
|
-
// (save.actions.test.ts) — the narrow-scope mock ResultsClient's suites carry.
|
|
25
|
+
// The boundary under test is ResultsClient's render, not the results-email
|
|
26
|
+
// action (save.actions.test.ts) — the narrow-scope mock ResultsClient's suites carry.
|
|
24
27
|
// eslint-disable-next-line no-restricted-syntax -- see comment above
|
|
25
28
|
jest.mock("../../../save.actions", () => ({
|
|
26
|
-
|
|
29
|
+
sendResultsEmailAction: jest.fn(),
|
|
27
30
|
}));
|
|
28
31
|
|
|
29
32
|
jest.mock("next-intl", () => ({
|
|
30
33
|
__esModule: true,
|
|
31
34
|
useTranslations:
|
|
32
35
|
() =>
|
|
33
|
-
(key: string, values?:
|
|
34
|
-
values
|
|
36
|
+
(key: string, values?: Record<string, unknown>): string =>
|
|
37
|
+
values === undefined
|
|
38
|
+
? key
|
|
39
|
+
: `${key}:${Object.entries(values)
|
|
40
|
+
.map(([k, v]) => `${k}=${String(v)}`)
|
|
41
|
+
.join(",")}`,
|
|
35
42
|
useMessages: () => ({}),
|
|
36
43
|
}));
|
|
37
44
|
|
|
@@ -40,8 +47,10 @@ import { ResultsClient } from "../ResultsClient";
|
|
|
40
47
|
const SLUG = "ai-readiness";
|
|
41
48
|
const en = (s: string) => ({ en: s });
|
|
42
49
|
|
|
43
|
-
|
|
44
|
-
|
|
50
|
+
type Scoring = NonNullable<FlowConfig["scoring"]>;
|
|
51
|
+
|
|
52
|
+
/** One question per dimension; each option's weight is the points it scores. */
|
|
53
|
+
function question(name: string, weights: Record<string, number>) {
|
|
45
54
|
return {
|
|
46
55
|
key: `s_${name}`,
|
|
47
56
|
type: "segmentation" as const,
|
|
@@ -49,131 +58,174 @@ function question(name: string) {
|
|
|
49
58
|
questions: [
|
|
50
59
|
{
|
|
51
60
|
name,
|
|
52
|
-
options:
|
|
53
|
-
{ value: "low", label: en("Low") },
|
|
54
|
-
{ value: "mid", label: en("Mid") },
|
|
55
|
-
{ value: "high", label: en("High") },
|
|
56
|
-
],
|
|
61
|
+
options: Object.keys(weights).map((value) => ({ value, label: en(value) })),
|
|
57
62
|
},
|
|
58
63
|
],
|
|
59
64
|
};
|
|
60
65
|
}
|
|
61
66
|
|
|
62
|
-
const QUESTIONS =
|
|
67
|
+
const QUESTIONS = {
|
|
68
|
+
// 30 of 73 in one dimension, so the total is the dimension's share.
|
|
69
|
+
reach: { low: 30, high: 73 },
|
|
70
|
+
craft: { low: 0, high: 10 },
|
|
71
|
+
} as const;
|
|
63
72
|
|
|
64
|
-
|
|
73
|
+
function scoring(names: string[] | undefined = ["Exploring", "Practising", "Scaling", "Leading"]): Scoring {
|
|
74
|
+
return {
|
|
75
|
+
version: 1,
|
|
76
|
+
points: Object.entries(QUESTIONS).map(([q, weights]) => ({
|
|
77
|
+
name: `p_${q}`,
|
|
78
|
+
question: q,
|
|
79
|
+
kind: "optionWeights" as const,
|
|
80
|
+
weights: { ...weights },
|
|
81
|
+
})),
|
|
82
|
+
scores: { total: { sum: ["p_reach", "p_craft"] } },
|
|
83
|
+
tiers: [{ key: "all", when: { score: "total", gte: 0 } }],
|
|
84
|
+
default: "all",
|
|
85
|
+
dimensions: [
|
|
86
|
+
{ key: "reach", name: "Reach", questions: ["reach"] },
|
|
87
|
+
{ key: "craft", name: "Craft", questions: ["craft"] },
|
|
88
|
+
],
|
|
89
|
+
...(names !== undefined ? { levels: { names } } : {}),
|
|
90
|
+
} satisfies Scoring;
|
|
91
|
+
}
|
|
65
92
|
|
|
66
|
-
|
|
67
|
-
version: 1,
|
|
68
|
-
points: QUESTIONS.map((q) => ({
|
|
69
|
-
name: `p_${q}`,
|
|
70
|
-
question: q,
|
|
71
|
-
kind: "optionWeights" as const,
|
|
72
|
-
weights: { low: 0, mid: 2, high: 4 },
|
|
73
|
-
})),
|
|
74
|
-
scores: { total: { sum: QUESTIONS.map((q) => `p_${q}`) } },
|
|
75
|
-
tiers: [{ key: "all", when: { score: "total", gte: 0 } }],
|
|
76
|
-
default: "all",
|
|
77
|
-
// Register order is not alphabetical: the page keeps it.
|
|
78
|
-
dimensions: [
|
|
79
|
-
{ key: "strategy", name: "Strategy", questions: ["vision"] },
|
|
80
|
-
{ key: "data", name: "Data", questions: ["data"] },
|
|
81
|
-
{ key: "people", name: "People", questions: ["skills"] },
|
|
82
|
-
],
|
|
83
|
-
levels: { names: ["Exploring", "Practising", "Scaling", "Leading"] },
|
|
84
|
-
} satisfies Scoring;
|
|
85
|
-
|
|
86
|
-
function config(scoring: Scoring | undefined): FlowConfig {
|
|
93
|
+
function config(scoringBlock: Scoring | undefined): FlowConfig {
|
|
87
94
|
return {
|
|
88
95
|
slug: SLUG,
|
|
89
96
|
defaultLocale: "en",
|
|
90
97
|
mode: "recommending",
|
|
91
|
-
steps: QUESTIONS.map(question),
|
|
92
|
-
...(
|
|
93
|
-
offers: [
|
|
94
|
-
{
|
|
95
|
-
key: "workshop",
|
|
96
|
-
copy: { name: en("Workshop") },
|
|
97
|
-
price: { kind: "label", label: en("On request") },
|
|
98
|
-
rules: [{ when: { answer: "vision", in: ["low", "mid", "high"] }, reason: en("Start here.") }],
|
|
99
|
-
},
|
|
100
|
-
],
|
|
98
|
+
steps: Object.entries(QUESTIONS).map(([q, weights]) => question(q, { ...weights })),
|
|
99
|
+
...(scoringBlock !== undefined ? { scoring: scoringBlock } : {}),
|
|
101
100
|
recommendation: { key: "result", copy: { title: en("Your AI readiness") } },
|
|
102
101
|
} as FlowConfig;
|
|
103
102
|
}
|
|
104
103
|
|
|
105
|
-
|
|
106
|
-
|
|
104
|
+
function renderResults(cfg: FlowConfig, answers: Record<string, string>): void {
|
|
105
|
+
render(<ResultsClient config={cfg} locale="en" answers={answers} slug={SLUG} payload="v1-abc" />);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function columns(): HTMLElement[] {
|
|
109
|
+
return within(screen.getByTestId("flow-level-chart")).getAllByTestId(/^flow-level-chart-column-\d$/);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function filledColumns(): number[] {
|
|
113
|
+
return columns()
|
|
114
|
+
.filter((col) => col.getAttribute("data-filled") === "true")
|
|
115
|
+
.map((col) => Number(col.getAttribute("data-level")));
|
|
116
|
+
}
|
|
107
117
|
|
|
108
|
-
|
|
109
|
-
|
|
118
|
+
/** The AC's walk: only `reach` scores, so the total is 30 of 73 at `low`. */
|
|
119
|
+
function reachOnly(names?: string[]): Scoring {
|
|
120
|
+
const base = scoring(names);
|
|
121
|
+
return { ...base, points: base.points.slice(0, 1), scores: { total: { sum: ["p_reach"] } } };
|
|
110
122
|
}
|
|
111
123
|
|
|
112
|
-
describe("
|
|
113
|
-
|
|
114
|
-
|
|
124
|
+
describe("AC-3 — the score and the Level chart (decisions 10, 11)", () => {
|
|
125
|
+
const SCORED = config(reachOnly());
|
|
126
|
+
|
|
127
|
+
it("a walk at 30 of 73 renders '30', of {max}, the total's Level name, and no bar", () => {
|
|
128
|
+
renderResults(SCORED, { reach: "low", craft: "low" });
|
|
115
129
|
const total = screen.getByTestId("flow-results-score-total");
|
|
116
|
-
expect(within(total).getByTestId("flow-results-score-total-points")).toHaveTextContent(
|
|
117
|
-
|
|
130
|
+
expect(within(total).getByTestId("flow-results-score-total-points")).toHaveTextContent(/^30$/);
|
|
131
|
+
expect(within(total).getByText("scoreOutOf:max=73")).toBeInTheDocument();
|
|
132
|
+
// 30 / 73 = 41.1% of all points is Level 3.
|
|
118
133
|
expect(within(total).getByTestId("flow-results-score-total-level")).toHaveTextContent("Scaling");
|
|
134
|
+
expect(screen.queryByTestId("flow-frame-bar")).not.toBeInTheDocument();
|
|
135
|
+
expect(screen.queryAllByTestId("flow-results-score-total-bar")).toHaveLength(0);
|
|
119
136
|
});
|
|
120
137
|
|
|
121
|
-
it("renders
|
|
122
|
-
renderResults(
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
expect(
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
"2 / 4, Scaling",
|
|
131
|
-
"4 / 4, Leading",
|
|
132
|
-
]);
|
|
133
|
-
expect(screen.getByTestId("flow-results-score-dimension-data-level")).toHaveTextContent("Scaling");
|
|
138
|
+
it("the chart renders five columns labelled 01 to 05 with only column 3 filled and its marker at 41%", () => {
|
|
139
|
+
renderResults(SCORED, { reach: "low", craft: "low" });
|
|
140
|
+
const chart = screen.getByTestId("flow-level-chart");
|
|
141
|
+
expect(chart.getAttribute("aria-label")).toBe("levelChartLabel:level=3,pct=41");
|
|
142
|
+
expect(columns().map((col) => col.textContent)).toEqual(["01", "02", "03", "04", "05"]);
|
|
143
|
+
expect(filledColumns()).toEqual([3]);
|
|
144
|
+
const marker = within(chart).getByTestId("flow-level-chart-marker");
|
|
145
|
+
expect(marker.parentElement?.getAttribute("style")).toContain("--flow-level-marker: 41%");
|
|
146
|
+
expect(marker).toHaveTextContent("41%");
|
|
134
147
|
});
|
|
135
148
|
|
|
136
|
-
it("
|
|
137
|
-
|
|
149
|
+
it("at 40% exactly column 3 is filled; at 100% column 5", () => {
|
|
150
|
+
const fifths = config({ ...scoring(), points: [{ name: "p_reach", question: "reach", kind: "optionWeights", weights: { low: 40, high: 100 } }], scores: { total: { sum: ["p_reach"] } } });
|
|
151
|
+
const { unmount } = render(
|
|
152
|
+
<ResultsClient config={fifths} locale="en" answers={{ reach: "low", craft: "low" }} slug={SLUG} payload="v1-a" />,
|
|
153
|
+
);
|
|
154
|
+
expect(filledColumns()).toEqual([3]);
|
|
155
|
+
expect(screen.getByTestId("flow-level-chart").getAttribute("aria-label")).toBe("levelChartLabel:level=3,pct=40");
|
|
156
|
+
unmount();
|
|
157
|
+
render(
|
|
158
|
+
<ResultsClient config={fifths} locale="en" answers={{ reach: "high", craft: "low" }} slug={SLUG} payload="v1-b" />,
|
|
159
|
+
);
|
|
160
|
+
expect(filledColumns()).toEqual([5]);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
it("a Level 5 with four stored names reads the fallback label, never names[3]", () => {
|
|
164
|
+
renderResults(SCORED, { reach: "high", craft: "low" });
|
|
165
|
+
expect(screen.getByTestId("flow-results-score-total-level")).toHaveTextContent("label:n=5");
|
|
166
|
+
expect(screen.getByTestId("flow-results-score-total-level")).not.toHaveTextContent("Leading");
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it("a five-name register names Level 5 by its fifth name", () => {
|
|
170
|
+
renderResults(config(reachOnly(["Exploring", "Practising", "Scaling", "Leading", "Pioneering"])), {
|
|
171
|
+
reach: "high",
|
|
172
|
+
craft: "low",
|
|
173
|
+
});
|
|
174
|
+
expect(screen.getByTestId("flow-results-score-total-level")).toHaveTextContent("Pioneering");
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it("renders the heading and body above the score", () => {
|
|
178
|
+
renderResults(SCORED, { reach: "low", craft: "low" });
|
|
138
179
|
const heading = screen.getByRole("heading", { name: "Your AI readiness" });
|
|
139
180
|
const score = screen.getByTestId("flow-results-score");
|
|
140
|
-
const card = screen.getByTestId("recommendation-card-workshop");
|
|
141
181
|
expect(heading.compareDocumentPosition(score) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
|
|
142
|
-
expect(score.compareDocumentPosition(card) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
|
|
143
182
|
});
|
|
183
|
+
});
|
|
144
184
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
renderResults(config(
|
|
148
|
-
|
|
185
|
+
describe("AC-3 — Report Compiled (decision 12)", () => {
|
|
186
|
+
it("heads one ScoreBar per dimension in register order, each named by the stored name else L{n}", () => {
|
|
187
|
+
renderResults(config(scoring()), { reach: "low", craft: "high" });
|
|
188
|
+
const report = screen.getByTestId("flow-results-report-compiled");
|
|
189
|
+
expect(within(report).getByRole("heading", { name: "reportCompiled" })).toBeInTheDocument();
|
|
190
|
+
const meters = within(report).getAllByRole("meter");
|
|
191
|
+
expect(meters.map((m) => m.getAttribute("aria-label"))).toEqual(["Reach", "Craft"]);
|
|
192
|
+
expect(meters.map((m) => m.getAttribute("aria-valuetext"))).toEqual([
|
|
193
|
+
// 30 / 73 = 41% is Level 3.
|
|
194
|
+
"30 / 73, Scaling",
|
|
195
|
+
// 100% is Level 5, which a four-name register leaves to the short fallback.
|
|
196
|
+
"10 / 10, levelShort:n=5",
|
|
197
|
+
]);
|
|
198
|
+
// The total is a display number, not a meter.
|
|
199
|
+
expect(screen.getAllByRole("meter")).toHaveLength(2);
|
|
149
200
|
});
|
|
150
201
|
|
|
151
|
-
it("renders
|
|
152
|
-
const { dimensions: _dimensions, ...flat } =
|
|
153
|
-
renderResults(config(flat));
|
|
154
|
-
expect(
|
|
202
|
+
it("renders no Report Compiled for a register with no dimensions", () => {
|
|
203
|
+
const { dimensions: _dimensions, ...flat } = scoring();
|
|
204
|
+
renderResults(config(flat), { reach: "low", craft: "low" });
|
|
205
|
+
expect(screen.getByTestId("flow-results-score")).toBeInTheDocument();
|
|
206
|
+
expect(screen.queryByTestId("flow-results-report-compiled")).not.toBeInTheDocument();
|
|
155
207
|
});
|
|
156
208
|
});
|
|
157
209
|
|
|
158
|
-
describe("
|
|
159
|
-
it(
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
expect(screen.getByTestId("recommendation-card-workshop")).toBeInTheDocument();
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
it("renders the cards only for a register that scores no points", () => {
|
|
167
|
-
renderResults(
|
|
210
|
+
describe("AC-3 — an unscored magnet (decision 19)", () => {
|
|
211
|
+
it.each([
|
|
212
|
+
["no scoring", config(undefined)],
|
|
213
|
+
[
|
|
214
|
+
"a max of 0",
|
|
168
215
|
config({
|
|
169
|
-
...
|
|
216
|
+
...scoring(),
|
|
170
217
|
points: [],
|
|
171
218
|
scores: {},
|
|
172
|
-
tiers: [{ key: "all", when: { answer: "
|
|
219
|
+
tiers: [{ key: "all", when: { answer: "reach", in: ["low", "high"] } }],
|
|
173
220
|
dimensions: [],
|
|
174
221
|
}),
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
222
|
+
],
|
|
223
|
+
])("%s: none of the score, the chart or Report Compiled render", (_label, cfg) => {
|
|
224
|
+
renderResults(cfg, { reach: "low", craft: "low" });
|
|
225
|
+
expect(screen.getByTestId("flow-results")).toBeInTheDocument();
|
|
226
|
+
expect(screen.queryByTestId("flow-results-score")).not.toBeInTheDocument();
|
|
227
|
+
expect(screen.queryByTestId("flow-level-chart")).not.toBeInTheDocument();
|
|
228
|
+
expect(screen.queryByTestId("flow-results-report-compiled")).not.toBeInTheDocument();
|
|
229
|
+
expect(screen.queryAllByRole("meter")).toHaveLength(0);
|
|
178
230
|
});
|
|
179
231
|
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// oss: false
|
|
2
|
+
/**
|
|
3
|
+
* meeting-seam.ts — where the results page meets scheduling (#11013 D-K).
|
|
4
|
+
*
|
|
5
|
+
* The results page is signal-collectors'; the Meeting card's data lives in
|
|
6
|
+
* `lib/meetings.tsx`, a scheduling file, and a signal-collectors scaffold may
|
|
7
|
+
* omit scheduling (`composeModuleSet`). A base file may not import a
|
|
8
|
+
* scheduling file — `paidModuleTemplateExclusions()` sweeps every importer of
|
|
9
|
+
* a paid module's `ownedFiles` out of the keyless snapshot, and a scaffold
|
|
10
|
+
* without scheduling has neither the file nor the `/meet` routes. So the
|
|
11
|
+
* dependency points the other way, on the `checkout-seam.ts` pattern:
|
|
12
|
+
* scheduling's `results/layout.tsx` (one segment above commerce's
|
|
13
|
+
* `results/[payload]/layout.tsx`, so the two nest) reads the served flow and
|
|
14
|
+
* the workspace's meetings on the server and provides AT MOST the one meeting
|
|
15
|
+
* the magnet's `conversionLink` names through `ResultsMeetingContext`, and
|
|
16
|
+
* `ResultsClient` reads it. Next renders a segment's `layout.tsx` only when
|
|
17
|
+
* the file exists, so a scaffold without scheduling has no provider, the
|
|
18
|
+
* context stays `undefined`, and an `appointment` link renders no card.
|
|
19
|
+
*
|
|
20
|
+
* Only a structural type and the context live here; nothing in this file
|
|
21
|
+
* names a scheduling module.
|
|
22
|
+
*/
|
|
23
|
+
import { createContext } from "react";
|
|
24
|
+
|
|
25
|
+
/** The one meeting the results page may show, mapped by the scheduling layout. */
|
|
26
|
+
export interface ResultsMeeting {
|
|
27
|
+
slug: string;
|
|
28
|
+
title: string;
|
|
29
|
+
description?: string;
|
|
30
|
+
/** The meeting's own page, locale-prefixed (`/<locale>/meet/<slug>`). */
|
|
31
|
+
href: string;
|
|
32
|
+
/** `/meet`'s own button label, "Book {n} min" (`schedule.bookLength`). */
|
|
33
|
+
bookLabel: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const ResultsMeetingContext = createContext<ResultsMeeting | undefined>(undefined);
|