From 8ed623adf8bd6ce5688d777f0a63f31b7362b009 Mon Sep 17 00:00:00 2001
From: Kamil Mielnik <kamil@kamilmielnik.com>
Date: Tue, 5 Nov 2024 17:48:11 +0700
Subject: [PATCH] Update `saveDashboard` helper to wait for the GET
 `/api/dashboard/:id` (#49522)

* Update saveDashboard helper to wait for the GET /api/dashboard/:id request
- update aliases to be unique so that they don't interfere with aliases used in tests

* Remove no longer needed intercept + wait
---
 e2e/support/helpers/e2e-dashboard-helpers.ts              | 8 ++++++--
 .../custom-column/cc-boolean-functions.cy.spec.ts         | 2 --
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/e2e/support/helpers/e2e-dashboard-helpers.ts b/e2e/support/helpers/e2e-dashboard-helpers.ts
index 5f52930e5bd..0c19c67506d 100644
--- a/e2e/support/helpers/e2e-dashboard-helpers.ts
+++ b/e2e/support/helpers/e2e-dashboard-helpers.ts
@@ -84,11 +84,15 @@ export function saveDashboard({
   waitMs = 1,
   awaitRequest = true,
 } = {}) {
-  cy.intercept("PUT", "/api/dashboard/*").as("saveDashboardCards");
+  cy.intercept("PUT", "/api/dashboard/*").as(
+    "saveDashboard-saveDashboardCards",
+  );
+  cy.intercept("GET", "/api/dashboard/*").as("saveDashboard-getDashboard");
   cy.button(buttonLabel).click();
 
   if (awaitRequest) {
-    cy.wait("@saveDashboardCards");
+    cy.wait("@saveDashboard-saveDashboardCards");
+    cy.wait("@saveDashboard-getDashboard");
   }
 
   cy.findByText(editBarText).should("not.exist");
diff --git a/e2e/test/scenarios/custom-column/cc-boolean-functions.cy.spec.ts b/e2e/test/scenarios/custom-column/cc-boolean-functions.cy.spec.ts
index fd926e4803e..63a895f156d 100644
--- a/e2e/test/scenarios/custom-column/cc-boolean-functions.cy.spec.ts
+++ b/e2e/test/scenarios/custom-column/cc-boolean-functions.cy.spec.ts
@@ -693,9 +693,7 @@ describe("scenarios > custom column > boolean functions", () => {
         .findByText(parameterDetails.name)
         .click();
       popover().findByText(expressionName).click();
-      cy.intercept("GET", "/api/dashboard/*").as("getDashboard");
       saveDashboard();
-      cy.wait("@getDashboard");
 
       cy.log("verify click behavior");
       getDashboardCard().within(() => {
-- 
GitLab