From e6179e31871190fb44f418cdd4881367f0082133 Mon Sep 17 00:00:00 2001 From: Nemanja Glumac <31325167+nemanjaglumac@users.noreply.github.com> Date: Mon, 22 Aug 2022 17:12:31 +0200 Subject: [PATCH] [E2E] Fix flakes in 22700 (#24923) --- .../admin/datamodel/metrics.cy.spec.js | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/frontend/test/metabase/scenarios/admin/datamodel/metrics.cy.spec.js b/frontend/test/metabase/scenarios/admin/datamodel/metrics.cy.spec.js index f81c5712e44..6c6c9b62fe0 100644 --- a/frontend/test/metabase/scenarios/admin/datamodel/metrics.cy.spec.js +++ b/frontend/test/metabase/scenarios/admin/datamodel/metrics.cy.spec.js @@ -93,8 +93,7 @@ describe("scenarios > admin > datamodel > metrics", () => { cy.visit("/admin/datamodel/metrics"); cy.button("New metric").click(); - cy.findByText("Select a table").click(); - cy.findByText("Orders").click(); + selectTable("Orders"); // It sees that there is one dataset query for each of the fields: // `data`, `filtered by` and `view` cy.wait(["@dataset", "@dataset", "@dataset"]); @@ -265,18 +264,8 @@ describe("scenarios > admin > datamodel > metrics", () => { it("should show CE that uses 'AND/OR' (metabase#13069, metabase#13070)", () => { cy.visit("/admin/datamodel/metrics"); cy.findByText("New metric").click(); - cy.findByText("Select a table").click(); - - // Ugly hack to prevent failures that started after https://github.com/metabase/metabase/pull/24682 has been merged. - // For unknon reasons, popover doesn't open with expanded list of all Sample Database tables. Rather. it shows - // Sample Database (collapsed) only. We need to click on it to expand it. - // This conditional mechanism prevents failures even if that popover opens expanded in the future. - cy.get(".List-section").then($list => { - if ($list.length !== 5) { - cy.findByText("Sample Database").click(); - } - cy.findByText("Orders").click(); - }); + + selectTable("Orders"); cy.findByText("Add filters to narrow your answer").click(); cy.findByText("Custom Expression").click(); @@ -288,3 +277,18 @@ describe("scenarios > admin > datamodel > metrics", () => { }); }); }); + +// Ugly hack to prevent failures that started after https://github.com/metabase/metabase/pull/24682 has been merged. +// For unknon reasons, popover doesn't open with expanded list of all Sample Database tables. Rather. it shows +// Sample Database (collapsed) only. We need to click on it to expand it. +// This conditional mechanism prevents failures even if that popover opens expanded in the future. +function selectTable(tableName) { + cy.findByText("Select a table").click(); + + cy.get(".List-section").then($list => { + if ($list.length !== 5) { + cy.findByText("Sample Database").click(); + } + cy.findByText(tableName).click(); + }); +} -- GitLab