2021-04-20 12:10:00 +00:00
|
|
|
const expect = chai.expect;
|
|
|
|
export default class RoleMappingTab {
|
2022-01-31 07:20:35 +00:00
|
|
|
private tab = "serviceAccountTab";
|
2021-04-20 12:10:00 +00:00
|
|
|
private scopeTab = "scopeTab";
|
2022-01-08 09:27:57 +00:00
|
|
|
private assignEmptyRoleBtn = "no-roles-for-this-client-empty-action";
|
|
|
|
private assignRoleBtn = "assignRole";
|
|
|
|
private unAssignBtn = "unAssignRole";
|
|
|
|
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';
|
|
|
|
|
|
|
|
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(
|
|
|
|
notEmpty ? this.assignEmptyRoleBtn : this.assignRoleBtn
|
|
|
|
).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;
|
|
|
|
}
|
|
|
|
|
|
|
|
hideInheritedRoles() {
|
2022-01-08 09:27:57 +00:00
|
|
|
cy.get(this.hideInheritedRolesBtn).check();
|
2021-05-06 05:31:40 +00:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2021-04-20 12:10:00 +00:00
|
|
|
selectRow(name: string) {
|
|
|
|
cy.get(this.namesColumn)
|
|
|
|
.contains(name)
|
|
|
|
.parent()
|
|
|
|
.within(() => {
|
|
|
|
cy.get("input").click();
|
|
|
|
});
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
checkRoles(roleNames: string[]) {
|
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];
|
|
|
|
expect(roles).to.contain(roleName);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} 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;
|
|
|
|
}
|
|
|
|
}
|