From ac6f16df70cd33d6ee1910c092d49ebaf552c335 Mon Sep 17 00:00:00 2001 From: Aboullos <61687012+Aboullos@users.noreply.github.com> Date: Mon, 5 Feb 2024 16:37:16 +0100 Subject: [PATCH] Add actions for flaky Admin UI tests (#26778) Signed-off-by: Alfredo Moises Boullosa --- .../cypress/e2e/authentication_test.spec.ts | 7 +++++-- js/apps/admin-ui/cypress/e2e/realm_test.spec.ts | 2 ++ .../support/pages/admin-ui/ListingPage.ts | 7 ++++--- .../manage/authentication/RequiredActions.ts | 17 +++++++++-------- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/js/apps/admin-ui/cypress/e2e/authentication_test.spec.ts b/js/apps/admin-ui/cypress/e2e/authentication_test.spec.ts index f861f65e8b..522fa577dc 100644 --- a/js/apps/admin-ui/cypress/e2e/authentication_test.spec.ts +++ b/js/apps/admin-ui/cypress/e2e/authentication_test.spec.ts @@ -224,14 +224,17 @@ describe("Required actions", () => { it("should enable delete account", () => { const action = "Delete Account"; - requiredActionsPage.enableAction(action); + requiredActionsPage.switchAction(action); masthead.checkNotificationMessage("Updated required action successfully"); requiredActionsPage.isChecked(action); }); it("should register an unregistered action", () => { const action = "Verify Profile"; - requiredActionsPage.enableAction(action); + requiredActionsPage.isChecked(action).isDefaultEnabled(action); + requiredActionsPage.switchAction(action); + masthead.checkNotificationMessage("Updated required action successfully"); + requiredActionsPage.switchAction(action); masthead.checkNotificationMessage("Updated required action successfully"); requiredActionsPage.isChecked(action).isDefaultEnabled(action); }); diff --git a/js/apps/admin-ui/cypress/e2e/realm_test.spec.ts b/js/apps/admin-ui/cypress/e2e/realm_test.spec.ts index 8e34958701..986d97857a 100644 --- a/js/apps/admin-ui/cypress/e2e/realm_test.spec.ts +++ b/js/apps/admin-ui/cypress/e2e/realm_test.spec.ts @@ -81,6 +81,8 @@ describe("Realm tests", () => { }); it("Should delete Test Disabled realm", () => { + cy.reload(); + sidebarPage.waitForPageLoad(); sidebarPage.goToRealm(testDisabledName).goToRealmSettings(); realmSettings.clickActionMenu(); cy.findByText("Delete").click(); diff --git a/js/apps/admin-ui/cypress/support/pages/admin-ui/ListingPage.ts b/js/apps/admin-ui/cypress/support/pages/admin-ui/ListingPage.ts index 538149c951..e170818de5 100644 --- a/js/apps/admin-ui/cypress/support/pages/admin-ui/ListingPage.ts +++ b/js/apps/admin-ui/cypress/support/pages/admin-ui/ListingPage.ts @@ -48,9 +48,9 @@ export default class ListingPage extends CommonElements { #listHeaderSecondaryBtn = ".pf-c-page__main .pf-c-toolbar__content-section .pf-m-link"; #previousPageBtn = - "div[class=pf-c-pagination__nav-control] button[data-action=previous]:visible"; + ".pf-c-pagination:not([class*=pf-m-bottom]) button[data-action=previous]"; #nextPageBtn = - "div[class=pf-c-pagination__nav-control] button[data-action=next]:visible"; + ".pf-c-pagination:not([class*=pf-m-bottom]) button[data-action=next]"; public tableRowItem = "tbody tr[data-ouia-component-type]:visible"; #table = "table[aria-label]"; #filterSessionDropdownButton = ".pf-c-select button:nth-child(1)"; @@ -72,7 +72,8 @@ export default class ListingPage extends CommonElements { } showNextPageTableItems() { - cy.get(this.#nextPageBtn).first().click(); + cy.get(this.#nextPageBtn).scrollIntoView(); + cy.get(this.#nextPageBtn).click(); return this; } diff --git a/js/apps/admin-ui/cypress/support/pages/admin-ui/manage/authentication/RequiredActions.ts b/js/apps/admin-ui/cypress/support/pages/admin-ui/manage/authentication/RequiredActions.ts index a142ad2580..e86da6366a 100644 --- a/js/apps/admin-ui/cypress/support/pages/admin-ui/manage/authentication/RequiredActions.ts +++ b/js/apps/admin-ui/cypress/support/pages/admin-ui/manage/authentication/RequiredActions.ts @@ -7,10 +7,10 @@ export default class RequiredActions { return name.replace(/\s/g, "-"); } - #getEnabled(name: string) { + #getEnabledSwitch(name: string) { return `#enable-${this.#toKey(name)}`; } - #getDefault(name: string) { + #getDefaultSwitch(name: string) { return `#default-${this.#toKey(name)}`; } @@ -18,28 +18,29 @@ export default class RequiredActions { cy.findByTestId("requiredActions").click(); } - enableAction(name: string) { - cy.get(this.#getEnabled(name)).click({ force: true }); + switchAction(name: string) { + cy.get(this.#getEnabledSwitch(name)).scrollIntoView(); + cy.get(this.#getEnabledSwitch(name)).click({ force: true }); return this; } isChecked(name: string) { - cy.get(this.#getEnabled(name)).should("be.checked"); + cy.get(this.#getEnabledSwitch(name)).should("be.checked"); return this; } isDefaultEnabled(name: string) { - cy.get(this.#getDefault(name)).should("be.enabled"); + cy.get(this.#getDefaultSwitch(name)).should("be.enabled"); return this; } setAsDefault(name: string) { - cy.get(this.#getDefault(name)).click({ force: true }); + cy.get(this.#getDefaultSwitch(name)).click({ force: true }); return this; } isDefaultChecked(name: string) { - cy.get(this.#getEnabled(name)).should("be.checked"); + cy.get(this.#getEnabledSwitch(name)).should("be.checked"); return this; }