From a8ab21096b798e00cf763f1c2c915bad91a2c06a Mon Sep 17 00:00:00 2001 From: Dominik Kawka <31955648+dominikkawka@users.noreply.github.com> Date: Mon, 5 Sep 2022 22:30:25 +0100 Subject: [PATCH] Group permission tests (#3246) --- apps/admin-ui/cypress/e2e/group_test.spec.ts | 11 ++++++++++ .../groups/group_details/GroupDetailPage.ts | 20 ++++++++++++++++++- .../permission-tab/PermissionTab.tsx | 1 + 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/apps/admin-ui/cypress/e2e/group_test.spec.ts b/apps/admin-ui/cypress/e2e/group_test.spec.ts index aa50d3f0f6..4a92fbb35d 100644 --- a/apps/admin-ui/cypress/e2e/group_test.spec.ts +++ b/apps/admin-ui/cypress/e2e/group_test.spec.ts @@ -473,4 +473,15 @@ describe("Group test", () => { groupPage.assertGroupItemExist(predefinedGroups[0], true); }); }); + + describe("Permissions", () => { + beforeEach(() => { + groupPage.goToGroupChildGroupsTab(predefinedGroups[0]); + groupDetailPage.goToPermissionsTab(); + }); + + it("enable/disable permissions", () => { + groupDetailPage.enablePermissionSwitch(); + }); + }); }); diff --git a/apps/admin-ui/cypress/support/pages/admin_console/manage/groups/group_details/GroupDetailPage.ts b/apps/admin-ui/cypress/support/pages/admin_console/manage/groups/group_details/GroupDetailPage.ts index 6d7aeb5799..02a3a145d3 100644 --- a/apps/admin-ui/cypress/support/pages/admin_console/manage/groups/group_details/GroupDetailPage.ts +++ b/apps/admin-ui/cypress/support/pages/admin_console/manage/groups/group_details/GroupDetailPage.ts @@ -9,6 +9,7 @@ export default class GroupDetailPage extends GroupPage { private childGroupsTab = "groups"; private attributesTab = "attributes"; private roleMappingTab = "role-mapping-tab"; + private permissionsTab = "permissionsTab"; private memberNameColumn = '[data-testid="members-table"] > tbody > tr > [data-label="Name"]'; private addMembers = "addMember"; @@ -18,7 +19,7 @@ export default class GroupDetailPage extends GroupPage { private headerGroupName = ".pf-l-level.pf-m-gutter"; private renameGroupModalGroupNameInput = "groupNameInput"; private renameGroupModalRenameBtn = "renameGroup"; - + private permissionSwitch = "permissionSwitch"; public goToChildGroupsTab() { cy.findByTestId(this.childGroupsTab).click(); return this; @@ -39,6 +40,11 @@ export default class GroupDetailPage extends GroupPage { return this; } + public goToPermissionsTab() { + cy.findByTestId(this.permissionsTab).click(); + return this; + } + public headerActionRenameGroup() { super.openDropdownMenu("", cy.findByTestId(this.actionDrpDwnButton)); super.clickDropdownMenuItem( @@ -128,4 +134,16 @@ export default class GroupDetailPage extends GroupPage { cy.findByTestId(this.addMembers).click(); return this; } + + enablePermissionSwitch() { + cy.findByTestId(this.permissionSwitch).parent().click(); + this.assertSwitchStateOn(cy.findByTestId(this.permissionSwitch)); + cy.findByTestId(this.permissionSwitch).parent().click(); + modalUtils + .checkModalTitle("Disable permissions?") + .checkConfirmButtonText("Confirm") + .confirmModal(); + this.assertSwitchStateOff(cy.findByTestId(this.permissionSwitch)); + return this; + } } diff --git a/apps/admin-ui/src/components/permission-tab/PermissionTab.tsx b/apps/admin-ui/src/components/permission-tab/PermissionTab.tsx index e8f973e21c..a5df277def 100644 --- a/apps/admin-ui/src/components/permission-tab/PermissionTab.tsx +++ b/apps/admin-ui/src/components/permission-tab/PermissionTab.tsx @@ -146,6 +146,7 @@ export const PermissionsTab = ({ id, type }: PermissionsTabProps) => { >