File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,13 @@ import type { Preview } from "@storybook/react-vite";
33import { ThemeProvider , type ThemeMode } from "../src/browser/contexts/ThemeContext" ;
44import { getStorageChangeEvent } from "@/common/constants/events" ;
55import { UI_THEME_KEY } from "@/common/constants/storage" ;
6+
7+ // Utility: detect e2e/test contexts where UI should be hidden (Chromatic, SB test-runner)
8+ const isE2ETestEnv = ( ) => {
9+ if ( typeof window !== "undefined" && ( window as any ) . CHROMATIC ) return true ;
10+ if ( typeof navigator !== "undefined" && / S t o r y b o o k T e s t R u n n e r / i. test ( navigator . userAgent ) ) return true ;
11+ return false ;
12+ } ;
613import "../src/browser/styles/globals.css" ;
714
815const applyStorybookTheme = ( mode : ThemeMode ) => {
@@ -101,7 +108,7 @@ const preview: Preview = {
101108 return (
102109 < ThemeProvider >
103110 < Story />
104- { ! mode && ( typeof navigator === "undefined" || ! / S t o r y b o o k T e s t R u n n e r / i . test ( navigator . userAgent ) ) && (
111+ { ! mode && ! isE2ETestEnv ( ) && (
105112 < StorybookThemeToggle initialTheme = { resolved } />
106113 ) }
107114 </ ThemeProvider >
You can’t perform that action at this time.
0 commit comments