From fa9009e29df4a1b04dfd61dd6e82165fb205952b Mon Sep 17 00:00:00 2001 From: Saw-jan Date: Fri, 3 Feb 2023 16:37:44 +0545 Subject: [PATCH] [e2e] separate upload step for internal link --- .../smoke/spaces/internalLink.feature | 41 ------------------- .../smoke/spaces/internalLink.ocis.feature | 39 ++++++++++++++++++ tests/e2e/cucumber/steps/ui/public.ts | 22 ++++++++++ tests/e2e/cucumber/steps/ui/spaces.ts | 10 +++++ .../support/objects/app-files/page/public.ts | 8 ++++ 5 files changed, 79 insertions(+), 41 deletions(-) delete mode 100644 tests/e2e/cucumber/features/smoke/spaces/internalLink.feature create mode 100644 tests/e2e/cucumber/features/smoke/spaces/internalLink.ocis.feature diff --git a/tests/e2e/cucumber/features/smoke/spaces/internalLink.feature b/tests/e2e/cucumber/features/smoke/spaces/internalLink.feature deleted file mode 100644 index 07cd74815b1..00000000000 --- a/tests/e2e/cucumber/features/smoke/spaces/internalLink.feature +++ /dev/null @@ -1,41 +0,0 @@ -Feature: internal link share in project space - - Scenario: share a link with internal role - Given "Admin" creates following users - | id | - | Alice | - | Brian | - And "Admin" assigns following roles to the users - | id | role | - | Alice | SpaceAdmin | - And "Alice" creates the following project space using API - | name | id | - | team | marketing | - And "Alice" creates the following folder in space "marketing" using API - | name | - | Strategy | - And "Alice" creates the following file in space "marketing" using API - | name | content | - | Strategy/plan.txt | secret plan | - And "Alice" shares the following resource using API - | resource | recipient | type | role | - | myfolder | Brian | user | editor | - And "Alice" logs in - And "Alice" opens the "files" app - And "Alice" creates a public link for the resource "myfolder" using the sidebar panel - When "Alice" edits the public link named "Link" of resource "myfolder" changing role to "internal" - And "Brian" opens the public link "Link" - And "Brian" logs in from the internal link - And "Brian" opens shared-with-me page from the internal link - And "Brian" accepts the following share - | name | - | myfolder | - And "Brian" uploads the following resource - | resource | to | - | simple.pdf | myfolder | - And "Alice" updates following sharee role - | resource | recipient | type | role | - | myfolder | Brian | user | custom_permissions:read | - And "Alice" logs out - Then "Brian" should see folder "myfolder" but should not be able to edit - And "Brian" logs out diff --git a/tests/e2e/cucumber/features/smoke/spaces/internalLink.ocis.feature b/tests/e2e/cucumber/features/smoke/spaces/internalLink.ocis.feature new file mode 100644 index 00000000000..e9315bc8bf8 --- /dev/null +++ b/tests/e2e/cucumber/features/smoke/spaces/internalLink.ocis.feature @@ -0,0 +1,39 @@ +Feature: internal link share in project space + + Scenario: share a link with internal role + Given "Admin" creates following users + | id | + | Alice | + | Brian | + And "Admin" assigns following roles to the users + | id | role | + | Alice | SpaceAdmin | + And "Alice" creates the following project space using API + | name | id | + | Marketing | marketing.1 | + And "Alice" creates the following folder in space "Marketing" using API + | name | + | myfolder | + And "Alice" creates the following file in space "Marketing" using API + | name | content | + | myfolder/plan.txt | secret plan | + And "Alice" logs in + And "Alice" navigates to the projects space page + And "Alice" navigates to the project space "marketing.1" + And "Alice" adds following users to the project space + | user | role | + | Brian | editor | + And "Alice" creates a public link for the resource "myfolder" using the sidebar panel + When "Alice" edits the public link named "Link" of resource "myfolder" changing role to "internal" + And "Brian" opens the public link "Link" + And "Brian" logs in from the internal link + And "Brian" uploads the following resource in internal link named "Link" + | resource | + | simple.pdf | + When "Alice" changes the roles of the following users in the project space + | user | role | + | Brian | viewer | + And "Alice" logs out + And "Brian" reloads the spaces page + Then "Brian" should see file "plan.txt" but should not be able to edit + And "Brian" logs out diff --git a/tests/e2e/cucumber/steps/ui/public.ts b/tests/e2e/cucumber/steps/ui/public.ts index 4da3dcc2c24..881f6817ab2 100644 --- a/tests/e2e/cucumber/steps/ui/public.ts +++ b/tests/e2e/cucumber/steps/ui/public.ts @@ -120,6 +120,28 @@ When( } ) +When( + '{string} uploads the following resource(s) in internal link named {string}', + async function ( + this: World, + stepUser: string, + link: string, + stepTable: DataTable + ): Promise { + const { page } = this.actorsEnvironment.getActor({ key: stepUser }) + const pageObject = new objects.applicationFiles.page.Public({ page }) + const { url } = this.linksEnvironment.getLink({ name: link }) + for (const info of stepTable.hashes()) { + await pageObject.uploadInternal({ + to: info.to, + resources: [this.filesEnvironment.getFile({ name: info.resource })], + option: info.option, + link: url + }) + } + } +) + Then( '{string} should not be able to open the old link {string}', function (this: World, stepUser: string, name: string): void { diff --git a/tests/e2e/cucumber/steps/ui/spaces.ts b/tests/e2e/cucumber/steps/ui/spaces.ts index 9f261009e02..74b558c2f6c 100644 --- a/tests/e2e/cucumber/steps/ui/spaces.ts +++ b/tests/e2e/cucumber/steps/ui/spaces.ts @@ -121,6 +121,16 @@ Then( } ) +Then( + '{string} should see file {string} but should not be able to edit', + async function (this: World, stepUser: string, resource: string): Promise { + const { page } = this.actorsEnvironment.getActor({ key: stepUser }) + const spacesObject = new objects.applicationFiles.Spaces({ page }) + const userCanEdit = await spacesObject.canUserEditResource({ resource }) + expect(userCanEdit).toBe(false) + } +) + Then( '{string} should not be able to see space {string}', async function (this: World, stepUser: string, space: string): Promise { diff --git a/tests/e2e/support/objects/app-files/page/public.ts b/tests/e2e/support/objects/app-files/page/public.ts index f2669fbc38d..ad9799022ac 100644 --- a/tests/e2e/support/objects/app-files/page/public.ts +++ b/tests/e2e/support/objects/app-files/page/public.ts @@ -72,6 +72,14 @@ export class Public { await this.#page.locator('body').click() } + async uploadInternal(args: Omit & { link: string }): Promise { + // link is the public link url + const { link } = args + delete args.link + await uploadResource({ ...args, page: this.#page }) + await this.#page.goto(link) + } + async delete(args: Omit): Promise { const startUrl = this.#page.url() await deleteResource({ ...args, page: this.#page })