From 65633c903ae7f7d5b7c3b0e3343d8e784242bddc Mon Sep 17 00:00:00 2001 From: Dominik Kawka <31955648+dominikkawka@users.noreply.github.com> Date: Mon, 12 Sep 2022 14:30:12 +0100 Subject: [PATCH] Sessions testing (#3285) --- .../cypress/e2e/sessions_test.spec.ts | 70 +++++++++++++++---- .../manage/sessions/SessionsPage.ts | 7 ++ 2 files changed, 63 insertions(+), 14 deletions(-) diff --git a/apps/admin-ui/cypress/e2e/sessions_test.spec.ts b/apps/admin-ui/cypress/e2e/sessions_test.spec.ts index f7d246bff1..64523b8d7d 100644 --- a/apps/admin-ui/cypress/e2e/sessions_test.spec.ts +++ b/apps/admin-ui/cypress/e2e/sessions_test.spec.ts @@ -1,38 +1,80 @@ import LoginPage from "../support/pages/LoginPage"; import SidebarPage from "../support/pages/admin_console/SidebarPage"; import SessionsPage from "../support/pages/admin_console/manage/sessions/SessionsPage"; +import CommonPage from "../support/pages/CommonPage"; +import ListingPage from "../support/pages/admin_console/ListingPage"; +import GroupPage from "../support/pages/admin_console/manage/groups/GroupPage"; import { keycloakBefore } from "../support/util/keycloak_hooks"; const loginPage = new LoginPage(); const sidebarPage = new SidebarPage(); const sessionsPage = new SessionsPage(); +const commonPage = new CommonPage(); +const listingPage = new ListingPage(); +const groupPage = new GroupPage(); describe("Sessions test", () => { + const admin = "admin"; + const client = "security-admin-console"; beforeEach(() => { keycloakBefore(); loginPage.logIn(); sidebarPage.goToSessions(); }); - it("Set revocation notBefore", () => { - sessionsPage.setToNow(); + describe("Sessions list view", () => { + it("check item values", () => { + commonPage + .tableUtils() + .checkRowItemExists(admin) + .checkRowItemExists(client); + }); + + it("go to item accessed clients link", () => { + commonPage.tableUtils().clickRowItemLink(client); + }); }); - it("Check if notBefore saved", () => { - sessionsPage.checkNotBeforeValueExists(); + describe("Search", () => { + it("search existing session", () => { + listingPage.searchItem(admin, false); + listingPage.itemExist(admin, true); + groupPage.assertNoSearchResultsMessageExist(false); + }); + + it("search non-existant session", () => { + listingPage.searchItem("non-existant-session", false); + groupPage.assertNoSearchResultsMessageExist(true); + }); }); - it("Clear revocation notBefore", () => { - sessionsPage.clearNotBefore(); + describe("revocation", () => { + it("Clear revocation notBefore", () => { + sessionsPage.clearNotBefore(); + }); + + it("Check if notBefore cleared", () => { + sessionsPage.checkNotBeforeCleared(); + }); + + it("Set revocation notBefore", () => { + sessionsPage.setToNow(); + }); + + it("Check if notBefore saved", () => { + sessionsPage.checkNotBeforeValueExists(); + }); + + it("Push when URI not configured", () => { + sessionsPage.pushRevocation(); + commonPage.masthead().checkNotificationMessage("No push sent"); + }); }); - it("Check if notBefore cleared", () => { - sessionsPage.checkNotBeforeCleared(); - }); - - it("logout all sessions", () => { - sessionsPage.logoutAllSessions(); - - cy.get("#kc-page-title").contains("Sign in to your account"); + describe("logout all sessions", () => { + it("logout all sessions", () => { + sessionsPage.logoutAllSessions(); + cy.get("#kc-page-title").contains("Sign in to your account"); + }); }); }); diff --git a/apps/admin-ui/cypress/support/pages/admin_console/manage/sessions/SessionsPage.ts b/apps/admin-ui/cypress/support/pages/admin_console/manage/sessions/SessionsPage.ts index d70aa35365..3ba6afe09b 100644 --- a/apps/admin-ui/cypress/support/pages/admin_console/manage/sessions/SessionsPage.ts +++ b/apps/admin-ui/cypress/support/pages/admin_console/manage/sessions/SessionsPage.ts @@ -10,6 +10,7 @@ export default class SessionsPage { setToNowButton = "set-to-now-button"; actionDropdown = "action-dropdown"; clearNotBeforeButton = "clear-not-before-button"; + pushButton = "modal-test-connection-button"; notBeforeInput = "not-before-input"; logoutAll = "logout-all"; logoutAllConfirm = "confirm"; @@ -43,4 +44,10 @@ export default class SessionsPage { cy.findByTestId(this.logoutAll).should("exist").click(); cy.findByTestId(this.logoutAllConfirm).should("exist").click(); } + + pushRevocation() { + cy.findByTestId(this.actionDropdown).should("exist").click(); + cy.findByTestId(this.revocationActionItem).should("exist").click(); + cy.findByTestId(this.pushButton).should("exist").click(); + } }