fixed realm role test (#962)

This commit is contained in:
Erik Jan de Wit 2021-08-09 16:31:03 +02:00 committed by GitHub
parent 55c0e5766f
commit 9eedd13a6b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 35 deletions

View file

@ -1,43 +1,30 @@
export default class AssociatedRolesPage { export default class AssociatedRolesPage {
actionDropdown: string; private actionDropdown = "action-dropdown";
addRolesDropdownItem: string; private addRolesDropdownItem = "add-roles";
addRoleToolbarButton: string; private addRoleToolbarButton = "add-role-button";
checkbox: string; private checkbox = "[type=checkbox]";
addAssociatedRolesModalButton: string; private addAssociatedRolesModalButton = "add-associated-roles-button";
compositeRoleBadge: string; private compositeRoleBadge = "composite-role-badge";
filterTypeDropdown: string; private filterTypeDropdown = "filter-type-dropdown";
filterTypeDropdownItem: string; private filterTypeDropdownItem = "filter-type-dropdown-item";
usersPage: string; private usersPage = "users-page";
constructor() {
this.actionDropdown = "[data-testid=action-dropdown]";
this.addRolesDropdownItem = "[data-testid=add-roles]";
this.addRoleToolbarButton = "[data-testid=add-role-button]";
this.checkbox = "[type=checkbox]";
this.addAssociatedRolesModalButton =
"[data-testid=add-associated-roles-button]";
this.compositeRoleBadge = "[data-testid=composite-role-badge]";
this.filterTypeDropdown = "[data-testid=filter-type-dropdown]";
this.filterTypeDropdownItem = "[data-testid=filter-type-dropdown-item]";
this.usersPage = "[data-testid=users-page]";
}
addAssociatedRealmRole() { addAssociatedRealmRole() {
cy.get(this.actionDropdown).last().click(); cy.getId(this.actionDropdown).last().click();
const load = "/auth/admin/realms/master/clients"; const load = "/auth/admin/realms/master/clients";
cy.intercept(load).as("load"); cy.intercept(load).as("load");
cy.get(this.addRolesDropdownItem).click(); cy.getId(this.addRolesDropdownItem).click();
cy.wait(["@load"]); cy.wait(["@load"]);
cy.get(this.checkbox).eq(2).check(); cy.get(this.checkbox).eq(2).check();
cy.get(this.addAssociatedRolesModalButton).contains("Add").click(); cy.getId(this.addAssociatedRolesModalButton).contains("Add").click();
cy.url().should("include", "/AssociatedRoles"); cy.url().should("include", "/AssociatedRoles");
cy.get(this.compositeRoleBadge).should("contain.text", "Composite"); cy.getId(this.compositeRoleBadge).should("contain.text", "Composite");
cy.wait(["@load"]); cy.wait(["@load"]);
@ -45,20 +32,23 @@ export default class AssociatedRolesPage {
} }
addAssociatedClientRole() { addAssociatedClientRole() {
cy.get(this.addRoleToolbarButton).click(); cy.getId(this.addRoleToolbarButton).click();
cy.get(this.filterTypeDropdown).click(); cy.getId(this.filterTypeDropdown).click();
cy.get(this.filterTypeDropdownItem).click(); cy.getId(this.filterTypeDropdownItem).click();
cy.get(".pf-c-spinner__tail-ball").should("not.exist"); cy.getId(".pf-c-spinner__tail-ball").should("not.exist");
cy.get(this.checkbox).eq(12).check({ force: true }); cy.get('[data-testid="addAssociatedRole"] td[data-label="Role name"]')
.contains("manage-account")
.parent()
.within(() => {
cy.get("input").click();
});
cy.get(this.addAssociatedRolesModalButton).contains("Add").click(); cy.getId(this.addAssociatedRolesModalButton).contains("Add").click();
cy.get(".pf-c-spinner__tail-ball").should("not.exist"); cy.contains("Users in role").click().getId(this.usersPage).should("exist");
cy.contains("Users in role").click().get(this.usersPage).should("exist");
} }
} }

View file

@ -157,6 +157,7 @@ export const AssociatedRolesModal = (props: AssociatedRolesModalProps) => {
return ( return (
<Modal <Modal
data-testid="addAssociatedRole"
title={t("roles:associatedRolesModalTitle", { name })} title={t("roles:associatedRolesModalTitle", { name })}
isOpen={props.open} isOpen={props.open}
onClose={props.toggleDialog} onClose={props.toggleDialog}

View file

@ -316,6 +316,7 @@ export const RealmRoleTabs = () => {
titleKey={role?.name || t("createRole")} titleKey={role?.name || t("createRole")}
badges={[ badges={[
{ {
id: "composite-role-badge",
text: additionalRoles.length > 0 ? t("composite") : "", text: additionalRoles.length > 0 ? t("composite") : "",
readonly: true, readonly: true,
}, },