Skip to content

Commit

Permalink
[full-ci][tests-only] Added wait for responses after batch actions (o…
Browse files Browse the repository at this point in the history
…wncloud#8697)

* wait for responses after batch group deletion

* wait for responses after batch user quota edit

* wait for responses after batch user deletion

* wait for responses after additing a user to groups

* wait for responses after removing a user from groups

* wait for responses after batch addition of user to groups

* wait for responses after batch removal of user from groups

* dry code

* refactor

* refactor

* add return type
  • Loading branch information
saw-jan authored Mar 24, 2023
1 parent 232a617 commit 5c9eace
Show file tree
Hide file tree
Showing 7 changed files with 262 additions and 166 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Feature: users management
When "Admin" logs in
And "Admin" opens the "admin-settings" app
And "Admin" navigates to the users management page
And "Admin" adds the following users to the groups "sales department,finance department" using the batch actions
And "Admin" adds the following users to the groups "sales,finance" using the batch actions
| user |
| Alice |
| Brian |
Expand All @@ -68,7 +68,7 @@ Feature: users management
| Alice |
| Brian |
| Carol |
And "Admin" removes the following users from the groups "sales department,finance department" using the batch actions
And "Admin" removes the following users from the groups "sales,finance" using the batch actions
| user |
| Alice |
| Brian |
Expand Down
63 changes: 35 additions & 28 deletions tests/e2e/cucumber/steps/ui/adminSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ When(
async function (this: World, stepUser: string, action: string, key: string): Promise<void> {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const spacesObject = new objects.applicationAdminSettings.Spaces({ page })

const spaceId = spacesObject.getUUID({ key })
switch (action) {
case 'disables':
await spacesObject.disable({ spaces: [key], context: 'context-menu' })
await spacesObject.disable({ spaceIds: [spaceId], context: 'context-menu' })
break
case 'deletes':
await spacesObject.delete({ spaces: [key], context: 'context-menu' })
await spacesObject.delete({ spaceIds: [spaceId], context: 'context-menu' })
break
case 'enables':
await spacesObject.enable({ spaces: [key], context: 'context-menu' })
await spacesObject.enable({ spaceIds: [spaceId], context: 'context-menu' })
break
default:
throw new Error(`${action} not implemented`)
Expand All @@ -71,7 +71,7 @@ When(
): Promise<void> {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const spacesObject = new objects.applicationAdminSettings.Spaces({ page })

const spaceId = spacesObject.getUUID({ key })
switch (action) {
case 'name':
await spacesObject.rename({ key, value })
Expand All @@ -80,7 +80,7 @@ When(
await spacesObject.changeSubtitle({ key, value })
break
case 'quota':
await spacesObject.changeQuota({ spaces: [key], value, context: 'context-menu' })
await spacesObject.changeQuota({ spaceIds: [spaceId], value, context: 'context-menu' })
break
default:
throw new Error(`'${action}' not implemented`)
Expand All @@ -98,13 +98,13 @@ When(
): Promise<void> {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const spacesObject = new objects.applicationAdminSettings.Spaces({ page })
const spaces = []
for (const info of stepTable.hashes()) {
spaces.push(info.id)
await spacesObject.select({ key: info.id })
const spaceIds = []
for (const { id: space } of stepTable.hashes()) {
spaceIds.push(spacesObject.getUUID({ key: space }))
await spacesObject.select({ key: space })
}
await spacesObject.changeQuota({
spaces,
spaceIds,
value,
context: 'batch-actions'
})
Expand All @@ -121,20 +121,20 @@ When(
): Promise<void> {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const spacesObject = new objects.applicationAdminSettings.Spaces({ page })
const spaces = []
for (const info of stepTable.hashes()) {
spaces.push(info.id)
await spacesObject.select({ key: info.id })
const spaceIds = []
for (const { id: space } of stepTable.hashes()) {
spaceIds.push(spacesObject.getUUID({ key: space }))
await spacesObject.select({ key: space })
}
switch (action) {
case 'disables':
await spacesObject.disable({ spaces, context: 'batch-actions' })
await spacesObject.disable({ spaceIds, context: 'batch-actions' })
break
case 'deletes':
await spacesObject.delete({ spaces, context: 'batch-actions' })
await spacesObject.delete({ spaceIds, context: 'batch-actions' })
break
case 'enables':
await spacesObject.enable({ spaces, context: 'batch-actions' })
await spacesObject.enable({ spaceIds, context: 'batch-actions' })
break
default:
throw new Error(`'${action}' not implemented`)
Expand Down Expand Up @@ -217,10 +217,12 @@ When(
): Promise<void> {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const usersObject = new objects.applicationAdminSettings.Users({ page })
for (const info of stepTable.hashes()) {
await usersObject.selectUser({ key: info.id })
const userIds = []
for (const { id: user } of stepTable.hashes()) {
userIds.push(usersObject.getUUID({ key: user }))
await usersObject.selectUser({ key: user })
}
await usersObject.changeQuotaUsingBatchAction({ value })
await usersObject.changeQuotaUsingBatchAction({ value, userIds })
}
)

Expand Down Expand Up @@ -275,17 +277,19 @@ When(
): Promise<void> {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const usersObject = new objects.applicationAdminSettings.Users({ page })
const userIds = []

for (const { user } of stepTable.hashes()) {
userIds.push(usersObject.getUUID({ key: user }))
await usersObject.select({ key: user })
}

switch (action) {
case 'adds':
await usersObject.addToGroupsBatchAtion({ groups: groups.split(',') })
await usersObject.addToGroupsBatchAtion({ userIds, groups: groups.split(',') })
break
case 'removes':
await usersObject.removeFromGroupsBatchAtion({ groups: groups.split(',') })
await usersObject.removeFromGroupsBatchAtion({ userIds, groups: groups.split(',') })
break
default:
throw new Error(`'${action}' not implemented`)
Expand Down Expand Up @@ -374,13 +378,14 @@ When(
): Promise<void> {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const usersObject = new objects.applicationAdminSettings.Users({ page })

const userIds = []
switch (actionType) {
case 'batch actions':
for (const user of stepTable.hashes()) {
await usersObject.selectUser({ key: user.id })
for (const { id: user } of stepTable.hashes()) {
userIds.push(usersObject.getUUID({ key: user }))
await usersObject.selectUser({ key: user })
}
await usersObject.deleteUserUsingBatchAction()
await usersObject.deleteUserUsingBatchAction({ userIds })
break
case 'context menu':
for (const { user } of stepTable.hashes()) {
Expand Down Expand Up @@ -481,13 +486,15 @@ When(
): Promise<void> {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const groupsObject = new objects.applicationAdminSettings.Groups({ page })
const groupIds = []

switch (actionType) {
case 'batch actions':
for (const { group } of stepTable.hashes()) {
groupIds.push(groupsObject.getUUID({ key: group }))
await groupsObject.selectGroup({ key: group })
}
await groupsObject.deleteGroupUsingBatchAction()
await groupsObject.deleteGroupUsingBatchAction({ groupIds })
break
case 'context menu':
for (const { group } of stepTable.hashes()) {
Expand Down
29 changes: 18 additions & 11 deletions tests/e2e/support/objects/app-admin-settings/groups/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,24 @@ export const deleteGroupUsingContextMenu = async (args: {
])
}

export const deleteGrouprUsingBatchAction = async (args: { page: Page }): Promise<void> => {
const { page } = args
export const deleteGrouprUsingBatchAction = async (args: {
page: Page
groupIds: string[]
}): Promise<void> => {
const { page, groupIds } = args
await page.locator(deleteBtnBatchAction).click()

await Promise.all([
page.waitForResponse(
(resp) =>
resp.url().includes('groups') &&
resp.status() === 204 &&
resp.request().method() === 'DELETE'
),
await page.locator(actionConfirmButton).click()
])
const checkResponses = []
for (const id of groupIds) {
checkResponses.push(
page.waitForResponse(
(resp) =>
resp.url().endsWith(encodeURIComponent(id)) &&
resp.status() === 204 &&
resp.request().method() === 'DELETE'
)
)
}

await Promise.all([...checkResponses, page.locator(actionConfirmButton).click()])
}
15 changes: 6 additions & 9 deletions tests/e2e/support/objects/app-admin-settings/groups/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ export class Groups {
this.#usersEnvironment = new UsersEnvironment()
this.#page = page
}
getUUID({ key }: { key: string }) {
const { uuid } = this.#usersEnvironment.getGroup({ key })
return uuid
getUUID({ key }: { key: string }): string {
return this.#usersEnvironment.getGroup({ key }).uuid
}
async createGroup({ key }: { key: string }): Promise<string> {
return await createGroup({ page: this.#page, key: key })
Expand All @@ -26,14 +25,12 @@ export class Groups {
return getDisplayedGroups({ page: this.#page })
}
async selectGroup({ key }: { key: string }): Promise<void> {
const { uuid } = this.#usersEnvironment.getGroup({ key })
await selectGroup({ uuid, page: this.#page })
await selectGroup({ page: this.#page, uuid: this.getUUID({ key }) })
}
async deleteGroupUsingBatchAction(): Promise<void> {
await deleteGrouprUsingBatchAction({ page: this.#page })
async deleteGroupUsingBatchAction({ groupIds }: { groupIds: string[] }): Promise<void> {
await deleteGrouprUsingBatchAction({ page: this.#page, groupIds })
}
async deleteGroupUsingContextMenu({ key }: { key: string }): Promise<void> {
const { uuid } = this.#usersEnvironment.getGroup({ key })
await deleteGroupUsingContextMenu({ page: this.#page, uuid })
await deleteGroupUsingContextMenu({ page: this.#page, uuid: this.getUUID({ key }) })
}
}
46 changes: 15 additions & 31 deletions tests/e2e/support/objects/app-admin-settings/spaces/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,79 +24,63 @@ export class Spaces {
this.#page = page
}

getUUID({ key }: { key: string }): string {
return this.getSpace({ key }).id
}

getDisplayedSpaces(): Promise<string[]> {
return getDisplayedSpaces(this.#page)
}

async getSpace({ key }: { key: string }): Promise<Space> {
getSpace({ key }: { key: string }): Space {
return this.#spacesEnvironment.getSpace({ key })
}

async changeQuota({
spaces,
spaceIds,
value,
context
}: {
spaces: string[]
spaceIds: string[]
value: string
context: string
}): Promise<void> {
const spaceIds = []
for (const space of spaces) {
spaceIds.push(this.#spacesEnvironment.getSpace({ key: space }).id)
}
await changeSpaceQuota({ spaceIds, value, page: this.#page, context })
}

async disable({ spaces, context }: { spaces: string[]; context: string }): Promise<void> {
const spaceIds = []
for (const space of spaces) {
spaceIds.push(this.#spacesEnvironment.getSpace({ key: space }).id)
}
async disable({ spaceIds, context }: { spaceIds: string[]; context: string }): Promise<void> {
await disableSpace({ spaceIds, page: this.#page, context })
}

async enable({ spaces, context }: { spaces: string[]; context: string }): Promise<void> {
const spaceIds = []
for (const space of spaces) {
spaceIds.push(this.#spacesEnvironment.getSpace({ key: space }).id)
}
async enable({ spaceIds, context }: { spaceIds: string[]; context: string }): Promise<void> {
await enableSpace({ spaceIds, page: this.#page, context })
}

async delete({ spaces, context }: { spaces: string[]; context: string }): Promise<void> {
const spaceIds = []
for (const space of spaces) {
spaceIds.push(this.#spacesEnvironment.getSpace({ key: space }).id)
}
async delete({ spaceIds, context }: { spaceIds: string[]; context: string }): Promise<void> {
await deleteSpace({ spaceIds, page: this.#page, context })
}

async select({ key }: { key: string }): Promise<void> {
const { id } = this.#spacesEnvironment.getSpace({ key })
await selectSpace({ id, page: this.#page })
await selectSpace({ page: this.#page, id: this.getUUID({ key }) })
}

async rename({ key, value }: { key: string; value: string }): Promise<void> {
const { id } = this.#spacesEnvironment.getSpace({ key })
await renameSpace({ id, page: this.#page, value })
await renameSpace({ page: this.#page, id: this.getUUID({ key }), value })
}

async changeSubtitle({ key, value }: { key: string; value: string }): Promise<void> {
const { id } = this.#spacesEnvironment.getSpace({ key })
await changeSpaceSubtitle({ id, page: this.#page, value })
await changeSpaceSubtitle({ page: this.#page, id: this.getUUID({ key }), value })
}

async openPanel({ key }: { key: string }): Promise<void> {
const { id } = this.#spacesEnvironment.getSpace({ key })
await openSpaceAdminSidebarPanel({ page: this.#page, id })
await openSpaceAdminSidebarPanel({ page: this.#page, id: this.getUUID({ key }) })
}

async openActionSideBarPanel({ action }: { action: string }): Promise<void> {
await openSpaceAdminActionSidebarPanel({ page: this.#page, action })
}

async listMembers({ filter }: { filter: string }): Promise<Array<string>> {
listMembers({ filter }: { filter: string }): Promise<Array<string>> {
return listSpaceMembers({ page: this.#page, filter })
}
}
Loading

0 comments on commit 5c9eace

Please sign in to comment.