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 986d97857a..169a70198c 100644 --- a/js/apps/admin-ui/cypress/e2e/realm_test.spec.ts +++ b/js/apps/admin-ui/cypress/e2e/realm_test.spec.ts @@ -34,23 +34,20 @@ describe("Realm tests", () => { ), ); - it("should fail creating Master realm", () => { + it("should fail creating duplicated or empty name realm", () => { sidebarPage.goToCreateRealm(); + + createRealmPage.createRealm().verifyRealmNameFieldInvalid(); + createRealmPage.fillRealmName("master").createRealm(); masthead.checkNotificationMessage( "Could not create realm Conflict detected. See logs for details", ); + createRealmPage.cancelRealmCreation(); }); - it("should fail creating realm with empty name", () => { - sidebarPage.goToCreateRealm(); - createRealmPage.createRealm(); - - createRealmPage.verifyRealmNameFieldInvalid(); - }); - it("should create Test realm", () => { sidebarPage.goToCreateRealm(); @@ -63,24 +60,27 @@ describe("Realm tests", () => { masthead.checkNotificationMessage("Realm created successfully"); }); - it("should create Test Disabled realm", () => { + it("CRUD test of Disabled realm", () => { sidebarPage.goToCreateRealm(); sidebarPage.waitForPageLoad(); createRealmPage.fillRealmName(testDisabledName).createRealm(); - createRealmPage.disableRealm(); masthead.checkNotificationMessage("Realm created successfully"); - }); - it("Should cancel deleting Test Disabled realm", () => { + cy.reload(); + sidebarPage.goToRealm(testDisabledName).goToRealmSettings(); + + createRealmPage.disableRealm(); + modalUtils.confirmModal(); + + masthead.checkNotificationMessage("Realm successfully updated"); + sidebarPage.goToRealm(testDisabledName).goToRealmSettings(); realmSettings.clickActionMenu(); cy.findByText("Delete").click(); modalUtils.cancelModal(); - }); - it("Should delete Test Disabled realm", () => { cy.reload(); sidebarPage.waitForPageLoad(); sidebarPage.goToRealm(testDisabledName).goToRealmSettings(); @@ -90,7 +90,7 @@ describe("Realm tests", () => { masthead.checkNotificationMessage("The realm has been deleted"); // Show current realms - sidebarPage.showCurrentRealms(2); + sidebarPage.realmExists("Test-Disabled", false); }); it("should create realm from new a realm", () => { diff --git a/js/apps/admin-ui/cypress/support/pages/admin-ui/CreateRealmPage.ts b/js/apps/admin-ui/cypress/support/pages/admin-ui/CreateRealmPage.ts index c7673f9846..bac776cbfc 100644 --- a/js/apps/admin-ui/cypress/support/pages/admin-ui/CreateRealmPage.ts +++ b/js/apps/admin-ui/cypress/support/pages/admin-ui/CreateRealmPage.ts @@ -2,7 +2,7 @@ export default class CreateRealmPage { #clearBtn = ".pf-c-file-upload__file-select button:last-child"; #modalClearBtn = "clear-button"; #realmNameInput = "#kc-realm-name"; - #enabledSwitch = '[for="kc-realm-enabled-switch"] span.pf-c-switch__toggle'; + #enabledSwitch = ".pf-c-toolbar .pf-c-switch__toggle"; #createBtn = '.pf-c-form__group:last-child button[type="submit"]'; #cancelBtn = '.pf-c-form__group:last-child button[type="button"]'; #codeEditor = ".pf-c-code-editor__code"; 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 e170818de5..1f10227eeb 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 @@ -72,8 +72,12 @@ export default class ListingPage extends CommonElements { } showNextPageTableItems() { - cy.get(this.#nextPageBtn).scrollIntoView(); - cy.get(this.#nextPageBtn).click(); + cy.get("body").then(($body) => { + if (!$body.find('[data-testid="' + this.#nextPageBtn + '"]').length) { + cy.get(this.#nextPageBtn).scrollIntoView(); + cy.get(this.#nextPageBtn).click(); + } + }); return this; } diff --git a/js/apps/admin-ui/cypress/support/pages/admin-ui/SidebarPage.ts b/js/apps/admin-ui/cypress/support/pages/admin-ui/SidebarPage.ts index a954d5531a..446f99ca49 100644 --- a/js/apps/admin-ui/cypress/support/pages/admin-ui/SidebarPage.ts +++ b/js/apps/admin-ui/cypress/support/pages/admin-ui/SidebarPage.ts @@ -17,13 +17,29 @@ export default class SidebarPage extends CommonElements { #identityProvidersBtn = "#nav-item-identity-providers"; #userFederationBtn = "#nav-item-user-federation"; + realmsElements = '[data-testid="realmSelector"] li'; + showCurrentRealms(length: number) { cy.findByTestId(this.#realmsDrpDwn).click(); - cy.get('[data-testid="realmSelector"] li').should( + cy.get(this.realmsElements).contains("Loading realms…").should("not.exist"); + cy.get(this.realmsElements).should( "have.length", length + 1, // account for button ); cy.findByTestId(this.#realmsDrpDwn).click({ force: true }); + + return this; + } + + realmExists(realmName: string, exists = true) { + cy.findByTestId(this.#realmsDrpDwn).click(); + cy.get(this.realmsElements).contains("Loading realms…").should("not.exist"); + cy.get(this.realmsElements) + .contains(realmName) + .should((exists ? "" : "not.") + "exist"); + cy.findByTestId(this.#realmsDrpDwn).click(); + + return this; } getCurrentRealm() { @@ -32,11 +48,9 @@ export default class SidebarPage extends CommonElements { goToRealm(realmName: string) { this.waitForPageLoad(); - cy.findByTestId(this.#realmsDrpDwn) - .click() - .parent() - .contains(realmName) - .click(); + cy.findByTestId(this.#realmsDrpDwn).click(); + cy.get(this.realmsElements).contains("Loading realms…").should("not.exist"); + cy.get(this.realmsElements).contains(realmName).click(); this.waitForPageLoad(); return this;