Skip to content

Commit 3b0d4b6

Browse files
jderochervlkcodex
andauthored
feat(playground): add light mode toggle and announcement toast (#1250)
* feat(playground): add light mode toggle and announcement toast Add a dark/light playground theme with default dark and persisted theme selection. Wire runtime CodeMirror theme reconfiguration, theme-aware JS output highlighting, and settings controls. Add a new light-mode toast with dismiss and try-it-now actions, auto-hide timeout, and session-based seen tracking. * fix(playground): improve light mode contrast and cover theme toggle flow Improve light-mode readability for the Auto-run control and center divider styling. Add Cypress coverage for toast-driven light mode switch and switching back to dark in settings. Co-authored-by: Codex <codex@openai.com> * chore: remove temporary playground light mode plan doc * change wording * adjust colors a bit * update cypress test * fix failing cypress tests * pr feedback --------- Co-authored-by: Codex <codex@openai.com>
1 parent 7c4a69b commit 3b0d4b6

7 files changed

Lines changed: 594 additions & 89 deletions

File tree

cypress/support/e2e.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,19 @@ const knownHydrationErrors = [
77
/Minified React error #425\b/,
88
];
99

10+
const knownPlaygroundBootstrapErrors = [
11+
/Sys_error.*file already exists/i,
12+
/\/static\/Belt\.cmi\s*:\s*file already exists/i,
13+
];
14+
1015
Cypress.on("uncaught:exception", (err) => {
1116
const message = err && err.message ? err.message : "";
1217
const isKnownHydrationError = knownHydrationErrors.some((pattern) =>
1318
pattern.test(message),
1419
);
20+
const isKnownPlaygroundBootstrapError = knownPlaygroundBootstrapErrors.some(
21+
(pattern) => pattern.test(message),
22+
);
1523

1624
if (isKnownHydrationError) {
1725
console.warn("Suppressing known React hydration exception in Cypress:", {
@@ -20,4 +28,15 @@ Cypress.on("uncaught:exception", (err) => {
2028
});
2129
return false;
2230
}
31+
32+
if (isKnownPlaygroundBootstrapError) {
33+
console.warn(
34+
"Suppressing known Playground bootstrap exception in Cypress:",
35+
{
36+
message,
37+
error: err,
38+
},
39+
);
40+
return false;
41+
}
2342
});

e2e/Playground.cy.res

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,43 @@ describe("Playground", () => {
6464
->shouldContainText("Hello ReScript!")
6565
->ignore
6666
})
67+
68+
it("should switch to light mode from toast and back to dark mode in settings", () => {
69+
// Navigate to playground and wait for initial render
70+
clickNavLink(~testId="navbar-primary-left-content", ~text="Playground")
71+
url()->shouldInclude("/try")->ignore
72+
waitForPlayground()
73+
74+
// Switch to light mode through the onboarding toast
75+
getByTestId("playground-lightmode-toast")
76+
->should("be.visible")
77+
->find("button")
78+
->containsChainable("Try it now")
79+
->click
80+
->ignore
81+
82+
// Verify playground shell is in light mode
83+
get("main")->shouldWithValue("have.class", "playground-theme-light")->ignore
84+
cyWindow()
85+
->its("localStorage")
86+
->invokeWithArg("getItem", "playgroundTheme")
87+
->shouldWithValue("eq", "light")
88+
->ignore
89+
90+
// Switch back to dark mode from Settings
91+
contains("Settings")->click->ignore
92+
get("main")
93+
->find("button")
94+
->containsChainable("Dark")
95+
->click
96+
->ignore
97+
98+
// Verify playground shell is back to dark mode
99+
get("main")->shouldWithValue("have.class", "playground-theme-dark")->ignore
100+
cyWindow()
101+
->its("localStorage")
102+
->invokeWithArg("getItem", "playgroundTheme")
103+
->shouldWithValue("eq", "dark")
104+
->ignore
105+
})
67106
})

0 commit comments

Comments
 (0)