2021-03-03 19:12:16 +00:00
|
|
|
import SidebarPage from "../support/pages/admin_console/SidebarPage";
|
|
|
|
import LoginPage from "../support/pages/LoginPage";
|
2021-03-04 14:26:21 +00:00
|
|
|
import CreateUserPage from "../support/pages/admin_console/manage/users/CreateUserPage";
|
|
|
|
import Masthead from "../support/pages/admin_console/Masthead";
|
|
|
|
import ListingPage from "../support/pages/admin_console/ListingPage";
|
2021-03-11 20:23:08 +00:00
|
|
|
import UserDetailsPage from "../support/pages/admin_console/manage/users/UserDetailsPage";
|
|
|
|
import ModalUtils from "../support/util/ModalUtils";
|
2021-03-18 12:48:14 +00:00
|
|
|
import { keycloakBefore } from "../support/util/keycloak_before";
|
2021-04-14 18:19:39 +00:00
|
|
|
import GroupModal from "../support/pages/admin_console/manage/groups/GroupModal";
|
|
|
|
import UserGroupsPage from "../support/pages/admin_console/manage/users/UserGroupsPage";
|
2021-05-06 05:31:40 +00:00
|
|
|
import AdminClient from "../support/util/AdminClient";
|
2021-04-14 18:19:39 +00:00
|
|
|
|
|
|
|
let groupName = "group";
|
2021-04-19 19:53:28 +00:00
|
|
|
let groupsList: string[] = [];
|
2021-04-14 18:19:39 +00:00
|
|
|
|
|
|
|
describe("Group creation", () => {
|
|
|
|
const loginPage = new LoginPage();
|
|
|
|
const masthead = new Masthead();
|
|
|
|
const sidebarPage = new SidebarPage();
|
|
|
|
const groupModal = new GroupModal();
|
|
|
|
|
2021-05-06 05:31:40 +00:00
|
|
|
beforeEach(() => {
|
2021-04-14 18:19:39 +00:00
|
|
|
keycloakBefore();
|
|
|
|
loginPage.logIn();
|
|
|
|
sidebarPage.goToGroups();
|
|
|
|
});
|
|
|
|
|
2021-04-20 12:22:36 +00:00
|
|
|
function createNewGroup() {
|
2021-04-14 18:19:39 +00:00
|
|
|
groupName += "_" + (Math.random() + 1).toString(36).substring(7);
|
|
|
|
|
|
|
|
groupModal
|
|
|
|
.open("openCreateGroupModal")
|
|
|
|
.fillGroupForm(groupName)
|
|
|
|
.clickCreate();
|
|
|
|
|
2021-04-19 19:53:28 +00:00
|
|
|
groupsList = [...groupsList, groupName];
|
|
|
|
masthead.checkNotificationMessage("Group created");
|
|
|
|
|
|
|
|
sidebarPage.goToGroups();
|
2021-04-20 12:22:36 +00:00
|
|
|
}
|
2021-04-19 19:53:28 +00:00
|
|
|
|
2021-04-20 12:22:36 +00:00
|
|
|
it("Add groups to be joined", () => {
|
|
|
|
for (let i = 0; i <= 2; i++) {
|
|
|
|
createNewGroup();
|
|
|
|
}
|
2021-04-14 18:19:39 +00:00
|
|
|
});
|
|
|
|
});
|
2021-03-03 19:12:16 +00:00
|
|
|
|
|
|
|
describe("Users test", () => {
|
|
|
|
const loginPage = new LoginPage();
|
|
|
|
const sidebarPage = new SidebarPage();
|
2021-03-04 14:26:21 +00:00
|
|
|
const createUserPage = new CreateUserPage();
|
2021-04-14 18:19:39 +00:00
|
|
|
const userGroupsPage = new UserGroupsPage();
|
2021-03-04 14:26:21 +00:00
|
|
|
const masthead = new Masthead();
|
2021-03-11 20:23:08 +00:00
|
|
|
const modalUtils = new ModalUtils();
|
2021-03-04 14:26:21 +00:00
|
|
|
const listingPage = new ListingPage();
|
2021-03-11 20:23:08 +00:00
|
|
|
const userDetailsPage = new UserDetailsPage();
|
2021-03-04 14:26:21 +00:00
|
|
|
|
|
|
|
let itemId = "user_crud";
|
2021-03-03 19:12:16 +00:00
|
|
|
|
|
|
|
describe("User creation", () => {
|
2021-03-11 20:23:08 +00:00
|
|
|
beforeEach(() => {
|
2021-03-18 12:48:14 +00:00
|
|
|
keycloakBefore();
|
2021-03-03 19:12:16 +00:00
|
|
|
loginPage.logIn();
|
|
|
|
sidebarPage.goToUsers();
|
|
|
|
});
|
|
|
|
|
2021-05-06 05:31:40 +00:00
|
|
|
after(async () => {
|
|
|
|
await new AdminClient().deleteGroups();
|
|
|
|
});
|
2021-03-04 18:49:05 +00:00
|
|
|
|
2021-05-06 05:31:40 +00:00
|
|
|
it("Go to create User page", () => {
|
2021-03-04 14:26:21 +00:00
|
|
|
createUserPage.goToCreateUser();
|
2021-03-03 19:12:16 +00:00
|
|
|
cy.url().should("include", "users/add-user");
|
2021-03-04 14:26:21 +00:00
|
|
|
|
|
|
|
// Verify Cancel button works
|
|
|
|
createUserPage.cancel();
|
2021-03-03 19:12:16 +00:00
|
|
|
cy.url().should("not.include", "/add-user");
|
|
|
|
});
|
2021-03-04 14:26:21 +00:00
|
|
|
|
2021-05-06 05:31:40 +00:00
|
|
|
it("Create user test", () => {
|
2021-03-04 14:26:21 +00:00
|
|
|
itemId += "_" + (Math.random() + 1).toString(36).substring(7);
|
2021-03-04 18:49:05 +00:00
|
|
|
|
2021-03-04 14:26:21 +00:00
|
|
|
// Create
|
|
|
|
createUserPage.goToCreateUser();
|
2021-03-04 18:49:05 +00:00
|
|
|
|
2021-04-20 12:22:36 +00:00
|
|
|
createUserPage.createUser(itemId);
|
|
|
|
|
|
|
|
createUserPage.toggleAddGroupModal();
|
|
|
|
|
|
|
|
const groupsListCopy = groupsList.slice(0, 1);
|
|
|
|
|
|
|
|
console.log(groupsList);
|
|
|
|
|
|
|
|
groupsListCopy.forEach((element) => {
|
|
|
|
cy.getId(`${element}-check`).click();
|
|
|
|
});
|
|
|
|
|
|
|
|
createUserPage.joinGroups();
|
|
|
|
|
|
|
|
createUserPage.save();
|
2021-03-04 14:26:21 +00:00
|
|
|
|
|
|
|
masthead.checkNotificationMessage("The user has been created");
|
|
|
|
|
2021-03-11 20:23:08 +00:00
|
|
|
sidebarPage.goToUsers();
|
|
|
|
});
|
|
|
|
|
2021-05-06 05:31:40 +00:00
|
|
|
it("User details test", () => {
|
2021-03-11 20:23:08 +00:00
|
|
|
listingPage.searchItem(itemId).itemExist(itemId);
|
|
|
|
|
|
|
|
listingPage.goToItemDetails(itemId);
|
|
|
|
|
|
|
|
userDetailsPage.fillUserData().save();
|
|
|
|
|
|
|
|
masthead.checkNotificationMessage("The user has been saved");
|
|
|
|
|
2021-04-14 18:19:39 +00:00
|
|
|
sidebarPage.goToUsers();
|
|
|
|
listingPage.searchItem(itemId).itemExist(itemId);
|
|
|
|
});
|
2021-03-23 19:02:27 +00:00
|
|
|
|
2021-05-06 05:31:40 +00:00
|
|
|
it("Add user to groups test", () => {
|
2021-04-14 18:19:39 +00:00
|
|
|
// Go to user groups
|
2021-03-04 14:26:21 +00:00
|
|
|
listingPage.searchItem(itemId).itemExist(itemId);
|
2021-04-14 18:19:39 +00:00
|
|
|
listingPage.goToItemDetails(itemId);
|
|
|
|
|
|
|
|
userGroupsPage.goToGroupsTab();
|
|
|
|
userGroupsPage.toggleAddGroupModal();
|
2021-04-19 19:53:28 +00:00
|
|
|
|
2021-04-20 12:22:36 +00:00
|
|
|
const groupsListCopy = groupsList.slice(1, 2);
|
|
|
|
|
|
|
|
groupsListCopy.forEach((element) => {
|
2021-04-19 19:53:28 +00:00
|
|
|
cy.getId(`${element}-check`).click();
|
|
|
|
});
|
|
|
|
|
2021-04-20 12:22:36 +00:00
|
|
|
userGroupsPage.joinGroups();
|
2021-04-14 18:19:39 +00:00
|
|
|
});
|
2021-03-11 20:23:08 +00:00
|
|
|
|
2021-05-06 05:31:40 +00:00
|
|
|
it("Leave group test", () => {
|
2021-04-14 18:19:39 +00:00
|
|
|
listingPage.searchItem(itemId).itemExist(itemId);
|
|
|
|
listingPage.goToItemDetails(itemId);
|
|
|
|
// Go to user groups
|
|
|
|
userGroupsPage.goToGroupsTab();
|
2021-04-20 12:22:36 +00:00
|
|
|
cy.contains("Leave").click();
|
2021-04-14 18:19:39 +00:00
|
|
|
cy.getId("modalConfirm").click();
|
|
|
|
});
|
|
|
|
|
2021-05-06 05:31:40 +00:00
|
|
|
it("Go to user consents test", () => {
|
2021-04-14 18:19:39 +00:00
|
|
|
listingPage.searchItem(itemId).itemExist(itemId);
|
2021-04-14 18:39:21 +00:00
|
|
|
|
|
|
|
listingPage.goToItemDetails(itemId);
|
|
|
|
|
|
|
|
cy.getId("user-consents-tab").click();
|
|
|
|
cy.getId("empty-state").contains("No consents");
|
|
|
|
});
|
|
|
|
|
2021-05-06 05:31:40 +00:00
|
|
|
it("Delete user test", () => {
|
2021-03-11 20:23:08 +00:00
|
|
|
// Delete
|
|
|
|
listingPage.deleteItem(itemId);
|
|
|
|
|
|
|
|
modalUtils.checkModalTitle("Delete user?").confirmModal();
|
|
|
|
|
|
|
|
masthead.checkNotificationMessage("The user has been deleted");
|
|
|
|
|
|
|
|
listingPage.itemExist(itemId, false);
|
2021-03-04 14:26:21 +00:00
|
|
|
});
|
2021-03-03 19:12:16 +00:00
|
|
|
});
|
2021-04-19 19:53:28 +00:00
|
|
|
});
|