From 6a6f3f6cf6e6d3729b19619e29c6013ffce6b8f0 Mon Sep 17 00:00:00 2001 From: Maurice Date: Thu, 8 Oct 2026 12:49:02 +0200 Subject: [PATCH] test(client): stub the sync triggers in the consent and dashboard specs OAuthAuthorizePage reloads the user on mount and useDashboard's retry reloads it too. The real loadUser then registers the background sync triggers, a 30 s heartbeat and window listeners that nothing in either spec unregisters, so they outlive the tests the same way they did in the account specs before 27db5dd5e. Both specs now stub the triggers, which neither is about. --- client/src/pages/OAuthAuthorizePage.test.tsx | 6 ++++++ client/src/pages/dashboard/useDashboard.test.tsx | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/client/src/pages/OAuthAuthorizePage.test.tsx b/client/src/pages/OAuthAuthorizePage.test.tsx index fa84f016d..69a22f629 100644 --- a/client/src/pages/OAuthAuthorizePage.test.tsx +++ b/client/src/pages/OAuthAuthorizePage.test.tsx @@ -8,6 +8,12 @@ import { resetAllStores, seedStore } from '../../tests/helpers/store'; import { buildUser } from '../../tests/helpers/factories'; import OAuthAuthorizePage from './OAuthAuthorizePage'; +// The consent page reloads the user on mount, and loadUser registers the +// background sync triggers: a 30 s heartbeat and window listeners that nothing +// here unregisters, so they outlive the test and can fire, and log, while the +// file's worker shuts down. Nothing here is about sync. +vi.mock('../sync/syncTriggers', () => ({ registerSyncTriggers: vi.fn(), unregisterSyncTriggers: vi.fn() })); + // Default OAuth query params const DEFAULT_SEARCH = '?client_id=test-client&redirect_uri=http%3A%2F%2Flocalhost%3A4000%2Fcallback&scope=trips%3Aread&state=abc&code_challenge=challenge&code_challenge_method=S256'; diff --git a/client/src/pages/dashboard/useDashboard.test.tsx b/client/src/pages/dashboard/useDashboard.test.tsx index 6031b7d35..f3e2d44c8 100644 --- a/client/src/pages/dashboard/useDashboard.test.tsx +++ b/client/src/pages/dashboard/useDashboard.test.tsx @@ -11,6 +11,12 @@ import { useAuthStore } from '../../store/authStore'; import { useDashboard } from './useDashboard'; import type { DashboardTrip } from './dashboardModel'; +// Retrying reloads the user, and loadUser registers the background sync +// triggers: a 30 s heartbeat and window listeners that nothing here +// unregisters, so they outlive the test and can fire, and log, while the +// file's worker shuts down. Nothing here is about sync. +vi.mock('../../sync/syncTriggers', () => ({ registerSyncTriggers: vi.fn(), unregisterSyncTriggers: vi.fn() })); + // FE-HOOK-DASH-001 onwards const PARIS = buildTrip({ id: 101, title: 'Paris Adventure', start_date: '2026-07-01', end_date: '2026-07-10' });