2021-04-20 12:10:00 +00:00
|
|
|
const expect = chai.expect;
|
|
|
|
export default class RoleMappingTab {
|
2022-04-05 15:02:27 +00:00
|
|
|
private type = "client";
|
2022-01-31 07:20:35 +00:00
|
|
|
private tab = "serviceAccountTab";
|
2021-04-20 12:10:00 +00:00
|
|
|
private scopeTab = "scopeTab";
|
2022-04-05 15:02:27 +00:00
|
|
|
private assignEmptyRoleBtn = (type: string) =>
|
|
|
|
`no-roles-for-this-${type}-empty-action`;
|
2022-01-08 09:27:57 +00:00
|
|
|
private assignRoleBtn = "assignRole";
|
|
|
|
private unAssignBtn = "unAssignRole";
|
2022-05-12 13:45:50 +00:00
|
|
|
private unAssignDrpDwnBtn = '.pf-c-table__action li[role="menuitem"] button';
|
2022-01-08 09:27:57 +00:00
|
|
|
private assignBtn = "assign";
|
|
|
|
private hideInheritedRolesBtn = "#hideInheritedRoles";
|
2021-04-20 12:10:00 +00:00
|
|
|
private assignedRolesTable = "assigned-roles";
|
|
|
|
private namesColumn = 'td[data-label="Name"]:visible';
|
2022-05-12 13:45:50 +00:00
|
|
|
private actionBtn = 'button[aria-label="Actions"]';
|
2021-04-20 12:10:00 +00:00
|
|
|
|
2022-04-05 15:02:27 +00:00
|
|
|
constructor(type: string) {
|
|
|
|
this.type = type;
|
|
|
|
}
|
|
|
|
|
2021-04-20 12:10:00 +00:00
|
|
|
goToServiceAccountTab() {
|
2022-01-31 07:20:35 +00:00
|
|
|
cy.findByTestId(this.tab).click();
|
2021-04-20 12:10:00 +00:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
goToScopeTab() {
|
2021-09-17 13:23:34 +00:00
|
|
|
cy.findByTestId(this.scopeTab).click();
|
2021-04-20 12:10:00 +00:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2022-01-08 09:27:57 +00:00
|
|
|
assignRole(notEmpty = true) {
|
|
|
|
cy.findByTestId(
|
2022-04-05 15:02:27 +00:00
|
|
|
notEmpty ? this.assignEmptyRoleBtn(this.type) : this.assignRoleBtn
|
2022-01-08 09:27:57 +00:00
|
|
|
).click();
|
2021-04-20 12:10:00 +00:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2022-01-08 09:27:57 +00:00
|
|
|
assign() {
|
|
|
|
cy.findByTestId(this.assignBtn).click();
|
2021-04-20 12:10:00 +00:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2022-01-08 09:27:57 +00:00
|
|
|
unAssign() {
|
|
|
|
cy.findByTestId(this.unAssignBtn).click();
|
2021-05-06 05:31:40 +00:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2022-05-12 13:45:50 +00:00
|
|
|
unAssignFromDropdown() {
|
|
|
|
cy.get(this.unAssignDrpDwnBtn).click();
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2021-05-06 05:31:40 +00:00
|
|
|
hideInheritedRoles() {
|
2022-01-08 09:27:57 +00:00
|
|
|
cy.get(this.hideInheritedRolesBtn).check();
|
2021-05-06 05:31:40 +00:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2022-05-12 13:45:50 +00:00
|
|
|
unhideInheritedRoles() {
|
|
|
|
cy.get(this.hideInheritedRolesBtn).uncheck();
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
selectRow(name: string, modal = false) {
|
|
|
|
cy.get(modal ? ".pf-c-modal-box " : "" + this.namesColumn)
|
2021-04-20 12:10:00 +00:00
|
|
|
.contains(name)
|
|
|
|
.parent()
|
|
|
|
.within(() => {
|
|
|
|
cy.get("input").click();
|
|
|
|
});
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2022-05-12 13:45:50 +00:00
|
|
|
checkRoles(roleNames: string[], exist = true) {
|
2021-09-16 10:24:21 +00:00
|
|
|
if (roleNames.length) {
|
2021-09-17 13:23:34 +00:00
|
|
|
cy.findByTestId(this.assignedRolesTable)
|
2021-05-06 05:31:40 +00:00
|
|
|
.get(this.namesColumn)
|
|
|
|
.should((roles) => {
|
|
|
|
for (let index = 0; index < roleNames.length; index++) {
|
|
|
|
const roleName = roleNames[index];
|
2022-05-12 13:45:50 +00:00
|
|
|
|
|
|
|
if (exist) {
|
|
|
|
expect(roles).to.contain(roleName);
|
|
|
|
} else {
|
|
|
|
expect(roles).not.to.contain(roleName);
|
|
|
|
}
|
2021-05-06 05:31:40 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
2021-09-17 13:23:34 +00:00
|
|
|
cy.findByTestId(this.assignedRolesTable).should("not.exist");
|
2021-05-06 05:31:40 +00:00
|
|
|
}
|
2021-04-20 12:10:00 +00:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
}
|