keycloak-scim/cypress/support/pages/admin_console/manage/RoleMappingTab.ts

77 lines
1.8 KiB
TypeScript
Raw Normal View History

const expect = chai.expect;
export default class RoleMappingTab {
2022-04-05 15:02:27 +00:00
private type = "client";
private tab = "serviceAccountTab";
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";
private assignBtn = "assign";
private hideInheritedRolesBtn = "#hideInheritedRoles";
private assignedRolesTable = "assigned-roles";
private namesColumn = 'td[data-label="Name"]:visible';
2022-04-05 15:02:27 +00:00
constructor(type: string) {
this.type = type;
}
goToServiceAccountTab() {
cy.findByTestId(this.tab).click();
return this;
}
goToScopeTab() {
cy.findByTestId(this.scopeTab).click();
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();
return this;
}
2022-01-08 09:27:57 +00:00
assign() {
cy.findByTestId(this.assignBtn).click();
return this;
}
2022-01-08 09:27:57 +00:00
unAssign() {
cy.findByTestId(this.unAssignBtn).click();
return this;
}
hideInheritedRoles() {
2022-01-08 09:27:57 +00:00
cy.get(this.hideInheritedRolesBtn).check();
return this;
}
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) {
cy.findByTestId(this.assignedRolesTable)
.get(this.namesColumn)
.should((roles) => {
for (let index = 0; index < roleNames.length; index++) {
const roleName = roleNames[index];
expect(roles).to.contain(roleName);
}
});
} else {
cy.findByTestId(this.assignedRolesTable).should("not.exist");
}
return this;
}
}