From d1f9fd446869c61b9ac7f9fec823f776d455f03f Mon Sep 17 00:00:00 2001
From: Nemanja Glumac <31325167+nemanjaglumac@users.noreply.github.com>
Date: Fri, 24 Feb 2023 14:28:33 +0100
Subject: [PATCH] [E2E] Fix explicit joins dashboard filters flake (#28600)

* Limit the number of results for better performance

* Wait for all filter results to load

* Remove the need for popover
---
 ...dashboard-filters-explicit-join.cy.spec.js | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/frontend/test/metabase/scenarios/dashboard-filters/dashboard-filters-explicit-join.cy.spec.js b/frontend/test/metabase/scenarios/dashboard-filters/dashboard-filters-explicit-join.cy.spec.js
index 106456629b8..0848b99ef91 100644
--- a/frontend/test/metabase/scenarios/dashboard-filters/dashboard-filters-explicit-join.cy.spec.js
+++ b/frontend/test/metabase/scenarios/dashboard-filters/dashboard-filters-explicit-join.cy.spec.js
@@ -1,9 +1,4 @@
-import {
-  restore,
-  filterWidget,
-  popover,
-  visitDashboard,
-} from "__support__/e2e/helpers";
+import { restore, filterWidget, visitDashboard } from "__support__/e2e/helpers";
 import { SAMPLE_DATABASE } from "__support__/e2e/cypress_sample_database";
 
 const { ORDERS, ORDERS_ID, PRODUCTS, PRODUCTS_ID } = SAMPLE_DATABASE;
@@ -24,6 +19,7 @@ const questionDetails = {
         alias: "Products",
       },
     ],
+    limit: 5,
   },
 };
 
@@ -41,6 +37,10 @@ const dashboardDetails = {
 
 describe("scenarios > dashboard > filters", () => {
   beforeEach(() => {
+    cy.intercept("GET", `/api/dashboard/*/params/${filter.id}/values`).as(
+      "filterValues",
+    );
+
     restore();
     cy.signInAsAdmin();
 
@@ -78,6 +78,7 @@ describe("scenarios > dashboard > filters", () => {
 
   it("should work properly when connected to the explicitly joined field", () => {
     filterWidget().click();
+    cy.wait("@filterValues");
 
     cy.findByPlaceholderText("Search the list").type("Awe");
 
@@ -100,9 +101,7 @@ describe("scenarios > dashboard > filters", () => {
 });
 
 function selectFromDropdown(values) {
-  popover().within(() => {
-    values.forEach(value => {
-      cy.findByText(value).click();
-    });
+  values.forEach(value => {
+    cy.findByTestId(`${value}-filter-value`).should("be.visible").click();
   });
 }
-- 
GitLab