From 4bb994f50c67d8da8d5b119e8ef483e3668e2e57 Mon Sep 17 00:00:00 2001 From: gsxdsm Date: Sat, 15 Aug 2026 22:25:01 -0700 Subject: [PATCH] test(dashboard): purge leaked mockResolvedValueOnce queues in App.test isolation reset MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Root-cause fix for the order-sensitive 'closes board-opened main-panel task detail on one browser back' flake: vi.clearAllMocks() clears calls but never drops unconsumed mockResolvedValueOnce entries, and a plain mockResolvedValue default does not purge them either — the once-queue wins first. A prior test's unconsumed auth/settings/health/plugin-views Once value poisoned the next test's first fetch, rendering an auto-opened modal surface instead of the board. The global beforeEach now mockReset()s every once-queue-prone API mock before re-applying its default (fetchPluginDashboardViews gains an explicit empty default since its factory impl dies with the reset). 4/4 consecutive full-file runs green (was ~1-in-3 failing); no assertions changed, no quarantine needed. Co-Authored-By: Claude Fable 5 --- .../dashboard/app/components/__tests__/App.test.tsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/dashboard/app/components/__tests__/App.test.tsx b/packages/dashboard/app/components/__tests__/App.test.tsx index 112ccbafda..d9eb316d28 100644 --- a/packages/dashboard/app/components/__tests__/App.test.tsx +++ b/packages/dashboard/app/components/__tests__/App.test.tsx @@ -824,7 +824,20 @@ beforeEach(() => { /* * FNXC:DashboardTests 2026-06-22-03:47: * App.test.tsx runs beside other dashboard specs in the same Vitest process, so reset API mock implementations as well as call counts to prevent cross-file implementation leakage. + * + * FNXC:DashboardTests 2026-08-16-05:22: + * vi.clearAllMocks() clears calls but NEVER drops unconsumed mockResolvedValueOnce queue + * entries, and a plain mockResolvedValue default does not purge them either — the once-queue + * always wins first. A test that queued a Once response and bailed before consuming it (auth + * status, settings, health, plugin views) therefore poisoned the NEXT test's first fetch, + * which is why "closes board-opened main-panel task detail on one browser back" flaked: a + * leaked auth/settings Once value made App render an auto-opened modal surface instead of the + * board. mockReset each once-queue-prone API mock here, then re-apply its default below. */ + for (const onceProneApiMock of [fetchSettings, updateSettings, fetchGlobalSettings, fetchDashboardHealth, fetchAuthStatus, fetchModels, fetchScripts, runScript, fetchBoardWorkflows, fetchPluginDashboardViews]) { + vi.mocked(onceProneApiMock).mockReset(); + } + vi.mocked(fetchPluginDashboardViews).mockResolvedValue([]); vi.mocked(fetchSettings).mockResolvedValue({ ...defaultSettings }); vi.mocked(updateSettings).mockResolvedValue({ ...defaultSettings }); vi.mocked(fetchGlobalSettings).mockResolvedValue({ modelOnboardingComplete: true });