From daa805f3e6646eda544186833a0ced2094a2ddf4 Mon Sep 17 00:00:00 2001
From: Alexander Lesnenko <alxnddr@users.noreply.github.com>
Date: Thu, 13 May 2021 23:08:43 +0300
Subject: [PATCH] Fix table visualization flaky spec (#16041)

* hack table visualization flaky spec

* Fix the flake by waiting for the table to update

Co-authored-by: Nemanja <31325167+nemanjaglumac@users.noreply.github.com>
---
 .../metabase/scenarios/visualizations/table.cy.spec.js     | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/frontend/test/metabase/scenarios/visualizations/table.cy.spec.js b/frontend/test/metabase/scenarios/visualizations/table.cy.spec.js
index c84687e3731..91349282ab2 100644
--- a/frontend/test/metabase/scenarios/visualizations/table.cy.spec.js
+++ b/frontend/test/metabase/scenarios/visualizations/table.cy.spec.js
@@ -15,6 +15,7 @@ describe("scenarios > visualizations > table", () => {
   beforeEach(() => {
     restore();
     cy.signInAsNormalUser();
+    cy.intercept("POST", "/api/dataset").as("dataset");
   });
 
   it("should allow to display any column as link with extrapolated url and text", () => {
@@ -22,6 +23,7 @@ describe("scenarios > visualizations > table", () => {
       dataset_query: testQuery,
       display: "table",
     });
+    cy.wait("@dataset");
 
     cy.findByText("City").click();
 
@@ -34,10 +36,15 @@ describe("scenarios > visualizations > table", () => {
     popover().within(() => {
       cy.findByText("Link").click();
     });
+    // There is a lag caused by update of the table visualization which breaks Cypress typing.
+    // Any field in the table will not be "actionable" (the whole table has an overlay with pointer-events set to none) so Cypress cannot click it.
+    // Adding this line makes sure the table finished updating, and solves the typing issue.
+    cy.findByText("Address").click();
 
     cy.findByTestId("link_text").type("{{CITY}} {{ID}} fixed text", {
       parseSpecialCharSequences: false,
     });
+
     cy.findByTestId("link_url").type("http://metabase.com/people/{{ID}}", {
       parseSpecialCharSequences: false,
     });
-- 
GitLab