Skip to content

Commit

Permalink
group action test (#9734)
Browse files Browse the repository at this point in the history
  • Loading branch information
ScharfViktor authored Oct 5, 2023
1 parent 1a317ad commit acf8382
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 0 deletions.
63 changes: 63 additions & 0 deletions tests/e2e/cucumber/features/smoke/groupActions.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
Feature: Group actions
As a user
I want to check group operations like:
- sharing a resource by several users
- accepting multiple shares by using a batch action

Scenario: copy and move resources in personal space
Given "Admin" creates following user using API
| id |
| Alice |
| Brian |
| Carol |
| David |
| Edith |
And "Admin" creates following group using API
| id |
| sales |
| finance |
| security |
And "Admin" adds user to the group using API
| user | group |
| Brian | sales |
| Brian | finance |
| Brian | security |
And "Alice" logs in
And "Alice" creates the following folders in personal space using API
| name |
| sharedFolder |
| folder1 |
| folder2 |
| folder3 |
| folder4 |
| folder5 |
| parentFolder/SubFolder |
And "Alice" shares the following resource using API
| resource | recipient | type | role |
| folder1 | Brian | user | Can edit |
| folder2 | Brian | user | Can edit |
| folder3 | Brian | user | Can edit |
| folder4 | Brian | user | Can edit |
| folder5 | Brian | user | Can edit |
| parentFolder | Brian | user | Can edit |
And "Alice" opens the "files" app

# multiple share
And "Alice" shares the following resources using the sidebar panel
| resource | recipient | type | role |
| sharedFolder | Brian | user | Can edit |
| sharedFolder | Carol | user | Can edit |
| sharedFolder | David | user | Can edit |
| sharedFolder | Edith | user | Can edit |
| sharedFolder | sales | group | Can edit |
| sharedFolder | finance | group | Can edit |
| sharedFolder | security | group | Can edit |

When "Brian" logs in
And "Brian" opens the "files" app
And "Brian" navigates to the shared with me page

# multiple share accept
And "Brian" accepts all pending shares using the batch actions
And "Alice" logs out
And "Brian" logs out
9 changes: 9 additions & 0 deletions tests/e2e/cucumber/steps/ui/shares.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,15 @@ When(
}
)

When(
'{string} accepts all pending shares using the batch actions',
async function (this: World, stepUser: string): Promise<void> {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const shareObject = new objects.applicationFiles.Share({ page })
await shareObject.acceptAll()
}
)

When(
'{string} declines the following share from the context menu',
async function (this: World, stepUser: string, stepTable: DataTable): Promise<void> {
Expand Down
26 changes: 26 additions & 0 deletions tests/e2e/support/objects/app-files/share/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ const filesSharedWithMeDeclined =
const publicLinkInputField =
'//h4[contains(@class, "oc-files-file-link-name") and text()="%s"]' +
'/following-sibling::div//p[contains(@class,"oc-files-file-link-url")]'
const showAllButton = '#files-shared-with-me-pending-section #files-shared-with-me-show-all'
const selecAllCheckbox = '#files-shared-with-me-pending-section #resource-table-select-all'
const acceptButton = '.oc-files-actions-accept-share-trigger'
const pendingShareItem =
'//div[@id="files-shared-with-me-pending-section"]//tr[contains(@class,"oc-tbody-tr")]'

export interface ShareArgs {
page: Page
Expand Down Expand Up @@ -95,6 +100,27 @@ export const acceptShare = async (args: ShareStatusArgs): Promise<void> => {
await page.locator(util.format(filesSharedWithMeAccepted, resource)).waitFor()
}

export const acceptAllShare = async ({ page }: { page: Page }): Promise<void> => {
if (await page.locator(showAllButton).isVisible()) {
await page.locator(showAllButton).click()
}
await page.locator(selecAllCheckbox).click()
const numberOfPendingShares = await page.locator(pendingShareItem).count()
const checkResponses = []
for (let i = 0; i < numberOfPendingShares; i++) {
const id = await page.locator(pendingShareItem + `[${i + 1}]`).getAttribute('data-item-id')
checkResponses.push(
page.waitForResponse(
(resp) =>
resp.url().includes(`shares/pending/${id}`) &&
resp.status() === 200 &&
resp.request().method() === 'POST'
)
)
}
await Promise.all([...checkResponses, page.locator(acceptButton).click()])
}

export const declineShare = async (args: ShareStatusArgs): Promise<void> => {
const { page, resource, via } = args
if (via === 'CONTEXT_MENU') {
Expand Down
4 changes: 4 additions & 0 deletions tests/e2e/support/objects/app-files/share/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ export class Share {
await po.declineShare({ ...args, page: this.#page })
}

async acceptAll(): Promise<void> {
await po.acceptAllShare({ page: this.#page })
}

async changeShareeRole(args: Omit<po.ShareArgs, 'page'>): Promise<void> {
const startUrl = this.#page.url()
await po.changeShareeRole({ ...args, page: this.#page })
Expand Down

0 comments on commit acf8382

Please sign in to comment.