diff --git a/tests/e2e/cucumber/features/smoke/share.oc10.feature b/tests/e2e/cucumber/features/smoke/share.oc10.feature index 2527f7c5783..f6f414b9265 100644 --- a/tests/e2e/cucumber/features/smoke/share.oc10.feature +++ b/tests/e2e/cucumber/features/smoke/share.oc10.feature @@ -103,7 +103,7 @@ Feature: share | resource | recipient | | folder_to_shared/testavatar.jpeg | Brian | And "Alice" logs out - When "Brian" opens the "files" app + #When "Brian" opens the "files" app #Then "Brian" should not see the following resource # | Shares/testavatar_new.jpeg | #But "Brian" should see the following resource diff --git a/tests/e2e/cucumber/features/smoke/share.ocis.feature b/tests/e2e/cucumber/features/smoke/share.ocis.feature index aeba36a3e6f..63fab037dc9 100644 --- a/tests/e2e/cucumber/features/smoke/share.ocis.feature +++ b/tests/e2e/cucumber/features/smoke/share.ocis.feature @@ -7,26 +7,33 @@ Feature: share | Brian | Scenario: folder - When "Alice" logs in + Given "Alice" creates the following folder in personal space using API + | name | + | folder_to_shared | + | folder_to_customShared | + | shared_folder | + And "Alice" logs in And "Alice" opens the "files" app - And "Alice" creates the following resources - | resource | type | - | folder_to_shared | folder | - | shared_folder | folder | And "Alice" uploads the following resource - | resource | to | - | lorem.txt | folder_to_shared | + | resource | to | + | lorem.txt | folder_to_shared | + | lorem-big.txt | folder_to_customShared | When "Alice" shares the following resource using the sidebar panel - | resource | recipient | type | role | - | folder_to_shared | Brian | user | editor | - | shared_folder | Brian | user | editor | + | resource | recipient | type | role | + | folder_to_shared | Brian | user | editor | + | shared_folder | Brian | user | editor | + | folder_to_customShared | Brian | user | editor | And "Brian" logs in And "Brian" opens the "files" app And "Brian" navigates to the shared with me page + And "Brian" accepts the following share + | name | + | folder_to_shared | + | folder_to_customShared | Then "Brian" should not be able to open the folder "shared_folder" - When "Brian" accepts the following share - | name | - | folder_to_shared | + When "Brian" accepts the following share from the context menu + | name | + | shared_folder | And "Brian" declines the following share | name | | shared_folder | @@ -44,26 +51,33 @@ Feature: share And "Brian" uploads the following resource | resource | to | | simple.pdf | folder_to_shared | - When "Alice" opens the "files" app + And "Alice" opens the "files" app And "Alice" uploads the following resource | resource | to | option | | PARENT/simple.pdf | folder_to_shared | replace | And "Brian" downloads old version of the following resource | resource | to | | simple.pdf | folder_to_shared | - When "Brian" restores following resources + And "Brian" restores following resources | resource | to | version | | simple.pdf | folder_to_shared | 1 | - When "Alice" deletes the following resources + And "Alice" removes following sharee + | resource | recipient | + | folder_to_customShared | Brian | + And "Alice" deletes the following resources | resource | | folder_to_shared/lorem_new.txt | | folder_to_shared | And "Alice" logs out + Then "Brian" should not be able to see the following shares + | resource | owner | + | folder_to_customShared | Alice Hansen | + | folder_to_shared | Alice Hansen | And "Brian" logs out Scenario: file - When "Alice" logs in + Given "Alice" logs in And "Alice" opens the "files" app And "Alice" creates the following resources | resource | type | content | @@ -75,16 +89,14 @@ Feature: share | resource | | testavatar.jpeg | | simple.pdf | - And "Alice" shares the following resource using the sidebar panel + When "Alice" shares the following resource using the sidebar panel | resource | recipient | type | role | | shareToBrian.txt | Brian | user | editor | | shareToBrian.md | Brian | user | editor | | testavatar.jpeg | Brian | user | viewer | | simple.pdf | Brian | user | viewer | | sharedFile.txt | Brian | user | editor | - And "Alice" logs out - - When "Brian" logs in + And "Brian" logs in And "Brian" opens the "files" app And "Brian" navigates to the shared with me page Then "Brian" should not be able to open the file "shareToBrian.txt" @@ -115,4 +127,13 @@ Feature: share And "Brian" opens the following file in pdfviewer | resource | | simple.pdf | + And "Alice" removes following sharee + | resource | recipient | + | shareToBrian.txt | Brian | + | shareToBrian.md | Brian | + And "Alice" logs out + Then "Brian" should not be able to see the following shares + | resource | owner | + | shareToBrian.txt | Alice Hansen | + | shareToBrian.md | Alice Hansen | And "Brian" logs out diff --git a/tests/e2e/cucumber/steps/ui/shares.ts b/tests/e2e/cucumber/steps/ui/shares.ts index 80091602ced..06d80b730b5 100644 --- a/tests/e2e/cucumber/steps/ui/shares.ts +++ b/tests/e2e/cucumber/steps/ui/shares.ts @@ -202,3 +202,23 @@ When( expect(await shareObject.resourceIsNotOpenable(resource)).toBe(true) } ) + +Then( + /"([^"]*)" should( not | )be able to see the following shares$/, + async function ( + this: World, + stepUser: string, + condition: string, + stepTable: DataTable + ): Promise { + const shouldExist = condition.trim() !== 'not' + const { page } = this.actorsEnvironment.getActor({ key: stepUser }) + const shareObject = new objects.applicationFiles.Share({ page }) + for (const { resource, owner } of stepTable.hashes()) { + const isAcceptedSharePresent = await shareObject.isAcceptedSharePresent(resource, owner) + expect(isAcceptedSharePresent, '${resource} does not exist in accepted share').toBe( + shouldExist + ) + } + } +) diff --git a/tests/e2e/support/objects/app-files/share/index.ts b/tests/e2e/support/objects/app-files/share/index.ts index 8b84d044572..59a0b9e4270 100644 --- a/tests/e2e/support/objects/app-files/share/index.ts +++ b/tests/e2e/support/objects/app-files/share/index.ts @@ -13,7 +13,7 @@ import { hasPermissionToShare, copyQuickLink } from './actions' -import { resourceIsNotOpenable } from './utils' +import { resourceIsNotOpenable, isAcceptedSharePresent } from './utils' import { copyLinkArgs } from '../link/actions' export class Share { @@ -57,6 +57,11 @@ export class Share { await this.#page.goto(startUrl) } + async isAcceptedSharePresent(resource: string, owner: string): Promise { + await this.#page.reload() + return await isAcceptedSharePresent({ page: this.#page, resource, owner }) + } + async hasPermissionToShare(resource: string): Promise { return await hasPermissionToShare({ page: this.#page, resource }) } diff --git a/tests/e2e/support/objects/app-files/share/utils.ts b/tests/e2e/support/objects/app-files/share/utils.ts index 8014f2208fb..f79a830e7d2 100644 --- a/tests/e2e/support/objects/app-files/share/utils.ts +++ b/tests/e2e/support/objects/app-files/share/utils.ts @@ -1,7 +1,10 @@ -import { Page } from 'playwright' +import { errors, Page } from 'playwright' import util from 'util' import { resourceNameSelector, fileRow } from '../resource/actions' +const acceptedShareItem = + '//*[@data-test-resource-name="%s"]/ancestor::tr//span[@data-test-user-name="%s"]' + export const resourceIsNotOpenable = async ({ page, resource @@ -26,3 +29,28 @@ export const resourceIsNotOpenable = async ({ }) return true } + +export const isAcceptedSharePresent = async ({ + page, + resource, + owner, + timeout = 500 +}: { + page: Page + resource: string + owner: string + timeout?: number +}): Promise => { + let exist = true + await page + .waitForSelector(util.format(acceptedShareItem, resource, owner), { timeout }) + .catch((e) => { + if (!(e instanceof errors.TimeoutError)) { + throw e + } + + exist = false + }) + + return exist +}