create-ailk 0.34.1 → 0.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/component-catalog.json +37 -4
- package/component-catalog.md +11 -9
- 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/lib/env-catalog.js +8 -0
- 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 +32 -3
- package/dist/template-record.js +2 -0
- package/dist/topology.d.ts +4 -4
- package/dist/topology.js +104 -60
- package/dist/update.js +11 -0
- package/package.json +3 -3
- package/templates/.env.example +21 -0
- package/templates/apps/api/.env.example +7 -0
- package/templates/apps/api/CLAUDE.md +14 -9
- package/templates/apps/mcp/CLAUDE.md +18 -7
- package/templates/apps/web/.env.example +16 -0
- package/templates/apps/web/CLAUDE.md +46 -5
- package/templates/apps/web/app/[locale]/(auth)/__tests__/password-reset.test.tsx +2 -0
- package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/page.test.tsx +52 -1
- package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/remembered-method.test.ts +43 -0
- package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/sign-in-card.test.tsx +108 -1
- package/templates/apps/web/app/[locale]/(auth)/sign-in/page.tsx +36 -3
- package/templates/apps/web/app/[locale]/(auth)/sign-in/remembered-method.ts +37 -0
- package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-card.tsx +90 -33
- package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-text.ts +9 -4
- package/templates/apps/web/app/[locale]/(authed)/__tests__/gate.test.tsx +79 -348
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/billing.test.tsx +12 -1
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/hub-mode.test.tsx +55 -2
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/item.test.tsx +43 -0
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout-sign-out.test.tsx +10 -5
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +6 -5
- package/templates/apps/web/app/[locale]/(authed)/account/account-frame.tsx +1 -1
- package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +60 -6
- package/templates/apps/web/app/[locale]/(authed)/account/billing-source.ts +32 -3
- package/templates/apps/web/app/[locale]/(authed)/account/connect/__tests__/page.test.tsx +8 -1
- package/templates/apps/web/app/[locale]/(authed)/account/connect/page.tsx +7 -3
- package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/phone-verification.test.tsx +215 -0
- package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/seam-imports.test.ts +65 -0
- package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +47 -0
- package/templates/apps/web/app/[locale]/(authed)/account/general/phone-actions.ts +122 -0
- package/templates/apps/web/app/[locale]/(authed)/account/general/phone-verification.tsx +214 -0
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +6 -1
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/invitation-id.test.ts +35 -0
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/page.test.tsx +266 -0
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/actions.ts +116 -0
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/invitation-id.ts +12 -0
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/page.tsx +154 -0
- package/templates/apps/web/app/[locale]/(authed)/account/layout.tsx +6 -4
- package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +3 -1
- package/templates/apps/web/app/[locale]/(authed)/layout.tsx +15 -13
- package/templates/apps/web/app/[locale]/(authed)/signed-out-gate.generated.tsx +20 -52
- 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 +42 -76
- package/templates/apps/web/app/[locale]/purchase/__tests__/success.test.tsx +50 -0
- package/templates/apps/web/app/[locale]/purchase/success/page.tsx +48 -7
- package/templates/apps/web/app/api/auth/hub/__tests__/entry-routes.test.ts +749 -0
- package/templates/apps/web/app/api/auth/hub/authorize/__tests__/route.test.ts +189 -6
- package/templates/apps/web/app/api/auth/hub/authorize/route.ts +101 -31
- package/templates/apps/web/app/api/auth/hub/continuation.ts +51 -2
- package/templates/apps/web/app/api/auth/hub/email/route.ts +111 -0
- package/templates/apps/web/app/api/auth/hub/entry-shared.ts +163 -0
- package/templates/apps/web/app/api/auth/hub/purchase/route.ts +230 -0
- package/templates/apps/web/app/api/auth/hub/purchase-link/route.ts +174 -0
- package/templates/apps/web/app/api/auth/hub/sign-up/route.ts +60 -0
- package/templates/apps/web/app/api/auth/hub/sign-up-evidence.ts +97 -0
- package/templates/apps/web/app/api/hub-session/__tests__/routes.test.ts +475 -7
- package/templates/apps/web/app/api/hub-session/callback/route.ts +13 -47
- package/templates/apps/web/app/api/hub-session/email/route.ts +125 -0
- package/templates/apps/web/app/api/hub-session/one-tap/nonce/route.ts +49 -0
- package/templates/apps/web/app/api/hub-session/one-tap/route.ts +106 -0
- package/templates/apps/web/app/api/hub-session/open/route.ts +111 -0
- package/templates/apps/web/app/api/hub-session/sign-in/route.ts +23 -40
- package/templates/apps/web/app/api/hub-session/sign-out/route.ts +1 -10
- 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/auth.ts +133 -6
- package/templates/apps/web/components/sign-out-trigger.tsx +1 -1
- package/templates/apps/web/lib/__tests__/auth-email.test.ts +141 -0
- package/templates/apps/web/lib/__tests__/auth-phone.test.ts +445 -0
- package/templates/apps/web/lib/__tests__/auth-sms.test.ts +140 -0
- package/templates/apps/web/lib/__tests__/fixtures/tsconfig.flow.json +18 -0
- package/templates/apps/web/lib/__tests__/site-header.test.ts +13 -0
- package/templates/apps/web/lib/__tests__/telemetry-scrub.test.ts +19 -1
- package/templates/apps/web/lib/account-config.ts +24 -9
- package/templates/apps/web/lib/auth-email.ts +62 -6
- package/templates/apps/web/lib/auth-env.ts +13 -0
- package/templates/apps/web/lib/auth-sms.ts +180 -0
- package/templates/apps/web/lib/hub-session/__tests__/hub-session.test.ts +28 -0
- package/templates/apps/web/lib/hub-session/__tests__/spoke-sign-in.test.tsx +332 -0
- package/templates/apps/web/lib/hub-session/config.ts +7 -1
- package/templates/apps/web/lib/hub-session/entry.ts +238 -0
- package/templates/apps/web/lib/hub-session/index.ts +1 -4
- package/templates/apps/web/lib/hub-session/one-tap.tsx +148 -0
- package/templates/apps/web/lib/hub-session/session.ts +120 -2
- package/templates/apps/web/lib/hub-session/spoke-sign-in.tsx +277 -0
- package/templates/apps/web/lib/site-header.ts +14 -1
- package/templates/apps/web/lib/site-listing.ts +7 -0
- package/templates/apps/web/lib/telemetry-scrub.ts +11 -0
- package/templates/apps/web/lib/topology.generated.ts +39 -0
- package/templates/apps/web/messages/en.json +125 -21
- package/templates/apps/web/middleware.ts +34 -2
- package/templates/apps/web/security-headers.config.ts +21 -0
- package/versions.json +47 -47
- package/templates/apps/web/app/[locale]/(authed)/sign-in-gate.tsx +0 -162
- package/templates/apps/web/components/signed-in-nav.tsx +0 -79
- package/templates/apps/web/lib/hub-session/__tests__/sign-in-gate.test.tsx +0 -180
- package/templates/apps/web/lib/hub-session/sign-in-gate.tsx +0 -162
|
@@ -1,25 +1,22 @@
|
|
|
1
1
|
// signed-out-gate.generated.tsx — what the (authed) group shows a signed-out visitor.
|
|
2
2
|
//
|
|
3
3
|
// GENERATED by create-ailk for this site's topology and sign-in mode (#7894).
|
|
4
|
-
// Do not edit: every scaffold rewrites it. A hub
|
|
5
|
-
//
|
|
6
|
-
// through its hub (`--hub-sign-in`)
|
|
4
|
+
// Do not edit: every scaffold rewrites it. A hub redirects to its own
|
|
5
|
+
// /sign-in (an account path with no sign-in method on says so in place); a
|
|
6
|
+
// spoke that signs in through its hub (`--hub-sign-in`) redirects to its
|
|
7
|
+
// hub-session sign-in route.
|
|
7
8
|
import { localeHref } from "@working-theory/ui";
|
|
8
9
|
import { Button, Heading, Link, Text } from "@working-theory/ui/primitives";
|
|
9
|
-
import type { AuthPanelProvider } from "@working-theory/ui/sections";
|
|
10
10
|
import { readLocales } from "@working-theory/web-i18n";
|
|
11
|
+
import { redirect } from "next/navigation";
|
|
11
12
|
import { getTranslations } from "next-intl/server";
|
|
12
13
|
import type { ReactElement } from "react";
|
|
13
14
|
|
|
14
|
-
import { legalFootnote } from "../(auth)/legal-footnote";
|
|
15
|
-
import { resolveSignInCardText } from "../(auth)/sign-in/sign-in-text";
|
|
16
15
|
import { getActiveProviderIds } from "../../../lib/auth-env";
|
|
17
16
|
import { isAccountPath } from "../../../lib/auth-routes";
|
|
18
|
-
import { siteLogo } from "../../../lib/site-logo";
|
|
19
17
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const SUPPORTED_PROVIDERS: readonly AuthPanelProvider[] = ["google", "github"];
|
|
18
|
+
/** The methods a member signs in with on /sign-in's card. */
|
|
19
|
+
const MEMBER_METHODS: readonly string[] = ["google", "github", "magic-link"];
|
|
23
20
|
|
|
24
21
|
export interface SignedOutGateProps {
|
|
25
22
|
locale: string;
|
|
@@ -31,23 +28,17 @@ export async function SignedOutGate({
|
|
|
31
28
|
locale,
|
|
32
29
|
requestHeaders,
|
|
33
30
|
}: SignedOutGateProps): Promise<ReactElement> {
|
|
34
|
-
// No `x-pathname`, no locale read: a render outside the middleware
|
|
35
|
-
// the
|
|
31
|
+
// No `x-pathname`, no locale read: a render outside the middleware
|
|
32
|
+
// redirects to the bare /sign-in without touching the locale config.
|
|
36
33
|
const pathname = requestHeaders.get("x-pathname");
|
|
37
34
|
const isAccount =
|
|
38
35
|
pathname !== null && isAccountPath(pathname, readLocales());
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
namespace: isAccount ? "account.gate" : "waitlistDashboard.gate",
|
|
42
|
-
});
|
|
43
|
-
const active = getActiveProviderIds();
|
|
44
|
-
const emailLink = active.includes("magic-link");
|
|
45
|
-
const providers = active.filter((id): id is AuthPanelProvider =>
|
|
46
|
-
(SUPPORTED_PROVIDERS as readonly string[]).includes(id),
|
|
36
|
+
const hasMemberMethod = getActiveProviderIds().some((id) =>
|
|
37
|
+
MEMBER_METHODS.includes(id),
|
|
47
38
|
);
|
|
48
|
-
const signInPath = localeHref(locale, "/sign-in");
|
|
49
39
|
|
|
50
|
-
if (isAccount &&
|
|
40
|
+
if (isAccount && !hasMemberMethod) {
|
|
41
|
+
const t = await getTranslations({ locale, namespace: "account.gate" });
|
|
51
42
|
return (
|
|
52
43
|
<div
|
|
53
44
|
className="flex min-h-screen flex-col items-center justify-center gap-4 py-section text-center"
|
|
@@ -75,35 +66,12 @@ export async function SignedOutGate({
|
|
|
75
66
|
);
|
|
76
67
|
}
|
|
77
68
|
|
|
78
|
-
//
|
|
79
|
-
//
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
text,
|
|
86
|
-
emailLink,
|
|
87
|
-
...(isAccount
|
|
88
|
-
? {
|
|
89
|
-
logo: siteLogo(),
|
|
90
|
-
prospect: { ...text.prospect, href: localeHref(locale, "/sign-up") },
|
|
91
|
-
footnote: legalFootnote(locale, text.acknowledgement),
|
|
92
|
-
}
|
|
93
|
-
: {}),
|
|
94
|
-
}
|
|
95
|
-
: undefined;
|
|
96
|
-
|
|
97
|
-
return (
|
|
98
|
-
<SignInGate
|
|
99
|
-
labels={{
|
|
100
|
-
emptyHeadline: t("emptyHeadline"),
|
|
101
|
-
emptyDescription: t("emptyDescription"),
|
|
102
|
-
signInLinkLabel: t("signInLink"),
|
|
103
|
-
}}
|
|
104
|
-
signInPath={signInPath}
|
|
105
|
-
providers={providers}
|
|
106
|
-
{...(card ? { card } : {})}
|
|
107
|
-
/>
|
|
69
|
+
// Every other signed-out render is a redirect to the sign-in card, with the
|
|
70
|
+
// requested path as `next` (#11095 D3): `/sign-in` sanitizes it.
|
|
71
|
+
const signInPath = localeHref(locale, "/sign-in");
|
|
72
|
+
redirect(
|
|
73
|
+
pathname === null
|
|
74
|
+
? signInPath
|
|
75
|
+
: `${signInPath}?next=${encodeURIComponent(pathname)}`,
|
|
108
76
|
);
|
|
109
77
|
}
|
|
@@ -57,7 +57,20 @@
|
|
|
57
57
|
* platform default with the locale's `/terms` and `/privacy` links
|
|
58
58
|
* (`consentPoliciesFor`, the map every agreement surface uses); a `message`
|
|
59
59
|
* step is shown but not counted in "Step N of M"; `hiddenValues` and `header`
|
|
60
|
-
* pass through from the page
|
|
60
|
+
* pass through from the page, as do the frame's `brand`, `exit` and
|
|
61
|
+
* `presentation` (#11013 D-A — the page builds the brand on the server and
|
|
62
|
+
* hands it down; the walk's Esc leaves for where it was entered from).
|
|
63
|
+
*
|
|
64
|
+
* The results page's reach (#11013 D-J): a recommending flow with no
|
|
65
|
+
* `ending` has a results page (`hasResultsPage`, spec C), whether or not it
|
|
66
|
+
* carries `offers`. `isRecommending` keeps its `offers` condition — its three
|
|
67
|
+
* readers are kept as they were, so a recommending `user` magnet still lands
|
|
68
|
+
* on sign-up at once (`goToSignUp`) — and a separate predicate,
|
|
69
|
+
* `showsResultsPage`, drives only the results push: a walk changes landing
|
|
70
|
+
* only when it is recommending with no ending, no `offers`, no sign-up
|
|
71
|
+
* hand-off and no deliverable (`deliveredRef`), and then pushes the results
|
|
72
|
+
* permalink instead of ending in the stepper's completed state. Every other
|
|
73
|
+
* walk lands where it landed before. When the config carries an `ending`, it is the
|
|
61
74
|
* one ending: `onCompleted` is not passed (so neither `thankYou` nor a
|
|
62
75
|
* recommending flow's permalink runs), and on the completing response the
|
|
63
76
|
* client picks the outcome from the answers it accumulated
|
|
@@ -87,6 +100,7 @@
|
|
|
87
100
|
* bundle, the same reasoning `middleware.ts` already documents for the
|
|
88
101
|
* Edge runtime) before it ever reaches the template literal.
|
|
89
102
|
*/
|
|
103
|
+
import type { FlowFrameBrand, FlowFrameExit, FlowFramePresentation } from "@working-theory/ui";
|
|
90
104
|
import { Button, Heading, Link, localeHref, Text } from "@working-theory/ui";
|
|
91
105
|
import { VideoEmbed } from "@working-theory/ui/blocks";
|
|
92
106
|
import {
|
|
@@ -112,6 +126,7 @@ import {
|
|
|
112
126
|
flowSitePathSchema,
|
|
113
127
|
flowStepDeliverableSchema,
|
|
114
128
|
flowStepNextSchema,
|
|
129
|
+
hasResultsPage,
|
|
115
130
|
hiddenAnswers,
|
|
116
131
|
PERMALINK_VERSION,
|
|
117
132
|
pruneHiddenState,
|
|
@@ -139,8 +154,14 @@ interface Props {
|
|
|
139
154
|
slug: string;
|
|
140
155
|
/** #8840 D9 — page-supplied `hidden` field values (a posting's slug). */
|
|
141
156
|
hiddenValues?: Readonly<Record<string, string>>;
|
|
142
|
-
/** #8840 D9 — the walk's back arrow, above the step. */
|
|
157
|
+
/** #8840 D9 — the walk's back arrow, above the step. Not rendered beside `brand` / `exit`. */
|
|
143
158
|
header?: ReactNode;
|
|
159
|
+
/** #11013 D-A — the frame's brand header (logomark, wordmark, the landing title). */
|
|
160
|
+
brand?: FlowFrameBrand;
|
|
161
|
+
/** #11013 D-A — the one `Esc ×` exit, to where the walk was entered from. */
|
|
162
|
+
exit?: FlowFrameExit;
|
|
163
|
+
/** #11013 decision 2 — a bounded window at `md:`+ (the default) or edge to edge. */
|
|
164
|
+
presentation?: FlowFramePresentation;
|
|
144
165
|
}
|
|
145
166
|
|
|
146
167
|
const DEFAULT_LOCALE = "en";
|
|
@@ -216,6 +237,9 @@ export function FlowStepperClient({
|
|
|
216
237
|
slug,
|
|
217
238
|
hiddenValues,
|
|
218
239
|
header,
|
|
240
|
+
brand,
|
|
241
|
+
exit,
|
|
242
|
+
presentation,
|
|
219
243
|
}: Props): ReactElement {
|
|
220
244
|
const t = useTranslations("flow");
|
|
221
245
|
const router = useRouter();
|
|
@@ -225,6 +249,10 @@ export function FlowStepperClient({
|
|
|
225
249
|
// client never routes to.
|
|
226
250
|
const isRecommending =
|
|
227
251
|
config.mode === "recommending" && config.offers !== undefined;
|
|
252
|
+
// #11013 D-J — spec C's predicate: the flow has a results page (recommending,
|
|
253
|
+
// no ending), offers or not. It drives only the results push below;
|
|
254
|
+
// `isRecommending`'s own readers are unchanged.
|
|
255
|
+
const showsResultsPage = hasResultsPage(config);
|
|
228
256
|
// #10616 D4 — a flow whose scoring maps at least one tier to a thank-you
|
|
229
257
|
// page: completion may redirect there, so `onCompleted` is passed.
|
|
230
258
|
const hasTierThankYou =
|
|
@@ -244,6 +272,9 @@ export function FlowStepperClient({
|
|
|
244
272
|
// has left for the sign-up landing, so no other ending races it.
|
|
245
273
|
const emailRef = useRef<string | undefined>(undefined);
|
|
246
274
|
const signingUpRef = useRef(false);
|
|
275
|
+
// #11013 D-J — set when the completing response (or the config) carried a
|
|
276
|
+
// deliverable: the walk keeps it and never leaves for the results page.
|
|
277
|
+
const deliveredRef = useRef(false);
|
|
247
278
|
// #8840 D9 — a config with an `ending` ends on it, never on `thankYou` or
|
|
248
279
|
// the permalink; the chosen screen is drawn in the finished card.
|
|
249
280
|
const endingWins = config.ending !== undefined;
|
|
@@ -268,6 +299,7 @@ export function FlowStepperClient({
|
|
|
268
299
|
// #8848 D8 — a deliverable (or a gated file's by-email line) is never
|
|
269
300
|
// lost to a navigation.
|
|
270
301
|
const hasDeliverable = raw !== undefined || config.deliverable !== undefined;
|
|
302
|
+
deliveredRef.current = hasDeliverable;
|
|
271
303
|
if (!hasDeliverable && (await goToSignUp(result.response))) return result;
|
|
272
304
|
const delivered = showDeliverable(raw);
|
|
273
305
|
if (endingWins) showEnding(delivered);
|
|
@@ -440,7 +472,9 @@ export function FlowStepperClient({
|
|
|
440
472
|
}
|
|
441
473
|
}
|
|
442
474
|
|
|
443
|
-
|
|
475
|
+
// #11013 D-J — the results push: a flow with `offers`, as before, or one
|
|
476
|
+
// whose results page is reached with no deliverable in hand.
|
|
477
|
+
if (isRecommending || (showsResultsPage && !deliveredRef.current)) {
|
|
444
478
|
// D1 (hidden-step pruning) — apply the shipped visibility resolver to
|
|
445
479
|
// the accumulated state before encoding, so an abandoned branch's
|
|
446
480
|
// answers never reach the URL.
|
|
@@ -560,7 +594,8 @@ export function FlowStepperClient({
|
|
|
560
594
|
locale={locale}
|
|
561
595
|
messages={messages}
|
|
562
596
|
onSubmitStep={handleSubmitStep}
|
|
563
|
-
{...(!endingWins &&
|
|
597
|
+
{...(!endingWins &&
|
|
598
|
+
(thankYou !== undefined || isRecommending || showsResultsPage || hasTierThankYou)
|
|
564
599
|
? { onCompleted: handleCompleted }
|
|
565
600
|
: {})}
|
|
566
601
|
// #8840 D9 — the locale's policy links, the input-step count, and the
|
|
@@ -569,6 +604,10 @@ export function FlowStepperClient({
|
|
|
569
604
|
uncountedStepKeys={config.steps.filter((step) => step.type === "message").map((step) => step.key)}
|
|
570
605
|
{...(hiddenValues !== undefined ? { hiddenValues } : {})}
|
|
571
606
|
{...(header !== undefined ? { header } : {})}
|
|
607
|
+
// #11013 D-A — the frame's brand header, exit and presentation, unchanged.
|
|
608
|
+
{...(brand !== undefined ? { brand } : {})}
|
|
609
|
+
{...(exit !== undefined ? { exit } : {})}
|
|
610
|
+
{...(presentation !== undefined ? { presentation } : {})}
|
|
572
611
|
{...(completedContent !== undefined ? { completedContent } : {})}
|
|
573
612
|
/>
|
|
574
613
|
);
|
|
@@ -25,24 +25,26 @@ jest.mock("../flow.actions", () => ({ submitFlowStepAction: jest.fn() }));
|
|
|
25
25
|
jest.mock("../account-invite.actions", () => ({ accountInviteLinkAction: jest.fn() }));
|
|
26
26
|
|
|
27
27
|
interface StubProps {
|
|
28
|
-
onSubmitStep: (payload: { stepKey: string; values: Record<string, unknown> }) => Promise<
|
|
28
|
+
onSubmitStep: (payload: { stepKey: string; values: Record<string, unknown> }) => Promise<{
|
|
29
|
+
ok: boolean;
|
|
30
|
+
response?: { completed: boolean };
|
|
31
|
+
}>;
|
|
32
|
+
onCompleted?: (result: Record<string, never>) => void;
|
|
29
33
|
completedContent?: ReactNode;
|
|
30
34
|
}
|
|
31
35
|
|
|
32
36
|
jest.mock("@working-theory/ui-signal-collectors", () => ({
|
|
33
37
|
FlowStepper: (props: StubProps) => {
|
|
34
38
|
const react = require("react");
|
|
39
|
+
// The real FlowStepper fires `onCompleted` after a completing submit.
|
|
40
|
+
async function handleSubmit(): Promise<void> {
|
|
41
|
+
const result = await props.onSubmitStep({ stepKey: "contact", values: { email: "ana@example.com" } });
|
|
42
|
+
if (result.ok && result.response?.completed) props.onCompleted?.({});
|
|
43
|
+
}
|
|
35
44
|
return react.createElement(
|
|
36
45
|
"div",
|
|
37
46
|
{ "data-testid": "mock-card" },
|
|
38
|
-
react.createElement(
|
|
39
|
-
"button",
|
|
40
|
-
{
|
|
41
|
-
"data-testid": "mock-submit",
|
|
42
|
-
onClick: () => props.onSubmitStep({ stepKey: "contact", values: { email: "ana@example.com" } }),
|
|
43
|
-
},
|
|
44
|
-
"Submit",
|
|
45
|
-
),
|
|
47
|
+
react.createElement("button", { "data-testid": "mock-submit", onClick: handleSubmit }, "Submit"),
|
|
46
48
|
props.completedContent,
|
|
47
49
|
) as ReactElement;
|
|
48
50
|
},
|
|
@@ -189,6 +191,18 @@ describe("the ending delivers the deliverable (#8848 D8, AC-5)", () => {
|
|
|
189
191
|
expect(document.querySelector("video")).toBeNull();
|
|
190
192
|
});
|
|
191
193
|
|
|
194
|
+
// #11013 D-J (AC-3) — a recommending walk with no offers that shows a
|
|
195
|
+
// deliverable keeps it: the deliverable's action renders and no results
|
|
196
|
+
// permalink is pushed.
|
|
197
|
+
it("a recommending walk with no offers keeps its deliverable and pushes no permalink", async () => {
|
|
198
|
+
respondWith({ kind: "file", grantId: "dgrant_x" });
|
|
199
|
+
await walk(config({ mode: "recommending" }));
|
|
200
|
+
|
|
201
|
+
const action = await screen.findByTestId("flow-deliverable-action");
|
|
202
|
+
expect(action.getAttribute("href")).toBe("/reports/q3?g=dgrant_x");
|
|
203
|
+
expect(mockPush).not.toHaveBeenCalled();
|
|
204
|
+
});
|
|
205
|
+
|
|
192
206
|
it("a config with no deliverable and no response key renders today's card", async () => {
|
|
193
207
|
respondWith();
|
|
194
208
|
await walk(config({ deliverable: undefined, deliverables: undefined }));
|
package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.invite.test.tsx
CHANGED
|
@@ -258,6 +258,21 @@ describe("a user magnet lands on sign-up (#10826 D6)", () => {
|
|
|
258
258
|
expect(navigated()).toBe("");
|
|
259
259
|
});
|
|
260
260
|
|
|
261
|
+
// #11013 D-J (AC-3) — the results page's reach never pre-empts the sign-up
|
|
262
|
+
// hand-off: a recommending `user` magnet with no offers and no ending still
|
|
263
|
+
// lands on sign-up at once, and no results permalink is pushed.
|
|
264
|
+
it("a recommending user magnet with no offers and no ending still lands on sign-up, with no permalink push", async () => {
|
|
265
|
+
mockSubmit.mockResolvedValue(ok({ next: { completion: "invite" } }));
|
|
266
|
+
|
|
267
|
+
await walk({ ...config({ tagged: true, thankYou: false }), mode: "recommending" } as FlowConfig);
|
|
268
|
+
|
|
269
|
+
await waitFor(() => expect(navigated()).toBe(HREF));
|
|
270
|
+
expect(mockLink).toHaveBeenCalledTimes(1);
|
|
271
|
+
expect(mockLink).toHaveBeenCalledWith(EMAIL);
|
|
272
|
+
expect(mockPush).not.toHaveBeenCalled();
|
|
273
|
+
expect(window.sessionStorage.getItem("ailk:flow-session:get-a-quote")).toBeNull();
|
|
274
|
+
});
|
|
275
|
+
|
|
261
276
|
it("a completion with no next pushes /thanks with no email in the URL", async () => {
|
|
262
277
|
mockSubmit.mockResolvedValue(ok({}));
|
|
263
278
|
|
package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.permalink.test.tsx
CHANGED
|
@@ -444,3 +444,77 @@ describe("FlowStepperClient — session hand-off on completion (#4842 AC-6, writ
|
|
|
444
444
|
expect(window.sessionStorage.getItem(STORAGE_KEY)).toBeNull();
|
|
445
445
|
});
|
|
446
446
|
});
|
|
447
|
+
|
|
448
|
+
// ─── #11013 spec E, D-J (AC-3) — a recommending flow with no offers now reaches
|
|
449
|
+
// the results page; a flow with offers pushes exactly as before ─────────────
|
|
450
|
+
|
|
451
|
+
describe("FlowStepperClient — the results push on a recommending flow with no offers (#11013 D-J, AC-3)", () => {
|
|
452
|
+
function noOffersConfig(extra: Record<string, unknown> = {}): FlowConfig {
|
|
453
|
+
const { offers: _offers, ...rest } = recommendingFlowConfig();
|
|
454
|
+
return { ...rest, ...extra } as FlowConfig;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
it("no offers, no by-result rows, no ending: the completed walk pushes the results permalink", async () => {
|
|
458
|
+
mockSubmitFlowStepAction.mockResolvedValueOnce({
|
|
459
|
+
ok: true,
|
|
460
|
+
response: { sessionId: "sess-r", landed: "team", nextStepKey: null, completed: true },
|
|
461
|
+
});
|
|
462
|
+
|
|
463
|
+
render(<FlowStepperClient config={noOffersConfig()} locale="en" slug={SLUG} />);
|
|
464
|
+
expect(captured?.onCompleted).toBeDefined();
|
|
465
|
+
|
|
466
|
+
await captured!.onSubmitStep({
|
|
467
|
+
stepKey: "team",
|
|
468
|
+
values: { team_size: "solo", wants_seo: "yes" },
|
|
469
|
+
locale: "en",
|
|
470
|
+
});
|
|
471
|
+
captured!.onCompleted?.({});
|
|
472
|
+
|
|
473
|
+
const decoded = decodePermalink(pushedPayload());
|
|
474
|
+
expect(decoded.ok).toBe(true);
|
|
475
|
+
if (!decoded.ok) return;
|
|
476
|
+
expect(decoded.value.answers).toEqual({ team_size: "solo", wants_seo: "yes" });
|
|
477
|
+
expect(window.sessionStorage.getItem(`ailk:flow-session:${SLUG}`)).toBe("sess-r");
|
|
478
|
+
});
|
|
479
|
+
|
|
480
|
+
it("a flow that is not recommending is passed no onCompleted and pushes nothing", async () => {
|
|
481
|
+
mockSubmitFlowStepAction.mockResolvedValueOnce({
|
|
482
|
+
ok: true,
|
|
483
|
+
response: { sessionId: "sess-q", landed: "team", nextStepKey: null, completed: true },
|
|
484
|
+
});
|
|
485
|
+
const { mode: _mode, ...qualifying } = noOffersConfig();
|
|
486
|
+
|
|
487
|
+
render(<FlowStepperClient config={qualifying as FlowConfig} locale="en" slug={SLUG} />);
|
|
488
|
+
expect(captured?.onCompleted).toBeUndefined();
|
|
489
|
+
await captured!.onSubmitStep({ stepKey: "team", values: { team_size: "solo" }, locale: "en" });
|
|
490
|
+
expect(mockPush).not.toHaveBeenCalled();
|
|
491
|
+
});
|
|
492
|
+
|
|
493
|
+
it("a recommending flow with an ending and offers is passed no onCompleted (the ending wins, D-I)", () => {
|
|
494
|
+
render(
|
|
495
|
+
<FlowStepperClient
|
|
496
|
+
config={{
|
|
497
|
+
...recommendingFlowConfig(),
|
|
498
|
+
ending: { default: { kind: "screen", headline: { en: "Done" } } },
|
|
499
|
+
} as FlowConfig}
|
|
500
|
+
locale="en"
|
|
501
|
+
slug={SLUG}
|
|
502
|
+
/>,
|
|
503
|
+
);
|
|
504
|
+
expect(captured?.onCompleted).toBeUndefined();
|
|
505
|
+
});
|
|
506
|
+
|
|
507
|
+
it("a recommending flow with offers and no ending pushes the permalink as at the pin", async () => {
|
|
508
|
+
mockSubmitFlowStepAction.mockResolvedValueOnce({
|
|
509
|
+
ok: true,
|
|
510
|
+
response: { sessionId: "sess-o", landed: "team", nextStepKey: null, completed: true },
|
|
511
|
+
});
|
|
512
|
+
|
|
513
|
+
render(<FlowStepperClient config={recommendingFlowConfig()} locale="en" slug={SLUG} />);
|
|
514
|
+
await captured!.onSubmitStep({ stepKey: "team", values: { team_size: "agency", wants_seo: "no" }, locale: "en" });
|
|
515
|
+
captured!.onCompleted?.({});
|
|
516
|
+
|
|
517
|
+
const decoded = decodePermalink(pushedPayload());
|
|
518
|
+
expect(decoded.ok && decoded.value.answers).toEqual({ team_size: "agency", wants_seo: "no" });
|
|
519
|
+
});
|
|
520
|
+
});
|
|
@@ -69,10 +69,13 @@ const PII_PAYLOAD = {
|
|
|
69
69
|
};
|
|
70
70
|
|
|
71
71
|
let capturedOnCompleted: MockFlowStepperProps["onCompleted"];
|
|
72
|
+
// #11013 AC-1 — every prop the client hands the stepper, for the forwarding cases.
|
|
73
|
+
let capturedProps: Record<string, unknown> | undefined;
|
|
72
74
|
|
|
73
75
|
jest.mock("@working-theory/ui-signal-collectors", () => ({
|
|
74
|
-
FlowStepper: (props: MockFlowStepperProps) => {
|
|
76
|
+
FlowStepper: (props: MockFlowStepperProps & Record<string, unknown>) => {
|
|
75
77
|
capturedOnCompleted = props.onCompleted;
|
|
78
|
+
capturedProps = props;
|
|
76
79
|
async function handleSubmit(): Promise<void> {
|
|
77
80
|
const result = await props.onSubmitStep({
|
|
78
81
|
stepKey: "contact",
|
|
@@ -140,6 +143,36 @@ beforeEach(() => {
|
|
|
140
143
|
mockPush.mockClear();
|
|
141
144
|
mockSubmitFlowStepAction.mockClear();
|
|
142
145
|
capturedOnCompleted = undefined;
|
|
146
|
+
capturedProps = undefined;
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
describe("FlowStepperClient — forwards brand, exit and presentation to FlowStepper (#11013 AC-1)", () => {
|
|
150
|
+
const brand = { logomark: <span data-testid="mark" />, wordmark: <span data-testid="word" />, title: "Quote" };
|
|
151
|
+
const exit = { href: "/en/flows/x", label: "Exit" };
|
|
152
|
+
|
|
153
|
+
it("forwards each unchanged", () => {
|
|
154
|
+
render(
|
|
155
|
+
<FlowStepperClient
|
|
156
|
+
config={noThankYouFlowConfig()}
|
|
157
|
+
locale="en"
|
|
158
|
+
slug="get-a-quote"
|
|
159
|
+
brand={brand}
|
|
160
|
+
exit={exit}
|
|
161
|
+
presentation="full"
|
|
162
|
+
/>,
|
|
163
|
+
);
|
|
164
|
+
expect(capturedProps?.["brand"]).toBe(brand);
|
|
165
|
+
expect(capturedProps?.["exit"]).toBe(exit);
|
|
166
|
+
expect(capturedProps?.["presentation"]).toBe("full");
|
|
167
|
+
expect(capturedProps).not.toHaveProperty("header");
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it("omits each when absent, so the stepper's own defaults apply", () => {
|
|
171
|
+
render(<FlowStepperClient config={noThankYouFlowConfig()} locale="en" slug="get-a-quote" />);
|
|
172
|
+
expect(capturedProps).not.toHaveProperty("brand");
|
|
173
|
+
expect(capturedProps).not.toHaveProperty("exit");
|
|
174
|
+
expect(capturedProps).not.toHaveProperty("presentation");
|
|
175
|
+
});
|
|
143
176
|
});
|
|
144
177
|
|
|
145
178
|
describe("FlowStepperClient — segment-keyed completion redirect (AC1)", () => {
|