From 3dccdd27c7e0e869beb4bb916bf19d3b40f325d6 Mon Sep 17 00:00:00 2001
From: Nemanja Glumac <31325167+nemanjaglumac@users.noreply.github.com>
Date: Mon, 10 Jul 2023 23:12:11 +0200
Subject: [PATCH] Fix flake in `impersonated` E2E spec (#32276)

Whenever hover is involved, we need to make sure UI is absolutely stable.
In failed test cases, the top bar with the test id `edit-bar` was being
removed at the very moment we're trying to hover the warning icon.

This PR makes sure UI updated before we even search for that icon.
---
 e2e/test/scenarios/permissions/impersonated.cy.spec.js | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/e2e/test/scenarios/permissions/impersonated.cy.spec.js b/e2e/test/scenarios/permissions/impersonated.cy.spec.js
index 164b38d3914..bdb636f4fa1 100644
--- a/e2e/test/scenarios/permissions/impersonated.cy.spec.js
+++ b/e2e/test/scenarios/permissions/impersonated.cy.spec.js
@@ -366,8 +366,11 @@ describeEE("impersonated permission", () => {
 });
 
 function savePermissions() {
-  cy.get("main").findByText("Save changes").click();
+  cy.findByTestId("edit-bar").button("Save changes").click();
   cy.findByRole("dialog").findByText("Yes").click();
+  cy.findByTestId("edit-bar")
+    .findByText("You've made changes to permissions.")
+    .should("not.exist");
 }
 
 function selectImpersonatedAttribute(attribute) {
-- 
GitLab