Skip to content
Snippets Groups Projects
Unverified Commit 0c0e84ce authored by Nemanja Glumac's avatar Nemanja Glumac Committed by GitHub
Browse files

Use Cypress event listener for `beforeunload` globally (#38264)

parent 1011ecdb
No related branches found
No related tags found
No related merge requests found
......@@ -54,3 +54,24 @@ Cypress.on("test:after:run", (test, runnable) => {
);
}
});
/**
* Our app registers beforeunload event listener e.g. when editing a native SQL question.
* Cypress does not automatically close the browser prompt and does not allow manually
* interacting with it (unlike with window.confirm). The test will hang forever with
* the prompt displayed and will eventually time out. We need to work around this by
* monkey-patching window.addEventListener to ignore beforeunload event handlers.
*
* @see https://github.com/cypress-io/cypress/issues/2118
*/
Cypress.on("window:load", window => {
const addEventListener = window.addEventListener;
window.addEventListener = function (event) {
if (event === "beforeunload") {
return;
}
return addEventListener.apply(this, arguments);
};
});
......@@ -36,27 +36,6 @@ const TEST_CASES = [
{ case: "dashboard", subject: DASHBOARD_NAME, confirmSave: false },
];
/**
* Our app registers beforeunload event listener e.g. when editing a native SQL question.
* Cypress does not automatically close the browser prompt and does not allow manually
* interacting with it (unlike with window.confirm). The test will hang forever with
* the prompt displayed and will eventually time out. We need to work around this by
* monkey-patching window.addEventListener to ignore beforeunload event handlers.
*
* @see https://github.com/cypress-io/cypress/issues/2118
*/
Cypress.on("window:load", window => {
const addEventListener = window.addEventListener;
window.addEventListener = function (event) {
if (event === "beforeunload") {
return;
}
return addEventListener.apply(this, arguments);
};
});
describe("scenarios > visualizations > pivot tables", { tags: "@slow" }, () => {
beforeEach(() => {
restore();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment