Skip to content

Commit d726af7

Browse files
committed
🤖 fix: show manual theme toggle in Chromatic review but hide in automation
1 parent ee606f7 commit d726af7

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

‎.storybook/preview.tsx‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,22 @@ import isChromatic from "chromatic/isChromatic";
66
import { UI_THEME_KEY } from "@/common/constants/storage";
77
import "../src/browser/styles/globals.css";
88

9+
const isAutomatedChromaticRun = () => {
10+
if (typeof window === "undefined" || !isChromatic()) {
11+
return false;
12+
}
13+
if (typeof navigator === "undefined") {
14+
return true;
15+
}
16+
if ("webdriver" in navigator) {
17+
return Boolean(navigator.webdriver);
18+
}
19+
return true;
20+
};
21+
922
// Utility: detect e2e/test contexts where UI should be hidden (Chromatic, SB test-runner)
1023
const isE2ETestEnv = () => {
11-
if (typeof window !== "undefined" && isChromatic()) {
24+
if (isAutomatedChromaticRun()) {
1225
return true;
1326
}
1427
if (typeof navigator !== "undefined" && /StorybookTestRunner/i.test(navigator.userAgent)) {

0 commit comments

Comments
 (0)