From f789ee643f6e72a509b4a3b1907fedbc5aad2518 Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Thu, 21 Apr 2022 11:26:58 +0200 Subject: [PATCH] Re-enable permissions test and fixed sub tabs (#2477) --- .../client_authorization_test.spec.ts | 24 ++++++------- .../pages/admin_console/components/TabPage.ts | 35 ++++++++++++------- .../client_details/tabs/AuthorizationTab.ts | 14 ++++---- 3 files changed, 41 insertions(+), 32 deletions(-) diff --git a/cypress/integration/client_authorization_test.spec.ts b/cypress/integration/client_authorization_test.spec.ts index 28068d15cb..5a88486317 100644 --- a/cypress/integration/client_authorization_test.spec.ts +++ b/cypress/integration/client_authorization_test.spec.ts @@ -23,22 +23,22 @@ describe("Client authentication subtab", () => { "client-authentication-" + (Math.random() + 1).toString(36).substring(7); before(() => { - adminClient.createClient({ - protocol: "openid-connect", - clientId, - publicClient: false, - authorizationServicesEnabled: true, - serviceAccountsEnabled: true, - standardFlowEnabled: true, - }); - }); - - beforeEach(() => { keycloakBefore(); loginPage.logIn(); sidebarPage.goToClients(); listingPage.searchItem(clientId).goToItemDetails(clientId); clientDetailsPage.goToAuthorizationTab(); + + cy.wrap( + adminClient.createClient({ + protocol: "openid-connect", + clientId, + publicClient: false, + authorizationServicesEnabled: true, + serviceAccountsEnabled: true, + standardFlowEnabled: true, + }) + ); }); after(() => { @@ -142,7 +142,7 @@ describe("Client authentication subtab", () => { authenticationTab.formUtils().cancel(); }); - it.skip("Should create a permission", () => { + it("Should create a permission", () => { authenticationTab.goToPermissionsSubTab(); permissionsSubTab.createPermission("resource").fillPermissionForm({ diff --git a/cypress/support/pages/admin_console/components/TabPage.ts b/cypress/support/pages/admin_console/components/TabPage.ts index eac2aa04e1..f31f6ae195 100644 --- a/cypress/support/pages/admin_console/components/TabPage.ts +++ b/cypress/support/pages/admin_console/components/TabPage.ts @@ -5,31 +5,40 @@ export default class TabPage extends CommonElements { constructor() { super(".pf-c-tabs"); - this.tabItemSelector = this.parentSelector + ".pf-c-tabs__item"; + this.tabItemSelector = ".pf-c-tabs__item"; } - clickTab(tabName: string) { - cy.get(this.tabItemSelector).contains(tabName).click(); - this.checkIsCurrentTab(tabName); + private getTab(tabName: string, index: number | undefined = 0) { + return cy + .get(this.parentSelector) + .eq(index) + .find(this.tabItemSelector) + .contains(tabName); + } + + clickTab(tabName: string, index: number | undefined = 0) { + this.getTab(tabName, index).click(); + this.checkIsCurrentTab(tabName, index); return this; } - checkIsCurrentTab(tabName: string) { - cy.get(this.tabItemSelector) - .contains(tabName) - .parent() - .should("have.class", "pf-m-current"); + checkIsCurrentTab(tabName: string, index: number | undefined = 0) { + this.getTab(tabName, index).parent().should("have.class", "pf-m-current"); return this; } - checkTabExists(tabName: string, exists: boolean) { + checkTabExists( + tabName: string, + exists: boolean, + index: number | undefined = 0 + ) { const condition = exists ? "exist" : "not.exist"; - cy.get(this.tabItemSelector).contains(tabName).should(condition); + this.getTab(tabName, index).should(condition); return this; } - checkNumberOfTabsIsEqual(number: number) { - cy.get(this.tabItemSelector).should("have.length", number); + checkNumberOfTabsIsEqual(number: number, index: number | undefined = 0) { + cy.get(this.parentSelector).eq(index).should("have.length", number); return this; } } diff --git a/cypress/support/pages/admin_console/manage/clients/client_details/tabs/AuthorizationTab.ts b/cypress/support/pages/admin_console/manage/clients/client_details/tabs/AuthorizationTab.ts index 1c5d81b8fa..77e13ce011 100644 --- a/cypress/support/pages/admin_console/manage/clients/client_details/tabs/AuthorizationTab.ts +++ b/cypress/support/pages/admin_console/manage/clients/client_details/tabs/AuthorizationTab.ts @@ -27,37 +27,37 @@ export default class AuthorizationTab extends CommonPage { private exportSubTab = new ExportTab(); goToSettingsSubTab() { - this.tabUtils().clickTab(AuthorizationSubTab.Settings); + this.tabUtils().clickTab(AuthorizationSubTab.Settings, 1); return this.settingsSubTab; } goToResourcesSubTab() { - this.tabUtils().clickTab(AuthorizationSubTab.Resources); + this.tabUtils().clickTab(AuthorizationSubTab.Resources, 1); return this.resourcesSubTab; } goToScopesSubTab() { - this.tabUtils().clickTab(AuthorizationSubTab.Scopes); + this.tabUtils().clickTab(AuthorizationSubTab.Scopes, 1); return this.scopesSubTab; } goToPoliciesSubTab() { - this.tabUtils().clickTab(AuthorizationSubTab.Policies); + this.tabUtils().clickTab(AuthorizationSubTab.Policies, 1); return this.policiesSubTab; } goToPermissionsSubTab() { - this.tabUtils().clickTab(AuthorizationSubTab.Permissions); + this.tabUtils().clickTab(AuthorizationSubTab.Permissions, 1); return this.permissionsSubTab; } goToEvaluateSubTab() { - this.tabUtils().clickTab(AuthorizationSubTab.Evaluate); + this.tabUtils().clickTab(AuthorizationSubTab.Evaluate, 1); return this.evaluateSubTab; } goToExportSubTab() { - this.tabUtils().clickTab(AuthorizationSubTab.Export); + this.tabUtils().clickTab(AuthorizationSubTab.Export, 1); return this.exportSubTab; } }