2021-03-01 15:06:04 +00:00
|
|
|
import ListingPage from "../support/pages/admin_console/ListingPage";
|
2021-03-24 14:07:49 +00:00
|
|
|
import GroupModal from "../support/pages/admin_console/manage/groups/GroupModal";
|
2021-03-16 12:37:57 +00:00
|
|
|
import GroupDetailPage from "../support/pages/admin_console/manage/groups/GroupDetailPage";
|
2021-03-29 11:37:47 +00:00
|
|
|
import MoveGroupModal from "../support/pages/admin_console/manage/groups/MoveGroupModal";
|
2021-03-01 15:06:04 +00:00
|
|
|
import { SearchGroupPage } from "../support/pages/admin_console/manage/groups/SearchGroup";
|
|
|
|
import Masthead from "../support/pages/admin_console/Masthead";
|
|
|
|
import SidebarPage from "../support/pages/admin_console/SidebarPage";
|
|
|
|
import LoginPage from "../support/pages/LoginPage";
|
|
|
|
import ViewHeaderPage from "../support/pages/ViewHeaderPage";
|
2021-03-16 12:37:57 +00:00
|
|
|
import AdminClient from "../support/util/AdminClient";
|
2021-03-18 12:48:14 +00:00
|
|
|
import { keycloakBefore } from "../support/util/keycloak_before";
|
2021-03-01 15:06:04 +00:00
|
|
|
|
|
|
|
describe("Group test", () => {
|
|
|
|
const loginPage = new LoginPage();
|
|
|
|
const masthead = new Masthead();
|
|
|
|
const sidebarPage = new SidebarPage();
|
|
|
|
const listingPage = new ListingPage();
|
|
|
|
const viewHeaderPage = new ViewHeaderPage();
|
2021-03-24 14:07:49 +00:00
|
|
|
const groupModal = new GroupModal();
|
2021-03-29 11:37:47 +00:00
|
|
|
const searchGroupPage = new SearchGroupPage();
|
|
|
|
const moveGroupModal = new MoveGroupModal();
|
2021-03-01 15:06:04 +00:00
|
|
|
|
|
|
|
let groupName = "group";
|
|
|
|
|
|
|
|
describe("Group creation", () => {
|
|
|
|
beforeEach(function () {
|
2021-03-18 12:48:14 +00:00
|
|
|
keycloakBefore();
|
2021-03-01 15:06:04 +00:00
|
|
|
loginPage.logIn();
|
|
|
|
sidebarPage.goToGroups();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Group CRUD test", () => {
|
|
|
|
groupName += "_" + (Math.random() + 1).toString(36).substring(7);
|
|
|
|
|
2021-03-24 14:07:49 +00:00
|
|
|
groupModal
|
2021-03-01 15:06:04 +00:00
|
|
|
.open("empty-primary-action")
|
|
|
|
.fillGroupForm(groupName)
|
|
|
|
.clickCreate();
|
|
|
|
|
|
|
|
masthead.checkNotificationMessage("Group created");
|
|
|
|
|
|
|
|
sidebarPage.goToGroups();
|
2021-03-02 09:12:40 +00:00
|
|
|
listingPage.searchItem(groupName, false).itemExist(groupName);
|
2021-03-01 15:06:04 +00:00
|
|
|
|
|
|
|
// Delete
|
|
|
|
listingPage.deleteItem(groupName);
|
|
|
|
masthead.checkNotificationMessage("Group deleted");
|
|
|
|
});
|
|
|
|
|
2021-03-24 14:07:49 +00:00
|
|
|
it("Should rename group", () => {
|
|
|
|
groupModal
|
|
|
|
.open("empty-primary-action")
|
|
|
|
.fillGroupForm(groupName)
|
|
|
|
.clickCreate();
|
|
|
|
listingPage.goToItemDetails(groupName);
|
|
|
|
viewHeaderPage.clickAction("renameGroupAction");
|
|
|
|
|
|
|
|
const newName = "Renamed group";
|
|
|
|
groupModal.fillGroupForm(newName).clickRename();
|
|
|
|
masthead.checkNotificationMessage("Group updated");
|
|
|
|
|
|
|
|
sidebarPage.goToGroups();
|
|
|
|
listingPage.searchItem(newName, false).itemExist(newName);
|
|
|
|
listingPage.deleteItem(newName);
|
|
|
|
});
|
|
|
|
|
2021-03-29 11:37:47 +00:00
|
|
|
it("Should move group", () => {
|
|
|
|
const targetGroupName = "target";
|
2021-05-06 05:31:40 +00:00
|
|
|
groupModal.open("empty-primary-action");
|
|
|
|
groupModal.fillGroupForm(groupName).clickCreate();
|
2021-03-29 11:37:47 +00:00
|
|
|
|
|
|
|
groupModal.open().fillGroupForm(targetGroupName).clickCreate();
|
|
|
|
|
|
|
|
listingPage.clickRowDetails(groupName).clickDetailMenu("Move to");
|
|
|
|
moveGroupModal
|
|
|
|
.clickRow(targetGroupName)
|
|
|
|
.checkTitle(`Move ${groupName} to ${targetGroupName}`);
|
|
|
|
moveGroupModal.clickMove();
|
|
|
|
|
|
|
|
masthead.checkNotificationMessage("Group moved");
|
2021-05-06 05:31:40 +00:00
|
|
|
listingPage.itemExist(groupName, false).goToItemDetails(targetGroupName);
|
|
|
|
cy.wait(2000);
|
|
|
|
listingPage.itemExist(groupName);
|
|
|
|
cy.wait(1000);
|
2021-03-29 11:37:47 +00:00
|
|
|
sidebarPage.goToGroups();
|
|
|
|
listingPage.deleteItem(targetGroupName);
|
|
|
|
});
|
2021-04-07 17:58:29 +00:00
|
|
|
|
|
|
|
it("Should move group to root", async () => {
|
|
|
|
const groups = ["group1", "group2"];
|
2021-05-06 05:31:40 +00:00
|
|
|
groupModal
|
|
|
|
.open("empty-primary-action")
|
|
|
|
.fillGroupForm(groups[0])
|
|
|
|
.clickCreate();
|
|
|
|
groupModal.open().fillGroupForm(groups[1]).clickCreate();
|
|
|
|
listingPage.clickRowDetails(groups[0]).clickDetailMenu("Move to");
|
2021-04-07 17:58:29 +00:00
|
|
|
|
|
|
|
moveGroupModal.clickRoot().clickMove();
|
|
|
|
sidebarPage.goToGroups();
|
|
|
|
|
|
|
|
new GroupDetailPage().checkListSubGroup(groups);
|
|
|
|
listingPage.deleteItem(groups[0]);
|
2021-05-06 05:31:40 +00:00
|
|
|
listingPage.deleteItem(groups[1]);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Group search", () => {
|
|
|
|
viewHeaderPage.clickAction("searchGroup");
|
|
|
|
searchGroupPage.searchGroup("group").clickSearchButton();
|
|
|
|
searchGroupPage.checkTerm("group");
|
2021-04-07 17:58:29 +00:00
|
|
|
});
|
2021-03-01 15:06:04 +00:00
|
|
|
});
|
2021-03-16 12:37:57 +00:00
|
|
|
|
|
|
|
describe("Group details", () => {
|
|
|
|
const groups = ["level", "level1", "level2"];
|
|
|
|
const detailPage = new GroupDetailPage();
|
|
|
|
|
|
|
|
before(async () => {
|
|
|
|
const client = new AdminClient();
|
|
|
|
const createdGroups = await client.createSubGroups(groups);
|
|
|
|
for (let i = 0; i < 5; i++) {
|
|
|
|
const username = "user" + i;
|
|
|
|
client.createUserInGroup(username, createdGroups[i % 3].id);
|
|
|
|
}
|
2021-03-24 14:07:49 +00:00
|
|
|
client.createUser({ username: "new", enabled: true });
|
2021-03-16 12:37:57 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(() => {
|
2021-05-06 05:31:40 +00:00
|
|
|
keycloakBefore();
|
2021-03-16 12:37:57 +00:00
|
|
|
loginPage.logIn();
|
|
|
|
sidebarPage.goToGroups();
|
|
|
|
});
|
|
|
|
|
2021-05-06 05:31:40 +00:00
|
|
|
after(async () => {
|
|
|
|
const adminClient = new AdminClient();
|
|
|
|
await adminClient.deleteGroups();
|
|
|
|
for (let i = 0; i < 5; i++) {
|
|
|
|
const username = "user" + i;
|
|
|
|
await adminClient.deleteUser(username);
|
|
|
|
}
|
|
|
|
await adminClient.deleteUser("new");
|
2021-03-16 12:37:57 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("Should display all the subgroups", () => {
|
|
|
|
listingPage.goToItemDetails(groups[0]);
|
|
|
|
detailPage.checkListSubGroup([groups[1]]);
|
|
|
|
|
|
|
|
const added = "addedGroup";
|
2021-03-24 14:07:49 +00:00
|
|
|
groupModal.open().fillGroupForm(added).clickCreate();
|
2021-03-16 12:37:57 +00:00
|
|
|
|
|
|
|
detailPage.checkListSubGroup([added, groups[1]]);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Should display members", () => {
|
|
|
|
listingPage.goToItemDetails(groups[0]);
|
|
|
|
detailPage.clickMembersTab().checkListMembers(["user0", "user3"]);
|
|
|
|
detailPage
|
|
|
|
.clickIncludeSubGroups()
|
|
|
|
.checkListMembers(["user0", "user3", "user1", "user4", "user2"]);
|
|
|
|
});
|
|
|
|
|
2021-03-24 14:07:49 +00:00
|
|
|
it("Should add members", () => {
|
|
|
|
listingPage.goToItemDetails(groups[0]);
|
|
|
|
detailPage
|
|
|
|
.clickMembersTab()
|
|
|
|
.clickAddMembers()
|
|
|
|
.checkSelectableMembers(["user1", "user4"]);
|
|
|
|
detailPage.selectUsers(["new"]).clickAdd();
|
|
|
|
|
|
|
|
masthead.checkNotificationMessage("1 user added to the group");
|
|
|
|
detailPage.checkListMembers(["new", "user0", "user3"]);
|
|
|
|
});
|
|
|
|
|
2021-03-16 12:37:57 +00:00
|
|
|
it("Attributes CRUD test", () => {
|
|
|
|
listingPage.goToItemDetails(groups[0]);
|
|
|
|
detailPage
|
|
|
|
.clickAttributesTab()
|
|
|
|
.fillAttribute("key", "value")
|
|
|
|
.saveAttribute();
|
|
|
|
|
|
|
|
masthead.checkNotificationMessage("Group updated");
|
|
|
|
});
|
|
|
|
});
|
2021-03-01 15:06:04 +00:00
|
|
|
});
|