From 60b0aa1558bc20bff63dd66f37ed055e725cb83f Mon Sep 17 00:00:00 2001 From: Mahakisore7 Date: Sat, 19 Sep 2026 20:37:54 +0530 Subject: [PATCH] fix: clear localStorage between ThemeContext tests to stop cross-test leak CI's Linux jsdom has a working localStorage (unlike this project's local dev environment), so the "defaults to light" test's persisted value was leaking into the "defaults to dark" test and masking the matchMedia stub, failing CI while passing locally. Co-Authored-By: Claude Sonnet 5 --- apps/web/test/state/ThemeContext.test.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/apps/web/test/state/ThemeContext.test.tsx b/apps/web/test/state/ThemeContext.test.tsx index 65c7205..a32dd74 100644 --- a/apps/web/test/state/ThemeContext.test.tsx +++ b/apps/web/test/state/ThemeContext.test.tsx @@ -12,12 +12,22 @@ function ThemeProbe() { ); } +function clearStoredTheme(): void { + try { + window.localStorage.clear(); + } catch { + // Unavailable in some environments (see ThemeContext.tsx) — nothing to clear. + } +} + beforeEach(() => { document.documentElement.classList.remove("dark"); + clearStoredTheme(); }); afterEach(() => { document.documentElement.classList.remove("dark"); + clearStoredTheme(); vi.unstubAllGlobals(); });