From 03ef8ba0a7a753409213adb34ed4785728cca573 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 21 Jul 2026 20:48:51 +0000 Subject: [PATCH 1/2] test(clinical-dashboard): assert upload-layout hook wires useSyncExternalStore The audit-navigation guard asserted the hook file merely *contains* `subscribeToUploadDesktopLayout`, which passes even if the helper is declared-but-unused or the subscription is disconnected. Match the actual useSyncExternalStore(subscribe, snapshot, () => false) wiring instead, so the guard fails on a disconnected subscription, a dropped SSR server-snapshot, or a present-but-unused helper. Follow-up to CodeRabbit's nitpick on #1042, which merged with the weaker assertion. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_019Jc1ZYHFjXjn6mE6U6riVU --- tests/audit-navigation-auth-regressions.test.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/audit-navigation-auth-regressions.test.ts b/tests/audit-navigation-auth-regressions.test.ts index c9c79904..5df1135b 100644 --- a/tests/audit-navigation-auth-regressions.test.ts +++ b/tests/audit-navigation-auth-regressions.test.ts @@ -177,8 +177,13 @@ describe("audit navigation and auth regressions", () => { // The viewport-driven region/tabpanel role is wired through the extracted hook, whose // media-query subscription carries the guard with it. expect(clinicalDashboardSource).toContain("useUploadDesktopLayout()"); - expect(source("src/components/clinical-dashboard/use-upload-desktop-layout.ts")).toContain( - "subscribeToUploadDesktopLayout", + // Assert the hook actually wires the media-query subscription through + // useSyncExternalStore (with the () => false server snapshot), so this guard + // fails on a disconnected subscription or a dropped SSR fallback — not merely + // when the helper name is present but unused. + const uploadDesktopHookSource = source("src/components/clinical-dashboard/use-upload-desktop-layout.ts"); + expect(uploadDesktopHookSource).toMatch( + /useSyncExternalStore\(\s*subscribeToUploadDesktopLayout,\s*getUploadDesktopLayoutSnapshot,\s*\(\)\s*=>\s*false/, ); expect(clinicalDashboardSource).toContain('event.key === "ArrowRight"'); expect(clinicalDashboardSource).toContain('event.key === "ArrowLeft"'); From 682a5d184b8b13ca879ab606a70e51e07f7e778f Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 21 Jul 2026 21:43:13 +0000 Subject: [PATCH 2/2] test(clinical-dashboard): anchor upload-layout hook guard to the exported return Scope the useSyncExternalStore wiring assertion to the exported useUploadDesktopLayout body and require the returned call to close right after the () => false server snapshot. This closes the gaps Codex and CodeRabbit both flagged: a stale/dead call elsewhere in the file, a present-but-unused helper, a missing return, or a mutated snapshot like `() => false || getSnapshot()` can no longer satisfy the guard. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_019Jc1ZYHFjXjn6mE6U6riVU --- .../audit-navigation-auth-regressions.test.ts | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/tests/audit-navigation-auth-regressions.test.ts b/tests/audit-navigation-auth-regressions.test.ts index 5df1135b..d6f9fe48 100644 --- a/tests/audit-navigation-auth-regressions.test.ts +++ b/tests/audit-navigation-auth-regressions.test.ts @@ -177,13 +177,20 @@ describe("audit navigation and auth regressions", () => { // The viewport-driven region/tabpanel role is wired through the extracted hook, whose // media-query subscription carries the guard with it. expect(clinicalDashboardSource).toContain("useUploadDesktopLayout()"); - // Assert the hook actually wires the media-query subscription through - // useSyncExternalStore (with the () => false server snapshot), so this guard - // fails on a disconnected subscription or a dropped SSR fallback — not merely - // when the helper name is present but unused. + // Assert the EXPORTED hook's return wires the media-query subscription through + // useSyncExternalStore with the () => false server snapshot, and that the call closes + // right after that snapshot. Scoping to the exported function body (not the whole file) + // plus the `return` anchor and trailing `)` means a stale/disconnected call elsewhere, a + // comment or string, a present-but-unused helper, a dropped SSR fallback, or a mutated + // snapshot such as `() => false || getUploadDesktopLayoutSnapshot()` all fail the guard. const uploadDesktopHookSource = source("src/components/clinical-dashboard/use-upload-desktop-layout.ts"); - expect(uploadDesktopHookSource).toMatch( - /useSyncExternalStore\(\s*subscribeToUploadDesktopLayout,\s*getUploadDesktopLayoutSnapshot,\s*\(\)\s*=>\s*false/, + const useUploadDesktopLayoutBody = sourceSegment( + uploadDesktopHookSource, + "export function useUploadDesktopLayout(", + "}", + ); + expect(useUploadDesktopLayoutBody).toMatch( + /return\s+useSyncExternalStore\(\s*subscribeToUploadDesktopLayout,\s*getUploadDesktopLayoutSnapshot,\s*\(\)\s*=>\s*false\s*\)/, ); expect(clinicalDashboardSource).toContain('event.key === "ArrowRight"'); expect(clinicalDashboardSource).toContain('event.key === "ArrowLeft"');