From 6e5a307be27a1fb058ae52a17a4f86a2e4c39a5e Mon Sep 17 00:00:00 2001 From: amrita Date: Tue, 3 Jan 2023 15:11:32 +0545 Subject: [PATCH 1/5] Add then step in share feature file --- .../features/smoke/share.ocis.feature | 9 +++++ tests/e2e/cucumber/steps/ui/shares.ts | 18 +++++++++ .../objects/app-files/share/actions.ts | 9 +++++ .../support/objects/app-files/share/index.ts | 6 +++ .../support/objects/app-files/share/utils.ts | 39 ++++++++++++++++--- 5 files changed, 76 insertions(+), 5 deletions(-) diff --git a/tests/e2e/cucumber/features/smoke/share.ocis.feature b/tests/e2e/cucumber/features/smoke/share.ocis.feature index aeba36a3e6f..2f3318b5127 100644 --- a/tests/e2e/cucumber/features/smoke/share.ocis.feature +++ b/tests/e2e/cucumber/features/smoke/share.ocis.feature @@ -115,4 +115,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 + And "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..fcbbee9e432 100644 --- a/tests/e2e/cucumber/steps/ui/shares.ts +++ b/tests/e2e/cucumber/steps/ui/shares.ts @@ -202,3 +202,21 @@ 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 hasAcceptedShareExist = await shareObject.checkShareContext(resource, owner) + expect(hasAcceptedShareExist).toBe(shouldExist) + } + } +) diff --git a/tests/e2e/support/objects/app-files/share/actions.ts b/tests/e2e/support/objects/app-files/share/actions.ts index 5622eea3f2e..b318f9c69a4 100644 --- a/tests/e2e/support/objects/app-files/share/actions.ts +++ b/tests/e2e/support/objects/app-files/share/actions.ts @@ -1,6 +1,7 @@ import { Page } from 'playwright' import util from 'util' import Collaborator, { ICollaborator } from './collaborator' +import { acceptedShareExists } from './utils' import { sidebar } from '../utils' import { clickResource } from '../resource/actions' import { copyLinkArgs, waitForPopupNotPresent } from '../link/actions' @@ -176,6 +177,14 @@ export const checkSharee = async (args: ShareArgs): Promise => { } } +export const checkShareContext = async ( + page: Page, + resource: string, + owner: string +): Promise => { + return await acceptedShareExists({ page, resource, owner }) +} + export const hasPermissionToShare = async ( args: Omit ): Promise => { diff --git a/tests/e2e/support/objects/app-files/share/index.ts b/tests/e2e/support/objects/app-files/share/index.ts index 8b84d044572..ba1ee8c91b6 100644 --- a/tests/e2e/support/objects/app-files/share/index.ts +++ b/tests/e2e/support/objects/app-files/share/index.ts @@ -5,6 +5,7 @@ import { acceptShare, changeShareeRole, removeShareeArgs, + checkShareContext, removeSharee, ShareArgs, ShareStatusArgs, @@ -57,6 +58,11 @@ export class Share { await this.#page.goto(startUrl) } + async checkShareContext(resource: string, owner: string): Promise { + await this.#page.reload() + return await checkShareContext(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..be69aae6253 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 acceptedShareList = + '//*[@data-test-resource-name="%s"]/ancestor::tr//span[@data-test-user-name="%s"]' + export const resourceIsNotOpenable = async ({ page, resource @@ -14,10 +17,10 @@ export const resourceIsNotOpenable = async ({ await Promise.all([ page.waitForResponse((resp) => { return ( - (resp.url().endsWith(encodeURIComponent(resource)) || - resp.url().endsWith(encodeURIComponent(itemId))) && - resp.status() === 404 && - resp.request().method() === 'PROPFIND' + (resp.url().endsWith(encodeURIComponent(resource)) || + resp.url().endsWith(encodeURIComponent(itemId))) && + resp.status() === 404 && + resp.request().method() === 'PROPFIND' ) }), resourceLocator.click() @@ -26,3 +29,29 @@ export const resourceIsNotOpenable = async ({ }) return true } + +export const acceptedShareExists = async ({ + page, + resource, + owner, + timeout = 500 +}: { + page: Page + resource: string + owner: string + timeout?: number +}): Promise => { + let exist = true + // page.locator(util.format(acceptedShareList, resource, owner)).waitFor() + await page + .waitForSelector(util.format(acceptedShareList, resource, owner), { timeout }) + .catch((e) => { + if (!(e instanceof errors.TimeoutError)) { + throw e + } + + exist = false + }) + + return exist +} From 2c056d349cbc98da928d1015f4b8b2e30d36dbfe Mon Sep 17 00:00:00 2001 From: amrita Date: Fri, 6 Jan 2023 10:28:16 +0545 Subject: [PATCH 2/5] Refactor for folder share --- .../features/smoke/share.oc10.feature | 2 +- .../features/smoke/share.ocis.feature | 43 ++++++++++++------- tests/e2e/cucumber/steps/ui/shares.ts | 4 +- .../objects/app-files/share/actions.ts | 2 +- .../support/objects/app-files/share/index.ts | 6 +-- .../support/objects/app-files/share/utils.ts | 1 - 6 files changed, 35 insertions(+), 23 deletions(-) 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 2f3318b5127..0a42cd36564 100644 --- a/tests/e2e/cucumber/features/smoke/share.ocis.feature +++ b/tests/e2e/cucumber/features/smoke/share.ocis.feature @@ -7,22 +7,31 @@ 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 | + 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 | @@ -44,17 +53,23 @@ 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 | + Then "Brian" should not be able to see the following shares + | resource | owner | + | folder_to_customShared | Alice Hansen | + And "Alice" deletes the following resources | resource | | folder_to_shared/lorem_new.txt | | folder_to_shared | @@ -63,7 +78,7 @@ Feature: share 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,15 +90,13 @@ 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" opens the "files" app And "Brian" navigates to the shared with me page @@ -120,7 +133,7 @@ Feature: share | shareToBrian.txt | Brian | | shareToBrian.md | Brian | And "Alice" logs out - And "Brian" should not be able to see the following shares + Then "Brian" should not be able to see the following shares | resource | owner | | shareToBrian.txt | Alice Hansen | | shareToBrian.md | Alice Hansen | diff --git a/tests/e2e/cucumber/steps/ui/shares.ts b/tests/e2e/cucumber/steps/ui/shares.ts index fcbbee9e432..ed10f41fe13 100644 --- a/tests/e2e/cucumber/steps/ui/shares.ts +++ b/tests/e2e/cucumber/steps/ui/shares.ts @@ -215,8 +215,8 @@ Then( const { page } = this.actorsEnvironment.getActor({ key: stepUser }) const shareObject = new objects.applicationFiles.Share({ page }) for (const { resource, owner } of stepTable.hashes()) { - const hasAcceptedShareExist = await shareObject.checkShareContext(resource, owner) - expect(hasAcceptedShareExist).toBe(shouldExist) + const isAcceptedSharePresent = await shareObject.isAcceptedSharePresent(resource, owner) + expect(isAcceptedSharePresent).toBe(shouldExist) } } ) diff --git a/tests/e2e/support/objects/app-files/share/actions.ts b/tests/e2e/support/objects/app-files/share/actions.ts index b318f9c69a4..83e7833e2ed 100644 --- a/tests/e2e/support/objects/app-files/share/actions.ts +++ b/tests/e2e/support/objects/app-files/share/actions.ts @@ -177,7 +177,7 @@ export const checkSharee = async (args: ShareArgs): Promise => { } } -export const checkShareContext = async ( +export const isAcceptedSharePresent = async ( page: Page, resource: string, owner: string diff --git a/tests/e2e/support/objects/app-files/share/index.ts b/tests/e2e/support/objects/app-files/share/index.ts index ba1ee8c91b6..ea11d6a9946 100644 --- a/tests/e2e/support/objects/app-files/share/index.ts +++ b/tests/e2e/support/objects/app-files/share/index.ts @@ -5,7 +5,7 @@ import { acceptShare, changeShareeRole, removeShareeArgs, - checkShareContext, + isAcceptedSharePresent, removeSharee, ShareArgs, ShareStatusArgs, @@ -58,9 +58,9 @@ export class Share { await this.#page.goto(startUrl) } - async checkShareContext(resource: string, owner: string): Promise { + async isAcceptedSharePresent(resource: string, owner: string): Promise { await this.#page.reload() - return await checkShareContext(this.#page, resource, owner) + return await isAcceptedSharePresent(this.#page, resource, owner) } async hasPermissionToShare(resource: string): Promise { diff --git a/tests/e2e/support/objects/app-files/share/utils.ts b/tests/e2e/support/objects/app-files/share/utils.ts index be69aae6253..6eb21856cb4 100644 --- a/tests/e2e/support/objects/app-files/share/utils.ts +++ b/tests/e2e/support/objects/app-files/share/utils.ts @@ -42,7 +42,6 @@ export const acceptedShareExists = async ({ timeout?: number }): Promise => { let exist = true - // page.locator(util.format(acceptedShareList, resource, owner)).waitFor() await page .waitForSelector(util.format(acceptedShareList, resource, owner), { timeout }) .catch((e) => { From 27ad6c37b446d9525940c5c2670c09c074938a53 Mon Sep 17 00:00:00 2001 From: amrita Date: Mon, 9 Jan 2023 16:57:16 +0545 Subject: [PATCH 3/5] Address review --- tests/e2e/cucumber/steps/ui/shares.ts | 4 +++- tests/e2e/support/objects/app-files/share/utils.ts | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/e2e/cucumber/steps/ui/shares.ts b/tests/e2e/cucumber/steps/ui/shares.ts index ed10f41fe13..06d80b730b5 100644 --- a/tests/e2e/cucumber/steps/ui/shares.ts +++ b/tests/e2e/cucumber/steps/ui/shares.ts @@ -216,7 +216,9 @@ Then( const shareObject = new objects.applicationFiles.Share({ page }) for (const { resource, owner } of stepTable.hashes()) { const isAcceptedSharePresent = await shareObject.isAcceptedSharePresent(resource, owner) - expect(isAcceptedSharePresent).toBe(shouldExist) + expect(isAcceptedSharePresent, '${resource} does not exist in accepted share').toBe( + shouldExist + ) } } ) diff --git a/tests/e2e/support/objects/app-files/share/utils.ts b/tests/e2e/support/objects/app-files/share/utils.ts index 6eb21856cb4..73c74bff179 100644 --- a/tests/e2e/support/objects/app-files/share/utils.ts +++ b/tests/e2e/support/objects/app-files/share/utils.ts @@ -1,8 +1,8 @@ -import {errors, Page} from 'playwright' +import { errors, Page } from 'playwright' import util from 'util' import { resourceNameSelector, fileRow } from '../resource/actions' -const acceptedShareList = +const acceptedShareItem = '//*[@data-test-resource-name="%s"]/ancestor::tr//span[@data-test-user-name="%s"]' export const resourceIsNotOpenable = async ({ @@ -43,7 +43,7 @@ export const acceptedShareExists = async ({ }): Promise => { let exist = true await page - .waitForSelector(util.format(acceptedShareList, resource, owner), { timeout }) + .waitForSelector(util.format(acceptedShareItem, resource, owner), { timeout }) .catch((e) => { if (!(e instanceof errors.TimeoutError)) { throw e From ecd6ee1676537869282c83fb033091bc5ecf1a50 Mon Sep 17 00:00:00 2001 From: amrita Date: Wed, 11 Jan 2023 13:05:24 +0545 Subject: [PATCH 4/5] Review address --- tests/e2e/cucumber/features/smoke/share.ocis.feature | 7 ++++--- tests/e2e/support/objects/app-files/share/actions.ts | 9 --------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/tests/e2e/cucumber/features/smoke/share.ocis.feature b/tests/e2e/cucumber/features/smoke/share.ocis.feature index 0a42cd36564..eeb665b4ce8 100644 --- a/tests/e2e/cucumber/features/smoke/share.ocis.feature +++ b/tests/e2e/cucumber/features/smoke/share.ocis.feature @@ -66,14 +66,15 @@ Feature: share And "Alice" removes following sharee | resource | recipient | | folder_to_customShared | Brian | - Then "Brian" should not be able to see the following shares - | resource | owner | - | folder_to_customShared | Alice Hansen | 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 diff --git a/tests/e2e/support/objects/app-files/share/actions.ts b/tests/e2e/support/objects/app-files/share/actions.ts index 83e7833e2ed..5622eea3f2e 100644 --- a/tests/e2e/support/objects/app-files/share/actions.ts +++ b/tests/e2e/support/objects/app-files/share/actions.ts @@ -1,7 +1,6 @@ import { Page } from 'playwright' import util from 'util' import Collaborator, { ICollaborator } from './collaborator' -import { acceptedShareExists } from './utils' import { sidebar } from '../utils' import { clickResource } from '../resource/actions' import { copyLinkArgs, waitForPopupNotPresent } from '../link/actions' @@ -177,14 +176,6 @@ export const checkSharee = async (args: ShareArgs): Promise => { } } -export const isAcceptedSharePresent = async ( - page: Page, - resource: string, - owner: string -): Promise => { - return await acceptedShareExists({ page, resource, owner }) -} - export const hasPermissionToShare = async ( args: Omit ): Promise => { From 8130a017f470ca5c21dc8e42c47c2d45a58eccbe Mon Sep 17 00:00:00 2001 From: amrita Date: Tue, 17 Jan 2023 11:35:06 +0545 Subject: [PATCH 5/5] Rebase conflict --- tests/e2e/cucumber/features/smoke/share.ocis.feature | 12 +++++------- tests/e2e/support/objects/app-files/share/index.ts | 5 ++--- tests/e2e/support/objects/app-files/share/utils.ts | 12 ++++++------ 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/tests/e2e/cucumber/features/smoke/share.ocis.feature b/tests/e2e/cucumber/features/smoke/share.ocis.feature index eeb665b4ce8..63fab037dc9 100644 --- a/tests/e2e/cucumber/features/smoke/share.ocis.feature +++ b/tests/e2e/cucumber/features/smoke/share.ocis.feature @@ -11,11 +11,9 @@ Feature: share | 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 | And "Alice" uploads the following resource | resource | to | | lorem.txt | folder_to_shared | @@ -33,9 +31,9 @@ Feature: share | 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 | @@ -98,7 +96,7 @@ Feature: share | testavatar.jpeg | Brian | user | viewer | | simple.pdf | Brian | user | viewer | | sharedFile.txt | Brian | user | editor | - 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" diff --git a/tests/e2e/support/objects/app-files/share/index.ts b/tests/e2e/support/objects/app-files/share/index.ts index ea11d6a9946..59a0b9e4270 100644 --- a/tests/e2e/support/objects/app-files/share/index.ts +++ b/tests/e2e/support/objects/app-files/share/index.ts @@ -5,7 +5,6 @@ import { acceptShare, changeShareeRole, removeShareeArgs, - isAcceptedSharePresent, removeSharee, ShareArgs, ShareStatusArgs, @@ -14,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 { @@ -60,7 +59,7 @@ export class Share { async isAcceptedSharePresent(resource: string, owner: string): Promise { await this.#page.reload() - return await isAcceptedSharePresent(this.#page, resource, owner) + return await isAcceptedSharePresent({ page: this.#page, resource, owner }) } async hasPermissionToShare(resource: string): Promise { diff --git a/tests/e2e/support/objects/app-files/share/utils.ts b/tests/e2e/support/objects/app-files/share/utils.ts index 73c74bff179..f79a830e7d2 100644 --- a/tests/e2e/support/objects/app-files/share/utils.ts +++ b/tests/e2e/support/objects/app-files/share/utils.ts @@ -3,7 +3,7 @@ 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"]' + '//*[@data-test-resource-name="%s"]/ancestor::tr//span[@data-test-user-name="%s"]' export const resourceIsNotOpenable = async ({ page, @@ -17,10 +17,10 @@ export const resourceIsNotOpenable = async ({ await Promise.all([ page.waitForResponse((resp) => { return ( - (resp.url().endsWith(encodeURIComponent(resource)) || - resp.url().endsWith(encodeURIComponent(itemId))) && - resp.status() === 404 && - resp.request().method() === 'PROPFIND' + (resp.url().endsWith(encodeURIComponent(resource)) || + resp.url().endsWith(encodeURIComponent(itemId))) && + resp.status() === 404 && + resp.request().method() === 'PROPFIND' ) }), resourceLocator.click() @@ -30,7 +30,7 @@ export const resourceIsNotOpenable = async ({ return true } -export const acceptedShareExists = async ({ +export const isAcceptedSharePresent = async ({ page, resource, owner,