From 617d4518648adb7751fc800319482971634e7afb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Fri, 15 May 2026 19:28:04 +0200 Subject: [PATCH] fix(tests): flip the insights-coach mount assertions to the new layout owner MB4 promoted the Coach drawer mount from the mother page up to `/insights/layout.tsx` so navigating into a routed sub-page no longer unmounts the drawer. The launch lifecycle now lives in the `` context that the layout supplies; the page consumes it via `useCoachLaunch`. The three insights-polish assertions still pinned the old contract (import + mount in the page, local `setCoachOpen` / `setCoachPrefill` state). Re-pointed them at the new owner: - layout imports the launch context, wraps children in ``, and mounts `` - page's hero strip still wires `onAskCoach` / `onPickPrompt` but now delegates to `coachLaunch.askCoach(prefill)` - the local `setCoachOpen` / `setCoachPrefill` pair is gone --- src/app/__tests__/insights-polish.test.ts | 35 +++++++++++++++-------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/src/app/__tests__/insights-polish.test.ts b/src/app/__tests__/insights-polish.test.ts index 9bdcb4485..cbdbb6533 100644 --- a/src/app/__tests__/insights-polish.test.ts +++ b/src/app/__tests__/insights-polish.test.ts @@ -37,6 +37,7 @@ import { join } from "node:path"; const ROOT = join(__dirname, "../../.."); const DASHBOARD_PATH = join(ROOT, "src/app/page.tsx"); const INSIGHTS_PATH = join(ROOT, "src/app/insights/page.tsx"); +const INSIGHTS_LAYOUT_PATH = join(ROOT, "src/app/insights/layout.tsx"); function load(path: string): string { return readFileSync(path, "utf8"); @@ -64,27 +65,37 @@ describe("v1.4.19 A3 — dashboard polish", () => { }); }); -describe("v1.4.20 B2b — /insights wires the Coach drawer", () => { - it("imports and mounts it at the bottom of the page", () => { - const src = load(INSIGHTS_PATH); - expect(src).toContain( - 'from "@/components/insights/coach-panel/coach-drawer"', +describe("v1.4.27 R3d MB4 — the layout mounts the Coach drawer", () => { + it("the insights layout wraps children in and mounts the drawer", () => { + // v1.4.27 MB4 promoted the drawer mount from the mother page up to + // `/insights/layout.tsx` so a routed sub-page does not unmount the + // drawer. The layout owns the mount + the provider; the page (and + // every sub-page) consumes the launch context. + const layout = load(INSIGHTS_LAYOUT_PATH); + expect(layout).toContain( + 'from "@/lib/insights/coach-launch-context"', ); - expect(src).toMatch(//); + expect(layout).toMatch(/ { + it("hero strip's onAskCoach handler calls the launch context", () => { const src = load(INSIGHTS_PATH); - // The hero supplies onAskCoach which sets coachPrefill to null and - // flips coachOpen. + // The hero supplies onAskCoach which now delegates to + // `coachLaunch.askCoach(prefill)` from the layout-level provider + // instead of toggling local state. expect(src).toMatch(/ { + it("the page no longer owns coachOpen + coachPrefill local state", () => { const src = load(INSIGHTS_PATH); - expect(src).toContain("setCoachOpen"); - expect(src).toContain("setCoachPrefill"); + // The local useState pair retired with MB4. The launch context + // (mounted by the layout) now owns the open + prefill lifecycle. + expect(src).not.toContain("setCoachOpen"); + expect(src).not.toContain("setCoachPrefill"); }); });