Skip to content

Commit

Permalink
Fix Cypress flakes (metabase#13421)
Browse files Browse the repository at this point in the history
* Fix `public.cy.spec.js` flake

Note in the comment clearly says that the tests are sequential. If the first one fails, it affects the others.
That's why we were seeing 9 failed tests in this file alone.

* Fix `snippet.cy.spec.js` flake

In very rare occasions it happened that test runner doesn't clear the input field before it starts typing new name.
That's how we end up with `stuff-snippetMath` instead of just `Math`.

* Wait for a dashboard to update

NOTE:
- In the latest CI run click on "Category" happened before this XHR
- due to congestion or a slow network, popover couldn't be found within 4s (Cypress started searching for it immediately after the previous click)

* Fix `modal()` + "Not now" related set of flakes

* Quarantine `public.cy.spec.js`
  • Loading branch information
nemanjaglumac authored Oct 9, 2020
1 parent 8412f44 commit fa7db31
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 14 deletions.
4 changes: 1 addition & 3 deletions frontend/test/metabase-db/mongo/query.cy.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,7 @@ describe("mongodb > user > query", () => {
expect(status).to.equal(202);
});

modal()
.contains("Not now")
.click();
cy.findByText("Not now").click();

cy.url().should("match", /\/question\/\d+$/);
});
Expand Down
12 changes: 9 additions & 3 deletions frontend/test/metabase/scenarios/public/public.cy.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ describe("scenarios > public", () => {
let dashboardPublicLink;
let dashboardEmbedUrl;

describe("questions", () => {
// [quarantined 2020-10-09]: - constantly breaking in CI,
// - React console errors,
// - needs fixing in isolation before being introduced to master again
describe.skip("questions", () => {
// Note: Test suite is sequential, so individual test cases can't be run individually
it("should allow users to create parameterized dashboards", () => {
cy.visit(`/question/${questionId}`);
Expand Down Expand Up @@ -107,8 +110,11 @@ describe("scenarios > public", () => {
.find("fieldset")
.should("not.exist");

cy.contains("Category").click();
cy.focused().type("Doohickey");
cy.findByText("Category").click();

popover().within(() => {
cy.findByText("Doohickey").click();
});
cy.contains("Add filter").click();
cy.contains(COUNT_DOOHICKEY);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@ describe("scenarios > question > native", () => {
modal().within(() => {
cy.findByLabelText("Name").type(QUESTION);
cy.findByText("Save").click();
cy.findByText("Not now").click();
});
cy.findByText("Not now").click();

cy.visit("/");
cy.findByText("Ask a question").click();
Expand Down
8 changes: 2 additions & 6 deletions frontend/test/metabase/scenarios/question/notebook.cy.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,7 @@ describe("scenarios > question > notebook", () => {
typeAndBlurUsingLabel("Name", "Q1");
cy.findByText("Save").click();
});
modal().within(() => {
cy.findByText("Not now").click();
});
cy.findByText("Not now").click();

cy.log("**Prepare Question 2**");
openProductsTable();
Expand Down Expand Up @@ -192,9 +190,7 @@ describe("scenarios > question > notebook", () => {
typeAndBlurUsingLabel("Name", "Q2");
cy.findByText("Save").click();
});
modal().within(() => {
cy.findByText("Not now").click();
});
cy.findByText("Not now").click();

cy.log("**Create Question 3 based on 2 previously saved questions**");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import { signInAsNormalUser, restore, modal } from "__support__/cypress";
// HACK which lets us type (even very long words) without losing focus
// this is needed for fields where autocomplete suggestions are enabled
function _clearAndIterativelyTypeUsingLabel(label, string) {
cy.findByLabelText(label).clear();
cy.findByLabelText(label)
.click()
.clear();

for (const char of string) {
cy.findByLabelText(label).type(char);
Expand Down

0 comments on commit fa7db31

Please sign in to comment.