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); masthead.checkNotificationMessage("Associated roles have been added", true);
}); });
it("Should search existing associated role by name", () => { it("should search existing associated role by name and go to it", () => {
listingPage.searchItem("create-realm", false).itemExist("create-realm"); 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", () => { it("Should search non-existent associated role by name", () => {
@ -283,11 +300,20 @@ describe("Realm roles test", () => {
}); });
const role = "a11y-role"; const role = "a11y-role";
const defaultRolesMaster = "default-roles-master";
it("Check a11y violations on load/ realm roles", () => { it("Check a11y violations on load/ realm roles", () => {
cy.checkA11y(); 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", () => { it("Check a11y violations on empty create role form", () => {
rolesTab.goToCreateRoleFromToolbar(); rolesTab.goToCreateRoleFromToolbar();
cy.checkA11y(); cy.checkA11y();

View file

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

View file

@ -13,6 +13,8 @@ export default class ClientRolesTab extends CommonPage {
#hideInheritedRolesChkBox = "#hideInheritedRoles"; #hideInheritedRolesChkBox = "#hideInheritedRoles";
#rolesTab = "rolesTab"; #rolesTab = "rolesTab";
#associatedRolesTab = "associatedRolesTab"; #associatedRolesTab = "associatedRolesTab";
#defaultRolesTab = "default-roles-tab";
#defaultGroupsTab = "default-groups-tab";
goToDetailsTab() { goToDetailsTab() {
this.tabUtils().clickTab(ClientRolesTabItems.Details); this.tabUtils().clickTab(ClientRolesTabItems.Details);
@ -63,4 +65,14 @@ export default class ClientRolesTab extends CommonPage {
cy.get(this.#hideInheritedRolesChkBox).check(); cy.get(this.#hideInheritedRolesChkBox).check();
return this; 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} loader={loader}
ariaLabelKey="roleList" ariaLabelKey="roleList"
searchPlaceholderKey="" searchPlaceholderKey=""
data-testid="users-in-role-table"
toolbarItem={ toolbarItem={
enabled && ( enabled && (
<Popover <Popover

View file

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