diff --git a/tests/e2e/cucumber/environment/index.ts b/tests/e2e/cucumber/environment/index.ts index ea075e86006..ecdbe99b88e 100644 --- a/tests/e2e/cucumber/environment/index.ts +++ b/tests/e2e/cucumber/environment/index.ts @@ -15,7 +15,7 @@ import { config } from '../../config' import { api, environment } from '../../support' import { World } from './world' import { state } from './shared' -import { createdSpaceStore, createdLinkStore } from '../../support/store' +import { createdSpaceStore, createdLinkStore, createdGroupStore } from '../../support/store' import { User } from '../../support/types' export { World } @@ -110,6 +110,7 @@ After(async function (this: World, { result }: ITestCaseHookParameter) { await cleanUpSpaces(this.usersEnvironment.getUser({ key: 'admin' })) + createdGroupStore.clear() createdLinkStore.clear() }) diff --git a/tests/e2e/cucumber/steps/ui/adminSettings.ts b/tests/e2e/cucumber/steps/ui/adminSettings.ts index d5c9cb852ca..7abd6b3f542 100644 --- a/tests/e2e/cucumber/steps/ui/adminSettings.ts +++ b/tests/e2e/cucumber/steps/ui/adminSettings.ts @@ -413,8 +413,7 @@ When( } await page.reload() for (const info of stepTable.hashes()) { - const group = this.usersEnvironment.getGroup({ key: info.id }) - group.uuid = await groupsObject.createGroup({ key: group.displayName }) + await groupsObject.createGroup({ key: info.id }) } } ) diff --git a/tests/e2e/support/api/graph/userManagement.ts b/tests/e2e/support/api/graph/userManagement.ts index 863321dfc7f..eda28946976 100644 --- a/tests/e2e/support/api/graph/userManagement.ts +++ b/tests/e2e/support/api/graph/userManagement.ts @@ -84,8 +84,8 @@ export const createGroup = async ({ checkResponseStatus(response, 'Failed while creating group') - const responseData = await response.json() - group.uuid = responseData.id + const usersEnvironment = new UsersEnvironment() + usersEnvironment.storeCreatedGroup({ group: { ...group, uuid: (await response.json()).id } }) return group } diff --git a/tests/e2e/support/environment/userManagement.ts b/tests/e2e/support/environment/userManagement.ts index 48c93e1c78f..484b45fea0c 100644 --- a/tests/e2e/support/environment/userManagement.ts +++ b/tests/e2e/support/environment/userManagement.ts @@ -1,6 +1,5 @@ import { Group, User } from '../types' -import { dummyUserStore, dummyGroupStore } from '../store' -import { createdUserStore } from '../store/user' +import { dummyUserStore, dummyGroupStore, createdUserStore, createdGroupStore } from '../store' export class UsersEnvironment { getUser({ key }: { key: string }): User { @@ -65,23 +64,30 @@ export class UsersEnvironment { } getGroup({ key }: { key: string }): Group { - const uniqueKey = key.toLowerCase() + const groupKey = key.toLowerCase() - if (!dummyGroupStore.has(uniqueKey)) { - throw new Error(`group with key '${uniqueKey}' not found`) + if (!dummyGroupStore.has(groupKey)) { + throw new Error(`group with key '${groupKey}' not found`) } - return dummyGroupStore.get(uniqueKey) + return dummyGroupStore.get(groupKey) } - createGroup({ key, group }: { key: string; group: Group }): Group { - const uniqueKey = key.toLowerCase() + getCreatedGroup({ key }: { key: string }): Group { + const groupKey = key.toLowerCase() - if (dummyUserStore.has(uniqueKey)) { - throw new Error(`group with key '${uniqueKey}' already exists`) + if (!createdGroupStore.has(groupKey)) { + throw new Error(`group with key '${groupKey}' not found`) } - dummyGroupStore.set(uniqueKey, group) + return createdGroupStore.get(groupKey) + } + + storeCreatedGroup({ group }: { group: Group }): Group { + if (createdGroupStore.has(group.id)) { + throw new Error(`user with key '${group.id}' already exists`) + } + createdGroupStore.set(group.id, group) return group } diff --git a/tests/e2e/support/objects/app-admin-settings/groups/actions.ts b/tests/e2e/support/objects/app-admin-settings/groups/actions.ts index eb7804c5421..072d4a9b81c 100644 --- a/tests/e2e/support/objects/app-admin-settings/groups/actions.ts +++ b/tests/e2e/support/objects/app-admin-settings/groups/actions.ts @@ -18,7 +18,7 @@ const closeEditPanel = '.sidebar-panel__header .header__close' const userInput = '#%s-input' const compareDialogConfirm = '.compare-save-dialog-confirm-btn' -export const createGroup = async (args: { page: Page; key: string }): Promise => { +export const createGroup = async (args: { page: Page; key: string }): Promise => { const { page, key } = args await page.locator(newGroupBtn).click() await page.locator(createGroupInput).fill(key) @@ -30,8 +30,8 @@ export const createGroup = async (args: { page: Page; key: string }): Promise => { diff --git a/tests/e2e/support/objects/app-admin-settings/groups/index.ts b/tests/e2e/support/objects/app-admin-settings/groups/index.ts index 152962c39f2..06aef42ffd7 100644 --- a/tests/e2e/support/objects/app-admin-settings/groups/index.ts +++ b/tests/e2e/support/objects/app-admin-settings/groups/index.ts @@ -17,21 +17,35 @@ export class Groups { this.#usersEnvironment = new UsersEnvironment() this.#page = page } + getUUID({ key }: { key: string }): string { - return this.#usersEnvironment.getGroup({ key }).uuid + return this.#usersEnvironment.getCreatedGroup({ key }).uuid } - async createGroup({ key }: { key: string }): Promise { - return await createGroup({ page: this.#page, key: key }) + + async createGroup({ key }: { key: string }): Promise { + const group = this.#usersEnvironment.getGroup({ key }) + const response = await createGroup({ page: this.#page, key: group.displayName }) + this.#usersEnvironment.storeCreatedGroup({ + group: { + id: key, + uuid: response['id'], + displayName: response['displayName'] + } + }) } + getDisplayedGroups(): Promise { return getDisplayedGroups({ page: this.#page }) } + async selectGroup({ key }: { key: string }): Promise { await selectGroup({ page: this.#page, uuid: this.getUUID({ key }) }) } + async deleteGroupUsingBatchAction({ groupIds }: { groupIds: string[] }): Promise { await deleteGrouprUsingBatchAction({ page: this.#page, groupIds }) } + async deleteGroupUsingContextMenu({ key }: { key: string }): Promise { await deleteGroupUsingContextMenu({ page: this.#page, uuid: this.getUUID({ key }) }) } diff --git a/tests/e2e/support/objects/app-admin-settings/users/actions.ts b/tests/e2e/support/objects/app-admin-settings/users/actions.ts index 245d2ac9d16..8571846b0d7 100644 --- a/tests/e2e/support/objects/app-admin-settings/users/actions.ts +++ b/tests/e2e/support/objects/app-admin-settings/users/actions.ts @@ -429,5 +429,5 @@ export const waitForEditPanelToBeVisible = async (args: { page: Page }): Promise const getGroupId = (group: string): string => { const usersEnvironment = new UsersEnvironment() - return usersEnvironment.getGroup({ key: group }).uuid + return usersEnvironment.getCreatedGroup({ key: group }).uuid } diff --git a/tests/e2e/support/store/index.ts b/tests/e2e/support/store/index.ts index bcb029f0883..bef99b9b139 100644 --- a/tests/e2e/support/store/index.ts +++ b/tests/e2e/support/store/index.ts @@ -1,6 +1,6 @@ export { actorStore } from './actor' export { createdLinkStore } from './link' export { createdSpaceStore } from './space' -export { dummyUserStore } from './user' -export { dummyGroupStore } from './group' +export { dummyUserStore, createdUserStore } from './user' +export { dummyGroupStore, createdGroupStore } from './group' export { userRoleStore } from './role'