diff --git a/cypress/integration/users_test.spec.ts b/cypress/integration/users_test.spec.ts index 3726d12a2c..801f1b3ba7 100644 --- a/cypress/integration/users_test.spec.ts +++ b/cypress/integration/users_test.spec.ts @@ -30,6 +30,7 @@ describe("User creation", () => { const attributesTab = new AttributesTab(); let itemId = "user_crud"; + let itemIdWithGroups = "user_with_groups_crud"; let itemIdWithCred = "user_crud_cred"; before(() => { @@ -63,12 +64,23 @@ describe("User creation", () => { it("Create user test", () => { itemId += "_" + (Math.random() + 1).toString(36).substring(7); - // Create createUserPage.goToCreateUser(); createUserPage.createUser(itemId); + createUserPage.save(); + + masthead.checkNotificationMessage("The user has been created"); + }); + + it("Create user with groups test", () => { + itemIdWithGroups += (Math.random() + 1).toString(36).substring(7); + // Add user from search bar + createUserPage.goToCreateUser(); + + createUserPage.createUser(itemIdWithGroups); + createUserPage.toggleAddGroupModal(); const groupsListCopy = groupsList.slice(0, 1); @@ -87,6 +99,7 @@ describe("User creation", () => { it("Create user with credentials test", () => { itemIdWithCred += "_" + (Math.random() + 1).toString(36).substring(7); + // Add user from search bar createUserPage.goToCreateUser(); createUserPage.createUser(itemIdWithCred); @@ -104,6 +117,15 @@ describe("User creation", () => { .clickSetPasswordBtn(); }); + it("Search existing user test", () => { + listingPage.searchItem(itemId).itemExist(itemId); + }); + + it("Search non-existing user test", () => { + listingPage.searchItem("user_DNE"); + cy.findByTestId(listingPage.emptyState).should("exist"); + }); + it("User details test", () => { sidebarPage.waitForPageLoad(); listingPage.searchItem(itemId).itemExist(itemId); @@ -162,7 +184,7 @@ describe("User creation", () => { userGroupsPage.goToGroupsTab(); userGroupsPage.toggleAddGroupModal(); - const groupsListCopy = groupsList.slice(1, 2); + const groupsListCopy = groupsList.slice(0, 1); groupsListCopy.forEach((element) => { cy.findByTestId(`${element}-check`).click(); @@ -213,10 +235,12 @@ describe("User creation", () => { ); }); - // TODO: Fix this test so it passes. - it.skip("Delete user test", () => { + it("Delete user from search bar test", () => { // Delete - listingPage.deleteItem(itemId); + sidebarPage.waitForPageLoad(); + + listingPage.searchItem(itemId).itemExist(itemId); + listingPage.deleteItemFromSearchBar(itemId); modalUtils.checkModalTitle("Delete user?").confirmModal(); @@ -226,6 +250,18 @@ describe("User creation", () => { listingPage.itemExist(itemId, false); }); + it("Delete user with groups test", () => { + // Delete + listingPage.deleteItem(itemIdWithGroups); + + modalUtils.checkModalTitle("Delete user?").confirmModal(); + + masthead.checkNotificationMessage("The user has been deleted"); + sidebarPage.waitForPageLoad(); + + listingPage.itemExist(itemIdWithGroups, false); + }); + it("Delete user with credential test", () => { // Delete listingPage.deleteItem(itemIdWithCred); diff --git a/cypress/support/pages/admin_console/ListingPage.ts b/cypress/support/pages/admin_console/ListingPage.ts index 05c38cfc94..65e58d62d5 100644 --- a/cypress/support/pages/admin_console/ListingPage.ts +++ b/cypress/support/pages/admin_console/ListingPage.ts @@ -29,8 +29,10 @@ export default class ListingPage { private searchInput = '.pf-c-toolbar__item [type="search"]:visible'; private tableToolbar = ".pf-c-toolbar"; private itemsRows = "table:visible"; + private deleteUserButton = "delete-user-btn"; private emptyListImg = '[role="tabpanel"]:not([hidden]) [data-testid="empty-state"]'; + public emptyState = "empty-state"; private progressBar = '[role="progressbar"]'; private itemRowDrpDwn = ".pf-c-dropdown__toggle"; private itemRowSelect = ".pf-c-select__toggle:nth-child(1)"; @@ -209,6 +211,13 @@ export default class ListingPage { return this; } + deleteItemFromSearchBar(itemName: string) { + this.markItemRow(itemName); + cy.findByTestId(this.deleteUserButton).click(); + + return this; + } + exportItem(itemName: string) { this.clickRowDetails(itemName); this.clickDetailMenu("Export"); diff --git a/cypress/support/pages/admin_console/manage/users/CreateUserPage.ts b/cypress/support/pages/admin_console/manage/users/CreateUserPage.ts index b1589ee753..abf46e5745 100644 --- a/cypress/support/pages/admin_console/manage/users/CreateUserPage.ts +++ b/cypress/support/pages/admin_console/manage/users/CreateUserPage.ts @@ -36,9 +36,9 @@ export default class CreateUserPage { goToCreateUser() { cy.get("body").then((body) => { if (body.find("[data-testid=search-users-title]").length > 0) { - cy.findByTestId(this.searchPgCreateUserBtn).click(); + cy.findByTestId(this.searchPgCreateUserBtn).click({ force: true }); } else { - cy.findByTestId(this.addUserBtn).click(); + cy.findByTestId(this.addUserBtn).click({ force: true }); } }); diff --git a/cypress/support/pages/admin_console/manage/users/UserGroupsPage.ts b/cypress/support/pages/admin_console/manage/users/UserGroupsPage.ts index 5ad099b035..46588c8c30 100644 --- a/cypress/support/pages/admin_console/manage/users/UserGroupsPage.ts +++ b/cypress/support/pages/admin_console/manage/users/UserGroupsPage.ts @@ -16,7 +16,7 @@ export default class UserGroupsPage { } toggleAddGroupModal() { - cy.findByTestId(this.addGroupButton).click(); + cy.findByTestId(this.addGroupButton).click({ force: true }); return this; } diff --git a/src/user/UsersSection.tsx b/src/user/UsersSection.tsx index a38bb2e719..c3d9b07ab6 100644 --- a/src/user/UsersSection.tsx +++ b/src/user/UsersSection.tsx @@ -223,6 +223,7 @@ export default function UsersSection() {