From c7fc0a8002497b00d247c9516dc487ac5dfb5267 Mon Sep 17 00:00:00 2001 From: Agnieszka Gancarczyk Date: Wed, 14 Jul 2021 11:14:03 +0100 Subject: [PATCH 1/2] sessions: added cypress tests for session types dropdown display --- cypress/integration/sessions_test.spec.ts | 46 ++++++++++++++ .../manage/sessions/SessionsPage.ts | 62 +++++++++++++++++++ 2 files changed, 108 insertions(+) create mode 100644 cypress/integration/sessions_test.spec.ts create mode 100644 cypress/support/pages/admin_console/manage/sessions/SessionsPage.ts diff --git a/cypress/integration/sessions_test.spec.ts b/cypress/integration/sessions_test.spec.ts new file mode 100644 index 0000000000..a718f13b43 --- /dev/null +++ b/cypress/integration/sessions_test.spec.ts @@ -0,0 +1,46 @@ +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 { keycloakBefore } from "../support/util/keycloak_before"; + +const loginPage = new LoginPage(); +const sidebarPage = new SidebarPage(); +const sessionsPage = new SessionsPage(); + +describe("Sessions test", function () { + describe("Session type dropdown", function () { + beforeEach(function () { + keycloakBefore(); + loginPage.logIn(); + sidebarPage.goToSessions(); + }); + + it("Check dropdown display", () => { + sessionsPage.shouldDisplay(); + }); + + it("Check dropdown options exist", () => { + sessionsPage.shouldNotBeEmpty(); + }); + + it("Select 'All session types' dropdown option", () => { + sessionsPage.selectAllSessionsType(); + }); + + it("Select 'Regular SSO' dropdown option", () => { + sessionsPage.selectRegularSSO(); + }); + + it("Select 'Offline' dropdown option", () => { + sessionsPage.selectOffline(); + }); + + it("Select 'Direct grant' dropdown option", () => { + sessionsPage.selectDirectGrant(); + }); + + it("Select 'Service account' dropdown option", () => { + sessionsPage.selectServiceAccount(); + }); + }); +}); diff --git a/cypress/support/pages/admin_console/manage/sessions/SessionsPage.ts b/cypress/support/pages/admin_console/manage/sessions/SessionsPage.ts new file mode 100644 index 0000000000..3ce41339a1 --- /dev/null +++ b/cypress/support/pages/admin_console/manage/sessions/SessionsPage.ts @@ -0,0 +1,62 @@ +export default class SessionsPage { + sessionTypeDrpDwn: string; + sessionTypeList: string; + allSessionTypesOption: string; + regularSSOOption: string; + offlineOption: string; + directGrantOption: string; + serviceAccountOption: string; + selectedType: string; + + constructor() { + this.sessionTypeDrpDwn = ".pf-c-select__toggle"; + this.sessionTypeList = ".pf-c-select__toggle + ul"; + this.allSessionTypesOption = '[data-testid="all-sessions-option"]'; + this.regularSSOOption = '[data-testid="regular-sso-option"'; + this.offlineOption = '[data-testid="offline-option"'; + this.directGrantOption = '[data-testid="direct-grant-option"'; + this.serviceAccountOption = '[data-testid="service-account-option"'; + this.selectedType = ".pf-c-select__toggle-text"; + } + + shouldDisplay() { + cy.get(this.sessionTypeDrpDwn).should("exist"); + } + + shouldNotBeEmpty() { + cy.get(this.sessionTypeDrpDwn).click(); + cy.get(this.sessionTypeList).should("exist"); + + return this; + } + + selectAllSessionsType() { + cy.get(this.sessionTypeDrpDwn).click(); + cy.get(this.allSessionTypesOption).click(); + cy.get(this.selectedType).should('have.text', 'All session types'); + } + + selectRegularSSO() { + cy.get(this.sessionTypeDrpDwn).click(); + cy.get(this.regularSSOOption).click(); + cy.get(this.selectedType).should('have.text', 'Regular SSO'); + } + + selectOffline() { + cy.get(this.sessionTypeDrpDwn).click(); + cy.get(this.offlineOption).click(); + cy.get(this.selectedType).should('have.text', 'Offline'); + } + + selectDirectGrant() { + cy.get(this.sessionTypeDrpDwn).click(); + cy.get(this.directGrantOption).click(); + cy.get(this.selectedType).should('have.text', 'Direct grant'); + } + + selectServiceAccount() { + cy.get(this.sessionTypeDrpDwn).click(); + cy.get(this.serviceAccountOption).click(); + cy.get(this.selectedType).should('have.text', 'Service account'); + } +} From b758a1f8b66148ad97b194647c4226fbaf5fc1ee Mon Sep 17 00:00:00 2001 From: Agnieszka Gancarczyk Date: Wed, 14 Jul 2021 11:41:04 +0100 Subject: [PATCH 2/2] sessions: added cypress tests review changes --- .../manage/sessions/SessionsPage.ts | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/cypress/support/pages/admin_console/manage/sessions/SessionsPage.ts b/cypress/support/pages/admin_console/manage/sessions/SessionsPage.ts index 3ce41339a1..cfb1c3fd56 100644 --- a/cypress/support/pages/admin_console/manage/sessions/SessionsPage.ts +++ b/cypress/support/pages/admin_console/manage/sessions/SessionsPage.ts @@ -11,11 +11,11 @@ export default class SessionsPage { constructor() { this.sessionTypeDrpDwn = ".pf-c-select__toggle"; this.sessionTypeList = ".pf-c-select__toggle + ul"; - this.allSessionTypesOption = '[data-testid="all-sessions-option"]'; - this.regularSSOOption = '[data-testid="regular-sso-option"'; - this.offlineOption = '[data-testid="offline-option"'; - this.directGrantOption = '[data-testid="direct-grant-option"'; - this.serviceAccountOption = '[data-testid="service-account-option"'; + this.allSessionTypesOption = "all-sessions-option"; + this.regularSSOOption = "regular-sso-option"; + this.offlineOption = "offline-option"; + this.directGrantOption = "direct-grant-option"; + this.serviceAccountOption = "service-account-option"; this.selectedType = ".pf-c-select__toggle-text"; } @@ -32,31 +32,31 @@ export default class SessionsPage { selectAllSessionsType() { cy.get(this.sessionTypeDrpDwn).click(); - cy.get(this.allSessionTypesOption).click(); + cy.getId(this.allSessionTypesOption).click(); cy.get(this.selectedType).should('have.text', 'All session types'); } selectRegularSSO() { cy.get(this.sessionTypeDrpDwn).click(); - cy.get(this.regularSSOOption).click(); + cy.getId(this.regularSSOOption).click(); cy.get(this.selectedType).should('have.text', 'Regular SSO'); } selectOffline() { cy.get(this.sessionTypeDrpDwn).click(); - cy.get(this.offlineOption).click(); + cy.getId(this.offlineOption).click(); cy.get(this.selectedType).should('have.text', 'Offline'); } selectDirectGrant() { cy.get(this.sessionTypeDrpDwn).click(); - cy.get(this.directGrantOption).click(); + cy.getId(this.directGrantOption).click(); cy.get(this.selectedType).should('have.text', 'Direct grant'); } selectServiceAccount() { cy.get(this.sessionTypeDrpDwn).click(); - cy.get(this.serviceAccountOption).click(); + cy.getId(this.serviceAccountOption).click(); cy.get(this.selectedType).should('have.text', 'Service account'); } }