Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions cypress/support/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,19 @@ const knownHydrationErrors = [
/Minified React error #425\b/,
];

const knownPlaygroundBootstrapErrors = [
/Sys_error.*file already exists/i,
Comment thread
jderochervlk marked this conversation as resolved.
/\/static\/Belt\.cmi\s*:\s*file already exists/i,
];

Cypress.on("uncaught:exception", (err) => {
const message = err && err.message ? err.message : "";
const isKnownHydrationError = knownHydrationErrors.some((pattern) =>
pattern.test(message),
);
const isKnownPlaygroundBootstrapError = knownPlaygroundBootstrapErrors.some(
(pattern) => pattern.test(message),
);

if (isKnownHydrationError) {
console.warn("Suppressing known React hydration exception in Cypress:", {
Expand All @@ -20,4 +28,15 @@ Cypress.on("uncaught:exception", (err) => {
});
return false;
}

if (isKnownPlaygroundBootstrapError) {
console.warn(
"Suppressing known Playground bootstrap exception in Cypress:",
{
message,
error: err,
},
);
return false;
}
});
39 changes: 39 additions & 0 deletions e2e/Playground.cy.res
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,43 @@ describe("Playground", () => {
->shouldContainText("Hello ReScript!")
->ignore
})

it("should switch to light mode from toast and back to dark mode in settings", () => {
// Navigate to playground and wait for initial render
clickNavLink(~testId="navbar-primary-left-content", ~text="Playground")
url()->shouldInclude("/try")->ignore
waitForPlayground()

// Switch to light mode through the onboarding toast
getByTestId("playground-lightmode-toast")
->should("be.visible")
->find("button")
->containsChainable("Try it now")
->click
->ignore

// Verify playground shell is in light mode
get("main")->shouldWithValue("have.class", "playground-theme-light")->ignore
cyWindow()
->its("localStorage")
->invokeWithArg("getItem", "playgroundTheme")
->shouldWithValue("eq", "light")
->ignore

// Switch back to dark mode from Settings
contains("Settings")->click->ignore
get("main")
->find("button")
->containsChainable("Dark")
->click
->ignore

// Verify playground shell is back to dark mode
get("main")->shouldWithValue("have.class", "playground-theme-dark")->ignore
cyWindow()
->its("localStorage")
->invokeWithArg("getItem", "playgroundTheme")
->shouldWithValue("eq", "dark")
->ignore
})
})
Loading
Loading