From 2cf14e492dceb770b85fded67b6f21e8b108c00f Mon Sep 17 00:00:00 2001 From: Viktor Scharf Date: Tue, 26 Sep 2023 21:31:08 +0200 Subject: [PATCH] group action test --- .../features/smoke/groupActions.feature | 63 +++++++++++++++++++ tests/e2e/cucumber/steps/ui/shares.ts | 9 +++ .../objects/app-files/share/actions.ts | 26 ++++++++ .../support/objects/app-files/share/index.ts | 4 ++ 4 files changed, 102 insertions(+) create mode 100644 tests/e2e/cucumber/features/smoke/groupActions.feature diff --git a/tests/e2e/cucumber/features/smoke/groupActions.feature b/tests/e2e/cucumber/features/smoke/groupActions.feature new file mode 100644 index 00000000000..12b4f276576 --- /dev/null +++ b/tests/e2e/cucumber/features/smoke/groupActions.feature @@ -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 diff --git a/tests/e2e/cucumber/steps/ui/shares.ts b/tests/e2e/cucumber/steps/ui/shares.ts index 8986c0fea37..bc0f6ab6424 100644 --- a/tests/e2e/cucumber/steps/ui/shares.ts +++ b/tests/e2e/cucumber/steps/ui/shares.ts @@ -160,6 +160,15 @@ When( } ) +When( + '{string} accepts all pending shares using the batch actions', + async function (this: World, stepUser: string): Promise { + 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 { diff --git a/tests/e2e/support/objects/app-files/share/actions.ts b/tests/e2e/support/objects/app-files/share/actions.ts index 5ad77b363c5..298246ca743 100644 --- a/tests/e2e/support/objects/app-files/share/actions.ts +++ b/tests/e2e/support/objects/app-files/share/actions.ts @@ -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 @@ -95,6 +100,27 @@ export const acceptShare = async (args: ShareStatusArgs): Promise => { await page.locator(util.format(filesSharedWithMeAccepted, resource)).waitFor() } +export const acceptAllShare = async ({ page }: { page: Page }): Promise => { + 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 => { const { page, resource, via } = args if (via === 'CONTEXT_MENU') { diff --git a/tests/e2e/support/objects/app-files/share/index.ts b/tests/e2e/support/objects/app-files/share/index.ts index c3ce5f3d0ec..514c50e2315 100644 --- a/tests/e2e/support/objects/app-files/share/index.ts +++ b/tests/e2e/support/objects/app-files/share/index.ts @@ -23,6 +23,10 @@ export class Share { await po.declineShare({ ...args, page: this.#page }) } + async acceptAll(): Promise { + await po.acceptAllShare({ page: this.#page }) + } + async changeShareeRole(args: Omit): Promise { const startUrl = this.#page.url() await po.changeShareeRole({ ...args, page: this.#page })