Group role mapping tests (#3314)

This commit is contained in:
Dominik Kawka 2022-09-14 11:44:30 +01:00 committed by GitHub
parent 71c79b31ed
commit c6aea1cd44
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 75 additions and 0 deletions

View file

@ -10,6 +10,8 @@ import ChildGroupsTab from "../support/pages/admin_console/manage/groups/group_d
import MembersTab from "../support/pages/admin_console/manage/groups/group_details/tabs/MembersTab";
import adminClient from "../support/util/AdminClient";
import { range } from "lodash-es";
import RoleMappingTab from "../support/pages/admin_console/manage/RoleMappingTab";
import CommonPage from "../support/pages/CommonPage";
describe("Group test", () => {
const loginPage = new LoginPage();
@ -21,6 +23,7 @@ describe("Group test", () => {
const groupDetailPage = new GroupDetailPage();
const childGroupsTab = new ChildGroupsTab();
const membersTab = new MembersTab();
const commonPage = new CommonPage();
const groupNamePrefix = "group_";
let groupName: string;
@ -474,6 +477,39 @@ describe("Group test", () => {
});
});
describe("Role mappings", () => {
const roleMappingTab = new RoleMappingTab("group");
beforeEach(() => {
groupPage.goToGroupChildGroupsTab(predefinedGroups[0]);
groupDetailPage.goToRoleMappingTab();
});
it("Check empty state", () => {
commonPage.emptyState().checkIfExists(true);
});
it("Assign roles from empty state", () => {
roleMappingTab.assignRole();
groupDetailPage.createRoleMappingSearch();
roleMappingTab.assign();
});
it("Show and search roles", () => {
groupDetailPage.checkRoles();
});
it("Check hide inherited roles option", () => {
roleMappingTab.unhideInheritedRoles();
roleMappingTab.hideInheritedRoles();
});
it("Remove roles", () => {
roleMappingTab.selectRow("offline_access");
roleMappingTab.unAssign();
groupDetailPage.deleteRole();
});
});
describe("Permissions", () => {
beforeEach(() => {
groupPage.goToGroupChildGroupsTab(predefinedGroups[0]);

View file

@ -64,6 +64,9 @@ export default class ListingPage extends CommonElements {
private tableHeaderCheckboxItemAllRows =
"input[aria-label='Select all rows']";
private searchBtnInModal =
".pf-c-modal-box .pf-c-toolbar__content-section button.pf-m-control:visible";
showPreviousPageTableItems() {
cy.get(this.previousPageBtn).first().click();
@ -110,6 +113,14 @@ export default class ListingPage extends CommonElements {
return this;
}
searchItemInModal(searchValue: string) {
cy.get(this.searchInput).clear();
if (searchValue) {
cy.get(this.searchInput).type(searchValue);
}
cy.get(this.searchBtnInModal).click({ force: true });
}
checkTableLength(length: number, identifier: string) {
cy.get("table")
.should("have.class", identifier)

View file

@ -1,7 +1,10 @@
import ModalUtils from "../../../../../util/ModalUtils";
import ListingPage from "../../../ListingPage";
import GroupPage from "../GroupPage";
const modalUtils = new ModalUtils();
const listingPage = new ListingPage();
const groupPage = new GroupPage();
export default class GroupDetailPage extends GroupPage {
private groupNamesColumn = '[data-label="Group name"] > a';
@ -146,4 +149,28 @@ export default class GroupDetailPage extends GroupPage {
this.assertSwitchStateOff(cy.findByTestId(this.permissionSwitch));
return this;
}
createRoleMapping() {
listingPage.clickItemCheckbox("default-roles-");
}
createRoleMappingSearch() {
listingPage.searchItemInModal("offline_access");
listingPage.clickItemCheckbox("offline_access");
}
checkRoles() {
listingPage.itemExist("offline_access");
listingPage.searchItem("offline_access", false);
listingPage.itemExist("offline_access");
listingPage.searchItem("non-existant-role", false);
groupPage.assertNoSearchResultsMessageExist(true);
}
deleteRole() {
modalUtils
.checkModalTitle("Remove mapping?")
.checkConfirmButtonText("Remove")
.confirmModal();
}
}

View file

@ -210,6 +210,7 @@ export const RoleMapping = ({
<Checkbox
label={t("common:hideInheritedRoles")}
id="hideInheritedRoles"
data-testid="hideInheritedRoles"
isChecked={hide}
onChange={(check) => {
setHide(check);