create-ailk 0.32.0 → 0.34.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.
Files changed (53) hide show
  1. package/README.md +21 -3
  2. package/component-catalog.json +12 -1
  3. package/component-catalog.md +6 -5
  4. package/dist/export-content.d.ts +6 -3
  5. package/dist/export-content.js +82 -11
  6. package/dist/lib/env-catalog.js +4 -0
  7. package/dist/lib/import-mdx.d.ts +111 -0
  8. package/dist/lib/import-mdx.js +648 -46
  9. package/dist/migrate-content.d.ts +3 -1
  10. package/dist/migrate-content.js +52 -1
  11. package/dist/seed-flows.d.ts +1 -1
  12. package/dist/seed-flows.js +9 -4
  13. package/dist/surfaces.js +1 -0
  14. package/package.json +3 -3
  15. package/templates/apps/api/.env.example +11 -0
  16. package/templates/apps/api/CLAUDE.md +7 -5
  17. package/templates/apps/api/src/lib/__mocks__/prisma.ts +13 -0
  18. package/templates/apps/mcp/CLAUDE.md +4 -2
  19. package/templates/apps/web/CLAUDE.md +4 -1
  20. package/templates/apps/web/app/[locale]/(auth)/__tests__/password-reset.test.tsx +28 -0
  21. package/templates/apps/web/app/[locale]/(auth)/verify-email/__tests__/actions.test.ts +94 -0
  22. package/templates/apps/web/app/[locale]/(auth)/verify-email/actions.ts +77 -0
  23. package/templates/apps/web/app/[locale]/(auth)/verify-email/page.tsx +79 -14
  24. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/hub-mode.test.tsx +7 -0
  25. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-menu.test.tsx +7 -0
  26. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +7 -0
  27. package/templates/apps/web/app/[locale]/contact/__tests__/contact.actions.test.ts +21 -0
  28. package/templates/apps/web/app/[locale]/contact/contact.actions.ts +15 -9
  29. package/templates/apps/web/app/[locale]/flows/[slug]/FlowStepperClient.tsx +38 -105
  30. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.invite.test.tsx +72 -58
  31. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/verify.test.tsx +249 -0
  32. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsClient.tsx +164 -20
  33. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/by-result.test.tsx +269 -0
  34. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/score.test.tsx +179 -0
  35. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/page.tsx +108 -40
  36. package/templates/apps/web/app/[locale]/flows/[slug]/verify/page.tsx +153 -0
  37. package/templates/apps/web/app/[locale]/flows/[slug]/verify.actions.ts +151 -0
  38. package/templates/apps/web/app/[locale]/meet/confirmed/BookingHandOff.tsx +1 -1
  39. package/templates/apps/web/app/[locale]/thanks/[slug]/__tests__/page.test.tsx +3 -20
  40. package/templates/apps/web/app/[locale]/thanks/[slug]/page.tsx +2 -9
  41. package/templates/apps/web/auth.ts +22 -6
  42. package/templates/apps/web/lib/__tests__/account-config.test.ts +69 -0
  43. package/templates/apps/web/lib/__tests__/auth-email.test.ts +99 -1
  44. package/templates/apps/web/lib/__tests__/telemetry-scrub.test.ts +20 -0
  45. package/templates/apps/web/lib/account-config.ts +52 -14
  46. package/templates/apps/web/lib/auth-email.ts +87 -5
  47. package/templates/apps/web/lib/mcp-oauth.ts +49 -6
  48. package/templates/apps/web/lib/telemetry-scrub.ts +6 -0
  49. package/templates/apps/web/messages/en.json +26 -1
  50. package/templates/database/seed.ts +7 -7
  51. package/versions.json +48 -48
  52. package/templates/apps/web/app/[locale]/thanks/[slug]/AccountInviteLink.tsx +0 -89
  53. package/templates/apps/web/app/[locale]/thanks/[slug]/__tests__/AccountInviteLink.test.tsx +0 -104
@@ -42,14 +42,16 @@
42
42
  * a tier with no slug, or a flow with none, continues exactly as before. The
43
43
  * answers are read to score, never written into the href.
44
44
  *
45
- * Account link (#8771 D5): when the walk completes on an `invite` magnet (the
46
- * step response's `next`), the client asks `accountInviteLinkAction` for the
47
- * sign-in link with the email the visitor gave already filled in, then shows
48
- * "Track this in your account" on `FlowStepper`'s own finished panel — or,
49
- * for a flow with a `thankYou` block, hands the link to `/thanks/<slug>`
50
- * through `sessionStorage` (`ailk:account-invite`). The email never enters a
51
- * URL the walk navigates to (NFR1), and each link sits in a Session-Replay
52
- * `data-sentry-block` element, since the scrub cannot reach a DOM `href`.
45
+ * Sign-up landing (#10826 D6, after #8771 D5): when the walk completes on a
46
+ * `user` magnet (the step response's `next` is `{ completion: "invite" }`),
47
+ * the client asks `accountInviteLinkAction` for the sign-in link with the
48
+ * email the visitor gave already filled in, and navigates there at once —
49
+ * a full navigation (`window.location.assign`), because a hub sign-in path is
50
+ * not a Next route. A `null` link (no sign-in on this site) ends the walk as
51
+ * before. A response carrying a `deliverable` never navigates (#8848 D8): the
52
+ * sign-up landing then reaches the respondent through the verification
53
+ * email's confirm (D5). The email never enters a URL the walk navigates to
54
+ * other than that sign-in link itself.
53
55
  *
54
56
  * The standard magnet's parts (#8840 D9): the consent registry is the
55
57
  * platform default with the locale's `/terms` and `/privacy` links
@@ -116,6 +118,7 @@ import {
116
118
  resolveLocalizedString,
117
119
  resolveThankYouSlug,
118
120
  resolveTierThankYouSlug,
121
+ resultsPermalinkAnswers,
119
122
  selectFlowEndingOutcome,
120
123
  SITE_CONSENT_CONFIG_DEFAULTS,
121
124
  visitorNameOf,
@@ -150,9 +153,6 @@ function resolveSafeLocale(candidate: string): string {
150
153
  return ENABLED_LOCALES.includes(candidate) ? candidate : DEFAULT_LOCALE;
151
154
  }
152
155
 
153
- /** The `/thanks` hand-off key (#8771 D5) — read once by `AccountInviteLink`. */
154
- const ACCOUNT_INVITE_STORAGE_KEY = "ailk:account-invite";
155
-
156
156
  /**
157
157
  * #8771 D5 — the email the engine will land as the lead's: the first
158
158
  * `mapsTo: "email"` field of the submitted `field` step that holds a
@@ -190,24 +190,6 @@ function safeDeliverable(raw: unknown): FlowStepDeliverable | undefined {
190
190
  return parsed.success ? parsed.data : undefined;
191
191
  }
192
192
 
193
- /**
194
- * D7 (#4770) — every question `name` contributed by a `segmentation`-typed
195
- * step. This is the allowlist the encoded permalink is filtered to: a
196
- * `field`-typed step's values — mapped or unmapped, including the invisible
197
- * `aeo_score` step's own submission (D1) — never reach it.
198
- */
199
- function segmentationQuestionNames(config: FlowConfig): Set<string> {
200
- const names = new Set<string>();
201
- for (const step of config.steps) {
202
- if (step.type === "segmentation") {
203
- for (const question of step.questions) {
204
- names.add(question.name);
205
- }
206
- }
207
- }
208
- return names;
209
- }
210
-
211
193
  /**
212
194
  * #8840 D9 — the answers the ending is chosen from, assembled as the
213
195
  * permalink path assembles them: the visible steps' answers flattened, then
@@ -258,13 +240,10 @@ export function FlowStepperClient({
258
240
  // recommending completion can hand the walk's session to the results page
259
241
  // via `sessionStorage` (never the URL — the permalink stays answers-only).
260
242
  const lastSessionIdRef = useRef<string | undefined>(undefined);
261
- // #8771 D5 — the email the walk has landed, and the account link built from
262
- // it at completion on an `invite` magnet. The ref carries the link to
263
- // `handleCompleted`; the state draws it on the finished panel.
243
+ // #8771 D5 — the email the walk has landed. #10826 D6 — set once the walk
244
+ // has left for the sign-up landing, so no other ending races it.
264
245
  const emailRef = useRef<string | undefined>(undefined);
265
- const inviteHrefRef = useRef<string | null>(null);
266
- const [inviteHref, setInviteHref] = useState<string | null>(null);
267
- const tContact = useTranslations("contact");
246
+ const signingUpRef = useRef(false);
268
247
  // #8840 D9 — a config with an `ending` ends on it, never on `thankYou` or
269
248
  // the permalink; the chosen screen is drawn in the finished card.
270
249
  const endingWins = config.ending !== undefined;
@@ -285,8 +264,12 @@ export function FlowStepperClient({
285
264
  lastSessionIdRef.current = result.response.sessionId;
286
265
  emailRef.current = mappedEmailOf(config, payload) ?? emailRef.current;
287
266
  if (result.response.completed) {
288
- await resolveInviteLink(result.response);
289
- const delivered = showDeliverable((result.response as { deliverable?: unknown }).deliverable);
267
+ const raw = (result.response as { deliverable?: unknown }).deliverable;
268
+ // #8848 D8 — a deliverable (or a gated file's by-email line) is never
269
+ // lost to a navigation.
270
+ const hasDeliverable = raw !== undefined || config.deliverable !== undefined;
271
+ if (!hasDeliverable && (await goToSignUp(result.response))) return result;
272
+ const delivered = showDeliverable(raw);
290
273
  if (endingWins) showEnding(delivered);
291
274
  }
292
275
  } else if (result.kind === "step_conflict") {
@@ -296,23 +279,25 @@ export function FlowStepperClient({
296
279
  return result;
297
280
  }
298
281
 
299
- // #8771 D5 — on an `invite` completion with a landed email, ask the server
300
- // for the prefilled sign-in link. A rejected or null answer gives no link.
301
- async function resolveInviteLink(response: unknown): Promise<void> {
302
- inviteHrefRef.current = null;
303
- setInviteHref(null);
282
+ // #10826 D6 — on an `invite` completion (a `user` magnet) with a landed
283
+ // email, ask the server for the prefilled sign-in link and go there. True
284
+ // when the walk navigated; a rejected or null answer ends the walk as before.
285
+ async function goToSignUp(response: unknown): Promise<boolean> {
304
286
  const next = flowStepNextSchema.safeParse(
305
287
  (response as { next?: unknown }).next,
306
288
  );
307
289
  const email = emailRef.current;
308
- if (!next.success || email === undefined || isRecommending) return;
290
+ if (!next.success || email === undefined || isRecommending) return false;
291
+ let href: string | null;
309
292
  try {
310
- const href = await accountInviteLinkAction(email);
311
- inviteHrefRef.current = href;
312
- setInviteHref(href);
293
+ href = await accountInviteLinkAction(email);
313
294
  } catch {
314
- // No link — the walk still completes.
295
+ return false;
315
296
  }
297
+ if (href === null) return false;
298
+ signingUpRef.current = true;
299
+ window.location.assign(href);
300
+ return true;
316
301
  }
317
302
 
318
303
  // #8848 D8 — draw the response's deliverable (true when there is one), or,
@@ -385,14 +370,7 @@ export function FlowStepperClient({
385
370
  // redirect never runs, so the deliverable is never lost to a navigation.
386
371
  function showEnding(delivered = false): void {
387
372
  const answers = walkAnswers(config, answersRef.current);
388
- const segmentationNames = segmentationQuestionNames(config);
389
- const choices: Record<string, string | string[]> = {};
390
- for (const [name, value] of Object.entries(answers)) {
391
- if (segmentationNames.has(name) && (typeof value === "string" || Array.isArray(value))) {
392
- choices[name] = value as string | string[];
393
- }
394
- }
395
- const outcome = selectFlowEndingOutcome(config, choices);
373
+ const outcome = selectFlowEndingOutcome(config, resultsPermalinkAnswers(config, answers));
396
374
  if (outcome === undefined) return;
397
375
  if (outcome.kind === "redirect") {
398
376
  if (!delivered && flowSitePathSchema.safeParse(outcome.href).success) {
@@ -449,6 +427,7 @@ export function FlowStepperClient({
449
427
  segment?: string;
450
428
  aeoScore?: AeoScoreResult;
451
429
  }): void {
430
+ if (signingUpRef.current) return;
452
431
  // #10616 D4 — a scored tier's thank-you page wins over the permalink and
453
432
  // the `thankYou` block. Scored from the walk's answers as the server's
454
433
  // completion payload assembles them; no flags are passed (the server
@@ -481,15 +460,9 @@ export function FlowStepperClient({
481
460
  // below.
482
461
  Object.assign(flat, hiddenAnswers(config, answersRef.current, flags));
483
462
 
484
- // D7 — segmentation-only filter.
485
- const segmentationNames = segmentationQuestionNames(config);
486
- const answers: Record<string, string | string[]> = {};
487
- for (const [name, value] of Object.entries(flat)) {
488
- if (!segmentationNames.has(name)) continue;
489
- if (typeof value === "string" || Array.isArray(value)) {
490
- answers[name] = value as string | string[];
491
- }
492
- }
463
+ // D7 — segmentation-only filter (`resultsPermalinkAnswers`, the
464
+ // allowlist the Lead confirm's results landing shares, #10826 D5).
465
+ const answers = resultsPermalinkAnswers(config, flat);
493
466
 
494
467
  const payload = encodePermalink({
495
468
  version: PERMALINK_VERSION,
@@ -519,28 +492,8 @@ export function FlowStepperClient({
519
492
  }
520
493
 
521
494
  // The thank-you redirect's tail, shared by the `thankYou` block and a
522
- // scored tier's slug (#10616 D4): the invite hand-off, then the push.
495
+ // scored tier's slug (#10616 D4).
523
496
  function goToThanks(thankYouSlug: string): void {
524
- // #8771 D5 — hand the link to /thanks through the per-tab sessionStorage,
525
- // never the URL; with no link, clear an earlier walk's so it never shows
526
- // on this page. A storage that throws gives no link.
527
- if (typeof window !== "undefined") {
528
- try {
529
- if (inviteHrefRef.current !== null) {
530
- window.sessionStorage.setItem(
531
- ACCOUNT_INVITE_STORAGE_KEY,
532
- JSON.stringify({
533
- thanks: thankYouSlug,
534
- href: inviteHrefRef.current,
535
- }),
536
- );
537
- } else {
538
- window.sessionStorage.removeItem(ACCOUNT_INVITE_STORAGE_KEY);
539
- }
540
- } catch {
541
- // No hand-off.
542
- }
543
- }
544
497
  router.push(`/${resolveSafeLocale(locale)}/thanks/${thankYouSlug}`);
545
498
  }
546
499
 
@@ -584,25 +537,6 @@ export function FlowStepperClient({
584
537
  selectAllThatApply: t("selectAllThatApply"),
585
538
  };
586
539
 
587
- // #8771 D5 — the link goes INSIDE FlowStepper's own finished card (a flow
588
- // with a `thankYou` block navigates away instead, so it never shows there).
589
- // Session Replay records the DOM, so the link (it carries the email) is
590
- // blocked from it; `Link` does not forward an undeclared data-* attribute.
591
- const completedAction =
592
- inviteHref !== null && (endingWins || thankYou === undefined) && !isRecommending ? (
593
- <div data-sentry-block>
594
- <Button asChild variant="outline" className="mt-4 min-h-11">
595
- <Link
596
- href={inviteHref}
597
- variant="bare"
598
- data-testid="flow-account-invite"
599
- >
600
- {tContact("trackInAccount")}
601
- </Link>
602
- </Button>
603
- </div>
604
- ) : undefined;
605
-
606
540
  // #8848 D8 — the ending screen, then the deliverable; with no ending the
607
541
  // stepper's own finished copy heads the action.
608
542
  const completedContent =
@@ -629,7 +563,6 @@ export function FlowStepperClient({
629
563
  {...(!endingWins && (thankYou !== undefined || isRecommending || hasTierThankYou)
630
564
  ? { onCompleted: handleCompleted }
631
565
  : {})}
632
- {...(completedAction !== undefined ? { completedAction } : {})}
633
566
  // #8840 D9 — the locale's policy links, the input-step count, and the
634
567
  // page's hidden values, header and ending.
635
568
  consentConfig={{ ...SITE_CONSENT_CONFIG_DEFAULTS, policies: consentPoliciesFor(locale) }}
@@ -1,8 +1,10 @@
1
1
  // oss: false
2
2
  /**
3
- * #8771 AC-4 — the walk shows "Track this in your account" with the email the
4
- * visitor gave already filled in, and keeps that email out of every URL it
5
- * navigates to. FlowStepper is a stub that submits a configurable step and
3
+ * #10826 D6 (AC-2) — a walk that completes on a `user` magnet (`next` is
4
+ * `{ completion: "invite" }`) lands on sign-up at once, through the prefilled
5
+ * sign-in link (`window.location.assign`), and writes no `/thanks` hand-off.
6
+ * A `null` link ends the walk as before; a deliverable is never lost to the
7
+ * navigation. FlowStepper is a stub that submits a configurable step and
6
8
  * calls the real `onCompleted` it is given; the Server Actions are doubles.
7
9
  */
8
10
  import { render, screen, waitFor } from "@testing-library/react";
@@ -70,10 +72,18 @@ import { FlowStepperClient } from "../FlowStepperClient";
70
72
  const mockSubmit = submitFlowStepAction as jest.MockedFunction<typeof submitFlowStepAction>;
71
73
  const mockLink = accountInviteLinkAction as jest.MockedFunction<typeof accountInviteLinkAction>;
72
74
 
73
- const HREF = "/sign-in?next=%2Faccount&email=jane%40example.com";
75
+ // jsdom cannot forge `location.assign`, but performs a fragment navigation
76
+ // (the LeadCaptureForm suite's idiom), so the link the action answers is a
77
+ // fragment here and the navigation is read back from `location.hash`.
78
+ const HREF = "#sign-up";
74
79
  const EMAIL = "jane@example.com";
75
80
 
76
- function config(opts: { tagged: boolean; thankYou: boolean; secondEmail?: boolean }): FlowConfig {
81
+ function config(opts: {
82
+ tagged: boolean;
83
+ thankYou: boolean;
84
+ secondEmail?: boolean;
85
+ deliverable?: boolean;
86
+ }): FlowConfig {
77
87
  return {
78
88
  slug: "get-a-quote",
79
89
  defaultLocale: "en",
@@ -106,6 +116,9 @@ function config(opts: { tagged: boolean; thankYou: boolean; secondEmail?: boolea
106
116
  ...(opts.thankYou
107
117
  ? { thankYou: { default: "flow-thanks", bySegment: { qualified: "flow-thanks-qualified" } } }
108
118
  : {}),
119
+ ...(opts.deliverable
120
+ ? { deliverable: { kind: "page", gated: true, href: "/guide", title: { en: "Guide" } } }
121
+ : {}),
109
122
  } as FlowConfig;
110
123
  }
111
124
 
@@ -127,8 +140,11 @@ async function walk(cfg: FlowConfig): Promise<void> {
127
140
  await userEvent.click(screen.getByTestId("mock-submit"));
128
141
  }
129
142
 
143
+ const navigated = () => window.location.hash;
144
+
130
145
  beforeEach(() => {
131
146
  mockPush.mockClear();
147
+ window.location.hash = "";
132
148
  mockSubmit.mockReset();
133
149
  mockLink.mockReset();
134
150
  mockLink.mockResolvedValue(HREF);
@@ -136,20 +152,27 @@ beforeEach(() => {
136
152
  window.sessionStorage.clear();
137
153
  });
138
154
 
139
- describe("the finished panel (no thankYou block)", () => {
140
- it("shows the prefilled link inside a Replay-blocked element", async () => {
155
+ describe("a user magnet lands on sign-up (#10826 D6)", () => {
156
+ it("navigates to the prefilled sign-in link and writes no ailk:account-invite key", async () => {
141
157
  mockSubmit.mockResolvedValue(ok({ next: { completion: "invite" } }));
142
158
 
143
159
  await walk(config({ tagged: true, thankYou: false }));
144
160
 
145
- const link = await screen.findByTestId("flow-account-invite");
146
- expect(link).toHaveAttribute("href", HREF);
147
- expect(link).toHaveTextContent("trackInAccount");
148
- expect(link.closest("[data-sentry-block]")).not.toBeNull();
149
- // Inside the finished card, not a sibling after the frame (#8771 design review).
150
- expect(link.closest('[data-testid="mock-completed-card"]')).not.toBeNull();
161
+ await waitFor(() => expect(navigated()).toBe(HREF));
151
162
  expect(mockLink).toHaveBeenCalledTimes(1);
152
163
  expect(mockLink).toHaveBeenCalledWith(EMAIL);
164
+ expect(window.sessionStorage.getItem("ailk:account-invite")).toBeNull();
165
+ expect(screen.queryByTestId("flow-account-invite")).toBeNull();
166
+ });
167
+
168
+ it("navigates instead of the /thanks redirect on a flow with a thankYou block", async () => {
169
+ mockSubmit.mockResolvedValue(ok({ segment: "qualified", next: { completion: "invite" } }));
170
+
171
+ await walk(config({ tagged: true, thankYou: true }));
172
+
173
+ await waitFor(() => expect(navigated()).toBe(HREF));
174
+ expect(mockPush).not.toHaveBeenCalled();
175
+ expect(window.sessionStorage.length).toBe(0);
153
176
  });
154
177
 
155
178
  it("only an email-tagged field counts", async () => {
@@ -159,7 +182,7 @@ describe("the finished panel (no thankYou block)", () => {
159
182
 
160
183
  await waitFor(() => expect(mockSubmit).toHaveBeenCalled());
161
184
  expect(mockLink).not.toHaveBeenCalled();
162
- expect(screen.queryByTestId("flow-account-invite")).toBeNull();
185
+ expect(navigated()).toBe("");
163
186
  });
164
187
 
165
188
  it("uses the step's first tagged email field", async () => {
@@ -168,31 +191,53 @@ describe("the finished panel (no thankYou block)", () => {
168
191
 
169
192
  await walk(config({ tagged: true, thankYou: false, secondEmail: true }));
170
193
 
171
- await screen.findByTestId("flow-account-invite");
194
+ await waitFor(() => expect(navigated()).toBe(HREF));
172
195
  expect(mockLink).toHaveBeenCalledWith("first@example.com");
173
196
  });
174
197
 
175
198
  it.each([
176
- ["no next", { }],
199
+ ["no next", {}],
177
200
  ["a step that does not complete", { completed: false, next: { completion: "invite" } }],
178
- ])("%s: no action call and no link", async (_name, response) => {
201
+ ])("%s: no action call and no navigation", async (_name, response) => {
179
202
  mockSubmit.mockResolvedValue(ok(response));
180
203
 
181
204
  await walk(config({ tagged: true, thankYou: false }));
182
205
 
183
206
  await waitFor(() => expect(mockSubmit).toHaveBeenCalled());
184
207
  expect(mockLink).not.toHaveBeenCalled();
185
- expect(screen.queryByTestId("flow-account-invite")).toBeNull();
208
+ expect(navigated()).toBe("");
186
209
  });
187
210
 
188
- it("an action answer of null shows no link", async () => {
189
- mockSubmit.mockResolvedValue(ok({ next: { completion: "invite" } }));
211
+ it("a null link (no sign-in on this site) ends the walk as before", async () => {
212
+ mockSubmit.mockResolvedValue(ok({ segment: "qualified", next: { completion: "invite" } }));
190
213
  mockLink.mockResolvedValue(null);
191
214
 
192
- await walk(config({ tagged: true, thankYou: false }));
215
+ await walk(config({ tagged: true, thankYou: true }));
193
216
 
194
- await waitFor(() => expect(mockLink).toHaveBeenCalled());
195
- expect(screen.queryByTestId("flow-account-invite")).toBeNull();
217
+ await waitFor(() => expect(mockPush).toHaveBeenCalledWith("/en/thanks/flow-thanks-qualified"));
218
+ expect(navigated()).toBe("");
219
+ });
220
+
221
+ it("a rejected action ends the walk as before", async () => {
222
+ mockSubmit.mockResolvedValue(ok({ next: { completion: "invite" } }));
223
+ mockLink.mockRejectedValue(new Error("boom"));
224
+
225
+ await walk(config({ tagged: true, thankYou: true }));
226
+
227
+ await waitFor(() => expect(mockPush).toHaveBeenCalledWith("/en/thanks/flow-thanks"));
228
+ expect(navigated()).toBe("");
229
+ });
230
+
231
+ it("a walk with a deliverable never navigates (#8848 D8)", async () => {
232
+ mockSubmit.mockResolvedValue(
233
+ ok({ next: { completion: "invite" }, deliverable: { kind: "page", href: "/guide" } }),
234
+ );
235
+
236
+ await walk(config({ tagged: true, thankYou: false, deliverable: true }));
237
+
238
+ await waitFor(() => expect(mockSubmit).toHaveBeenCalled());
239
+ expect(mockLink).not.toHaveBeenCalled();
240
+ expect(navigated()).toBe("");
196
241
  });
197
242
 
198
243
  it("a conflict forgets the email: a later completing step with no email field asks for no link", async () => {
@@ -210,48 +255,17 @@ describe("the finished panel (no thankYou block)", () => {
210
255
 
211
256
  await waitFor(() => expect(mockSubmit).toHaveBeenCalledTimes(3));
212
257
  expect(mockLink).not.toHaveBeenCalled();
258
+ expect(navigated()).toBe("");
213
259
  });
214
- });
215
260
 
216
- describe("the /thanks hand-off (a thankYou block)", () => {
217
- it("writes one sessionStorage item and pushes a URL with no email in it", async () => {
218
- mockSubmit.mockResolvedValue(ok({ segment: "qualified", next: { completion: "invite" } }));
261
+ it("a completion with no next pushes /thanks with no email in the URL", async () => {
262
+ mockSubmit.mockResolvedValue(ok({}));
219
263
 
220
264
  await walk(config({ tagged: true, thankYou: true }));
221
265
 
222
266
  await waitFor(() => expect(mockPush).toHaveBeenCalled());
223
- expect(JSON.parse(window.sessionStorage.getItem("ailk:account-invite") ?? "null")).toEqual({
224
- thanks: "flow-thanks-qualified",
225
- href: HREF,
226
- });
227
267
  const url = mockPush.mock.calls[0]?.[0] as string;
228
- expect(url).toBe("/en/thanks/flow-thanks-qualified");
268
+ expect(url).toBe("/en/thanks/flow-thanks");
229
269
  expect(url).not.toContain("@");
230
- expect(screen.queryByTestId("flow-account-invite")).toBeNull();
231
- });
232
-
233
- it("clears an earlier walk's hand-off when this completion has no link", async () => {
234
- window.sessionStorage.setItem(
235
- "ailk:account-invite",
236
- JSON.stringify({ thanks: "flow-thanks", href: HREF }),
237
- );
238
- mockSubmit.mockResolvedValue(ok({}));
239
-
240
- await walk(config({ tagged: true, thankYou: true }));
241
-
242
- await waitFor(() => expect(mockPush).toHaveBeenCalled());
243
- expect(window.sessionStorage.getItem("ailk:account-invite")).toBeNull();
244
- });
245
-
246
- it("a sessionStorage that throws still navigates", async () => {
247
- mockSubmit.mockResolvedValue(ok({ next: { completion: "invite" } }));
248
- const spy = jest.spyOn(Storage.prototype, "setItem").mockImplementation(() => {
249
- throw new Error("denied");
250
- });
251
-
252
- await walk(config({ tagged: true, thankYou: true }));
253
-
254
- await waitFor(() => expect(mockPush).toHaveBeenCalledWith("/en/thanks/flow-thanks"));
255
- spy.mockRestore();
256
270
  });
257
271
  });