Realm roles tests (admin-ui) (#25376)

* added missing tests for realm roles

Signed-off-by: Agnieszka Gancarczyk <agancarc@redhat.com>

* added more tests for realm roles

Signed-off-by: Agnieszka Gancarczyk <agancarc@redhat.com>

---------

Signed-off-by: Agnieszka Gancarczyk <agancarc@redhat.com>
Co-authored-by: Agnieszka Gancarczyk <agancarc@redhat.com>
This commit is contained in:
agagancarczyk 2023-12-07 14:34:31 +00:00 committed by GitHub
parent df465456b8
commit 72e57ca298
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 50 additions and 2 deletions

View file

@ -127,8 +127,25 @@ describe("Realm roles test", () => {
masthead.checkNotificationMessage("Associated roles have been added", true);
});
it("Should search existing associated role by name", () => {
listingPage.searchItem("create-realm", false).itemExist("create-realm");
it("should search existing associated role by name and go to it", () => {
listingPage
.searchItem("create-realm", false)
.itemExist("create-realm")
.goToItemDetails("create-realm");
cy.findByTestId("view-header").should("contain.text", "create-realm");
cy.findByTestId("cancel").click();
});
it("should go to default-roles-master link role name and check assign roles table is not empty", () => {
listingPage.goToItemDetails("default-roles-master");
rolesTab.goToDefaultGroupsTab();
cy.findByTestId("assigned-roles").find("tr").should("have.length.gt", 0);
cy.findByTestId("empty-state").contains("No default groups");
rolesTab.goToDefaultRolesTab();
cy.findByTestId("assigned-roles").find("tr").should("have.length.gt", 0);
});
it("Should search non-existent associated role by name", () => {
@ -283,11 +300,20 @@ describe("Realm roles test", () => {
});
const role = "a11y-role";
const defaultRolesMaster = "default-roles-master";
it("Check a11y violations on load/ realm roles", () => {
cy.checkA11y();
});
it("Check a11y violations on default-roles-master default tab and default roles tabs", () => {
listingPage.goToItemDetails(defaultRolesMaster);
cy.checkA11y();
rolesTab.goToDefaultGroupsTab();
cy.checkA11y();
});
it("Check a11y violations on empty create role form", () => {
rolesTab.goToCreateRoleFromToolbar();
cy.checkA11y();

View file

@ -1,4 +1,5 @@
import ListingPage from "../support/pages/admin-ui/ListingPage";
import ClientRolesTab from "../support/pages/admin-ui/manage/clients/ClientRolesTab";
import UserRegistration, {
GroupPickerDialog,
} from "../support/pages/admin-ui/manage/realm_settings/UserRegistration";
@ -18,6 +19,7 @@ describe("Realm settings - User registration tab", () => {
const listingPage = new ListingPage();
const groupPicker = new GroupPickerDialog();
const userRegistration = new UserRegistration();
const rolesTab = new ClientRolesTab();
const groupName = "The default group";
@ -39,6 +41,11 @@ describe("Realm settings - User registration tab", () => {
userRegistration.selectRow(role).assign();
masthead.checkNotificationMessage("Associated roles have been added");
listingPage.searchItem(role, false).itemExist(role);
sidebarPage.goToRealmRoles();
listingPage.goToItemDetails("admin");
rolesTab.goToUsersInRoleTab();
cy.findByTestId("users-in-role-table").contains("admin");
});
it("Remove admin role", () => {

View file

@ -13,6 +13,8 @@ export default class ClientRolesTab extends CommonPage {
#hideInheritedRolesChkBox = "#hideInheritedRoles";
#rolesTab = "rolesTab";
#associatedRolesTab = "associatedRolesTab";
#defaultRolesTab = "default-roles-tab";
#defaultGroupsTab = "default-groups-tab";
goToDetailsTab() {
this.tabUtils().clickTab(ClientRolesTabItems.Details);
@ -63,4 +65,14 @@ export default class ClientRolesTab extends CommonPage {
cy.get(this.#hideInheritedRolesChkBox).check();
return this;
}
goToDefaultRolesTab() {
cy.findByTestId(this.#defaultRolesTab).click();
return this;
}
goToDefaultGroupsTab() {
cy.findByTestId(this.#defaultGroupsTab).click();
return this;
}
}

View file

@ -50,6 +50,7 @@ export const UsersInRoleTab = () => {
loader={loader}
ariaLabelKey="roleList"
searchPlaceholderKey=""
data-testid="users-in-role-table"
toolbarItem={
enabled && (
<Popover

View file

@ -56,6 +56,7 @@ export const UserRegistration = () => {
id="roles"
eventKey={10}
title={<TabTitleText>{t("defaultRoles")}</TabTitleText>}
data-testid="default-roles-tab"
>
<RoleMapping
name={realm.defaultRole!.name!}
@ -69,6 +70,7 @@ export const UserRegistration = () => {
id="groups"
eventKey={20}
title={<TabTitleText>{t("defaultGroups")}</TabTitleText>}
data-testid="default-groups-tab"
>
<DefaultsGroupsTab />
</Tab>