Skip to content

Commit

Permalink
Clean created groups after scenario run (#8994)
Browse files Browse the repository at this point in the history
  • Loading branch information
amrita-shrestha authored May 11, 2023
1 parent 1d291c0 commit e2bfe8b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
16 changes: 15 additions & 1 deletion tests/e2e/cucumber/environment/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ After(async function (this: World, { result }: ITestCaseHookParameter) {
}

await cleanUpSpaces(this.usersEnvironment.getUser({ key: 'admin' }))
await cleanUpGroup(this.usersEnvironment.getUser({ key: 'admin' }))

createdGroupStore.clear()
createdLinkStore.clear()
})

Expand Down Expand Up @@ -140,3 +140,17 @@ const cleanUpSpaces = async (adminUser: User) => {
await Promise.all(requests)
createdSpaceStore.clear()
}

const cleanUpGroup = async (adminUser: User) => {
const requests = []
createdGroupStore.forEach((group) => {
if (config.ocis) {
requests.push(api.graph.deleteGroup({ group, admin: adminUser }))
} else {
requests.push(api.user.deleteGroup({ group, admin: adminUser }))
}
})

await Promise.all(requests)
createdGroupStore.clear()
}
2 changes: 0 additions & 2 deletions tests/e2e/cucumber/steps/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,8 @@ Given(
for (const info of stepTable.hashes()) {
const group = this.usersEnvironment.getGroup({ key: info.id })
if (config.ocis) {
await api.graph.deleteGroup({ group, admin })
await api.graph.createGroup({ group, admin })
} else {
await api.user.deleteGroup({ group, admin })
await api.user.createGroup({ group, admin })
}
}
Expand Down
8 changes: 0 additions & 8 deletions tests/e2e/cucumber/steps/ui/adminSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -404,14 +404,6 @@ When(
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const groupsObject = new objects.applicationAdminSettings.Groups({ page })

for (const info of stepTable.hashes()) {
const group = this.usersEnvironment.getGroup({ key: info.id })
await api.graph.deleteGroup({
group: group,
admin: this.usersEnvironment.getUser({ key: stepUser })
})
}
await page.reload()
for (const info of stepTable.hashes()) {
await groupsObject.createGroup({ key: info.id })
}
Expand Down
4 changes: 3 additions & 1 deletion tests/e2e/support/api/graph/userManagement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ export const deleteGroup = async ({
group: Group
admin: User
}): Promise<Group> => {
const groupId = await getGroupId({ group, admin })
const usersEnvironment = new UsersEnvironment()
const groupId = usersEnvironment.getCreatedGroup({ key: group.id }).uuid

await request({
method: 'DELETE',
path: join('graph', 'v1.0', 'groups', groupId),
Expand Down

0 comments on commit e2bfe8b

Please sign in to comment.