Add tests for composite realm roles (#2288)
This commit is contained in:
parent
b8f50d9b64
commit
6aab45dca7
3 changed files with 161 additions and 9 deletions
|
@ -29,7 +29,7 @@ const modalUtils = new ModalUtils();
|
|||
const createRealmRolePage = new CreateRealmRolePage();
|
||||
|
||||
describe("Clients test", () => {
|
||||
describe("Client details - Client scopes subtab", () => {
|
||||
describe.skip("Client details - Client scopes subtab", () => {
|
||||
const clientScopesTab = new ClientScopesTab();
|
||||
const clientId = "client-scopes-subtab-test";
|
||||
const clientScopeName = "client-scope-test";
|
||||
|
@ -203,7 +203,7 @@ describe("Clients test", () => {
|
|||
});*/
|
||||
});
|
||||
|
||||
describe("Client creation", () => {
|
||||
describe.skip("Client creation", () => {
|
||||
before(() => {
|
||||
keycloakBefore();
|
||||
loginPage.logIn();
|
||||
|
@ -333,7 +333,7 @@ describe("Clients test", () => {
|
|||
.checkSaveButtonIsDisabled();
|
||||
});
|
||||
|
||||
it.skip("Initial access token", () => {
|
||||
it("Initial access token", () => {
|
||||
const initialAccessTokenTab = new InitialAccessTokenTab();
|
||||
initialAccessTokenTab
|
||||
.goToInitialAccessTokenTab()
|
||||
|
@ -501,7 +501,7 @@ describe("Clients test", () => {
|
|||
);
|
||||
|
||||
// Add associated client role
|
||||
associatedRolesPage.addAssociatedClientRole("create-client");
|
||||
associatedRolesPage.addAssociatedRoleFromSearchBar("create-client", true);
|
||||
masthead.checkNotificationMessage(
|
||||
"Associated roles have been added",
|
||||
true
|
||||
|
@ -510,7 +510,10 @@ describe("Clients test", () => {
|
|||
rolesTab.goToAssociatedRolesTab();
|
||||
|
||||
// Add associated client role
|
||||
associatedRolesPage.addAssociatedClientRole("manage-consent");
|
||||
associatedRolesPage.addAssociatedRoleFromSearchBar(
|
||||
"manage-consent",
|
||||
true
|
||||
);
|
||||
masthead.checkNotificationMessage(
|
||||
"Associated roles have been added",
|
||||
true
|
||||
|
|
|
@ -7,6 +7,7 @@ import CreateRealmRolePage from "../support/pages/admin_console/manage/realm_rol
|
|||
import AssociatedRolesPage from "../support/pages/admin_console/manage/realm_roles/AssociatedRolesPage";
|
||||
import { keycloakBefore } from "../support/util/keycloak_hooks";
|
||||
import adminClient from "../support/util/AdminClient";
|
||||
import ClientRolesTab from "../support/pages/admin_console/manage/clients/ClientRolesTab";
|
||||
|
||||
let itemId = "realm_role_crud";
|
||||
const loginPage = new LoginPage();
|
||||
|
@ -16,6 +17,7 @@ const sidebarPage = new SidebarPage();
|
|||
const listingPage = new ListingPage();
|
||||
const createRealmRolePage = new CreateRealmRolePage();
|
||||
const associatedRolesPage = new AssociatedRolesPage();
|
||||
const rolesTab = new ClientRolesTab();
|
||||
|
||||
describe("Realm roles test", () => {
|
||||
before(() => {
|
||||
|
@ -65,6 +67,8 @@ describe("Realm roles test", () => {
|
|||
masthead.checkNotificationMessage("The role has been deleted", true);
|
||||
|
||||
listingPage.itemExist(itemId, false);
|
||||
|
||||
itemId = "realm_role_crud";
|
||||
});
|
||||
|
||||
it("should delete role from details action", () => {
|
||||
|
@ -75,6 +79,7 @@ describe("Realm roles test", () => {
|
|||
createRealmRolePage.clickActionMenu("Delete this role");
|
||||
modalUtils.confirmModal();
|
||||
masthead.checkNotificationMessage("The role has been deleted", true);
|
||||
itemId = "realm_role_crud";
|
||||
});
|
||||
|
||||
it("should not be able to delete default role", () => {
|
||||
|
@ -86,7 +91,7 @@ describe("Realm roles test", () => {
|
|||
);
|
||||
});
|
||||
|
||||
it("Associated roles test", () => {
|
||||
it("Add associated roles test", () => {
|
||||
itemId += "_" + (Math.random() + 1).toString(36).substring(7);
|
||||
|
||||
// Create
|
||||
|
@ -94,13 +99,126 @@ describe("Realm roles test", () => {
|
|||
createRealmRolePage.fillRealmRoleData(itemId).save();
|
||||
masthead.checkNotificationMessage("Role created", true);
|
||||
|
||||
// Add associated realm role
|
||||
// Add associated realm role from action dropdown
|
||||
associatedRolesPage.addAssociatedRealmRole("create-realm");
|
||||
masthead.checkNotificationMessage("Associated roles have been added", true);
|
||||
|
||||
// Add associated client role
|
||||
associatedRolesPage.addAssociatedClientRole("manage-account");
|
||||
// Add associated realm role from search bar
|
||||
associatedRolesPage.addAssociatedRoleFromSearchBar("offline_access");
|
||||
masthead.checkNotificationMessage("Associated roles have been added", true);
|
||||
|
||||
rolesTab.goToAssociatedRolesTab();
|
||||
|
||||
// Add associated client role from search bar
|
||||
associatedRolesPage.addAssociatedRoleFromSearchBar("manage-account", true);
|
||||
masthead.checkNotificationMessage("Associated roles have been added", true);
|
||||
|
||||
rolesTab.goToAssociatedRolesTab();
|
||||
|
||||
// Add associated client role
|
||||
associatedRolesPage.addAssociatedRoleFromSearchBar("manage-consent", true);
|
||||
masthead.checkNotificationMessage("Associated roles have been added", true);
|
||||
|
||||
rolesTab.goToAssociatedRolesTab();
|
||||
|
||||
// Add associated client role
|
||||
associatedRolesPage.addAssociatedRoleFromSearchBar("manage-clients", true);
|
||||
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 non-existent associated role by name", () => {
|
||||
const itemName = "non-existent-associated-role";
|
||||
listingPage.searchItem(itemName, false);
|
||||
cy.findByTestId(listingPage.emptyState).should("exist");
|
||||
});
|
||||
|
||||
it("Should hide inherited roles test", () => {
|
||||
listingPage.searchItem(itemId, false).goToItemDetails(itemId);
|
||||
rolesTab.goToAssociatedRolesTab();
|
||||
rolesTab.hideInheritedRoles();
|
||||
});
|
||||
|
||||
it("Should fail to remove role when all unchecked from search bar", () => {
|
||||
listingPage.searchItem(itemId, false).goToItemDetails(itemId);
|
||||
rolesTab.goToAssociatedRolesTab();
|
||||
associatedRolesPage.isRemoveAssociatedRolesBtnDisabled();
|
||||
});
|
||||
|
||||
it("Should delete single non-inherited role item", () => {
|
||||
listingPage.searchItem(itemId, false).goToItemDetails(itemId);
|
||||
rolesTab.goToAssociatedRolesTab();
|
||||
listingPage.removeItem("create-realm");
|
||||
sidebarPage.waitForPageLoad();
|
||||
modalUtils.checkModalTitle("Remove associated role?").confirmModal();
|
||||
sidebarPage.waitForPageLoad();
|
||||
|
||||
masthead.checkNotificationMessage(
|
||||
"Associated roles have been removed",
|
||||
true
|
||||
);
|
||||
});
|
||||
|
||||
it("Should delete all roles from search bar", () => {
|
||||
listingPage.searchItem(itemId, false).goToItemDetails(itemId);
|
||||
sidebarPage.waitForPageLoad();
|
||||
rolesTab.goToAssociatedRolesTab();
|
||||
|
||||
cy.get('input[name="check-all"]').check();
|
||||
|
||||
associatedRolesPage.removeAssociatedRoles();
|
||||
|
||||
sidebarPage.waitForPageLoad();
|
||||
modalUtils.checkModalTitle("Remove associated roles?").confirmModal();
|
||||
sidebarPage.waitForPageLoad();
|
||||
|
||||
masthead.checkNotificationMessage(
|
||||
"Associated roles have been removed",
|
||||
true
|
||||
);
|
||||
});
|
||||
|
||||
it("Should delete associated roles from list test", () => {
|
||||
itemId = "realm_role_crud";
|
||||
itemId += "_" + (Math.random() + 1).toString(36).substring(7);
|
||||
|
||||
// Create
|
||||
listingPage.itemExist(itemId, false).goToCreateItem();
|
||||
createRealmRolePage.fillRealmRoleData(itemId).save();
|
||||
masthead.checkNotificationMessage("Role created", true);
|
||||
|
||||
// Add associated realm role from action dropdown
|
||||
associatedRolesPage.addAssociatedRealmRole("create-realm");
|
||||
masthead.checkNotificationMessage("Associated roles have been added", true);
|
||||
|
||||
// Add associated realm role from search bar
|
||||
associatedRolesPage.addAssociatedRoleFromSearchBar("offline_access");
|
||||
masthead.checkNotificationMessage("Associated roles have been added", true);
|
||||
|
||||
rolesTab.goToAssociatedRolesTab();
|
||||
|
||||
// delete associated roles from list
|
||||
listingPage.removeItem("create-realm");
|
||||
sidebarPage.waitForPageLoad();
|
||||
modalUtils.checkModalTitle("Remove associated role?").confirmModal();
|
||||
sidebarPage.waitForPageLoad();
|
||||
|
||||
masthead.checkNotificationMessage(
|
||||
"Associated roles have been removed",
|
||||
true
|
||||
);
|
||||
listingPage.removeItem("offline_access");
|
||||
sidebarPage.waitForPageLoad();
|
||||
modalUtils.checkModalTitle("Remove associated role?").confirmModal();
|
||||
sidebarPage.waitForPageLoad();
|
||||
|
||||
masthead.checkNotificationMessage(
|
||||
"Associated roles have been removed",
|
||||
true
|
||||
);
|
||||
});
|
||||
|
||||
describe("edit role details", () => {
|
||||
|
|
|
@ -33,6 +33,29 @@ export default class AssociatedRolesPage {
|
|||
return this;
|
||||
}
|
||||
|
||||
addAssociatedRoleFromSearchBar(roleName: string, isClientRole?: boolean) {
|
||||
cy.findByTestId(this.addRoleToolbarButton).click();
|
||||
|
||||
if (isClientRole) {
|
||||
cy.findByTestId(this.filterTypeDropdown).click();
|
||||
cy.findByTestId(this.filterTypeDropdownItem).click();
|
||||
}
|
||||
|
||||
cy.findByTestId(".pf-c-spinner__tail-ball").should("not.exist");
|
||||
|
||||
cy.get('[data-testid="addAssociatedRole"] td[data-label="Role name"]')
|
||||
.contains(roleName)
|
||||
.parent()
|
||||
.within(() => {
|
||||
cy.get("input").click();
|
||||
});
|
||||
|
||||
cy.findByTestId(this.addAssociatedRolesModalButton).contains("Add").click();
|
||||
|
||||
cy.contains("Users in role").click();
|
||||
cy.findByTestId(this.usersPage).should("exist");
|
||||
}
|
||||
|
||||
addAssociatedClientRole(roleName: string) {
|
||||
cy.findByTestId(this.addRoleToolbarButton).click();
|
||||
|
||||
|
@ -59,4 +82,12 @@ export default class AssociatedRolesPage {
|
|||
cy.findByTestId(this.removeRolesButton).click();
|
||||
return this;
|
||||
}
|
||||
|
||||
isRemoveAssociatedRolesBtnDisabled() {
|
||||
cy.findByTestId(this.removeRolesButton).should(
|
||||
"have.class",
|
||||
"pf-m-disabled"
|
||||
);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue