diff --git a/tests/e2e/cucumber/features/smoke/internalLink.ocis.feature b/tests/e2e/cucumber/features/smoke/internalLink.ocis.feature new file mode 100644 index 00000000000..b25841829a1 --- /dev/null +++ b/tests/e2e/cucumber/features/smoke/internalLink.ocis.feature @@ -0,0 +1,32 @@ +Feature: internal link share + + Scenario: share a link with internal role + Given "Admin" creates following users + | id | + | Alice | + | Brian | + And "Alice" creates the following folder in personal space using API + | name | + | myfolder | + 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/steps/api.ts b/tests/e2e/cucumber/steps/api.ts index 85d1d8739d8..dbc924eac82 100644 --- a/tests/e2e/cucumber/steps/api.ts +++ b/tests/e2e/cucumber/steps/api.ts @@ -120,9 +120,10 @@ Given( await api.share.createShare({ user, path: info.resource, - shareWith: info.recipient, shareType: info.type, - role: info.role + shareWith: info.recipient, + role: info.role, + name: info.name }) } } diff --git a/tests/e2e/cucumber/steps/ui/links.ts b/tests/e2e/cucumber/steps/ui/links.ts index b6e5acf3ee1..f6c23591759 100644 --- a/tests/e2e/cucumber/steps/ui/links.ts +++ b/tests/e2e/cucumber/steps/ui/links.ts @@ -143,3 +143,12 @@ When( expect(role).toBe(newPermission.toLowerCase()) } ) + +When( + '{string} opens shared-with-me page from the internal link', + async function (this: World, stepUser: string): Promise { + const actor = this.actorsEnvironment.getActor({ key: stepUser }) + const pageObject = new objects.applicationFiles.page.shares.WithMe({ page: actor.page }) + await pageObject.openShareWithMeFromInternalLink(actor) + } +) diff --git a/tests/e2e/cucumber/steps/ui/session.ts b/tests/e2e/cucumber/steps/ui/session.ts index 7409ec042d5..06a771e3c9d 100644 --- a/tests/e2e/cucumber/steps/ui/session.ts +++ b/tests/e2e/cucumber/steps/ui/session.ts @@ -5,16 +5,20 @@ import { DateTime } from 'luxon' import { kebabCase } from 'lodash' import { objects } from '../../../support' -async function LogInUser(this: World, stepUser: string): Promise { - const user = this.usersEnvironment.getUser({ key: stepUser }) - const { page } = await this.actorsEnvironment.createActor({ +async function createNewSession(world: World, stepUser: string) { + const { page } = await world.actorsEnvironment.createActor({ key: stepUser, namespace: kebabCase( - [this.feature.name, stepUser, DateTime.now().toFormat('yyyy-M-d-hh-mm-ss')].join('-') + [world.feature.name, stepUser, DateTime.now().toFormat('yyyy-M-d-hh-mm-ss')].join('-') ) }) - const sessionObject = new objects.runtime.Session({ page }) + return new objects.runtime.Session({ page }) +} +async function LogInUser(this: World, stepUser: string): Promise { + const sessionObject = await createNewSession(this, stepUser) + const { page } = this.actorsEnvironment.getActor({ key: stepUser }) + const user = this.usersEnvironment.getUser({ key: stepUser }) await page.goto(config.frontendUrl) await sessionObject.login({ user }) } @@ -35,3 +39,12 @@ async function LogOutUser(this: World, stepUser: string): Promise { Given('{string} has logged out', LogOutUser) When('{string} logs out', LogOutUser) + +When( + '{string} logs in from the internal link', + async function (this: World, stepUser: string): Promise { + const sessionObject = await createNewSession(this, stepUser) + const user = this.usersEnvironment.getUser({ key: stepUser }) + await sessionObject.login({ user }) + } +) diff --git a/tests/e2e/support/api/share/share.ts b/tests/e2e/support/api/share/share.ts index a3c97182698..d038afdcaf9 100644 --- a/tests/e2e/support/api/share/share.ts +++ b/tests/e2e/support/api/share/share.ts @@ -21,19 +21,22 @@ export const createShare = async ({ path, shareWith, shareType, - role + role, + name }: { user: User path: string - shareWith: string shareType: string - role: string + shareWith?: string + role?: string + name?: string }): Promise => { const body = new URLSearchParams() body.append('path', path) body.append('shareWith', shareWith) body.append('shareType', shareTypes[shareType]) body.append('role', role) + body.append('name', name) const response = await request({ method: 'POST', diff --git a/tests/e2e/support/environment/actor/actor.ts b/tests/e2e/support/environment/actor/actor.ts index 40328a2dcd0..8e2622f987e 100644 --- a/tests/e2e/support/environment/actor/actor.ts +++ b/tests/e2e/support/environment/actor/actor.ts @@ -28,6 +28,14 @@ export class ActorEnvironment extends EventEmitter implements Actor { this.page = await this.context.newPage() } + public async newPage(newPage: Page): Promise { + // close the old page + await this.page.close() + // set the new page + this.page = newPage + return this.page + } + async close(): Promise { if (this.options.context.reportTracing) { await this.context?.tracing.stop({ diff --git a/tests/e2e/support/objects/app-files/page/shares/withMe.ts b/tests/e2e/support/objects/app-files/page/shares/withMe.ts index e259d7d6faf..e39a78ca056 100644 --- a/tests/e2e/support/objects/app-files/page/shares/withMe.ts +++ b/tests/e2e/support/objects/app-files/page/shares/withMe.ts @@ -1,6 +1,9 @@ import { Page } from 'playwright' +import { Actor } from '../../../../../support/types' const sharesNavSelector = '//a[@data-nav-name="files-shares-with-me"]' +const openShareWithMeButton = `//a/span[text()='Open "Shared with me"']` +const shareWithMeNavSelector = '//a/span[text()="Shared with me"]' export class WithMe { #page: Page @@ -12,4 +15,13 @@ export class WithMe { async navigate(): Promise { await this.#page.locator(sharesNavSelector).click() } + + async openShareWithMeFromInternalLink(actor: Actor): Promise { + const [newTab] = await Promise.all([ + this.#page.waitForEvent('popup'), + this.#page.locator(openShareWithMeButton).click() + ]) + await newTab.waitForSelector(shareWithMeNavSelector) + await actor.newPage(newTab) + } } diff --git a/tests/e2e/support/types.ts b/tests/e2e/support/types.ts index 9c314099f60..2cb07a16b9a 100644 --- a/tests/e2e/support/types.ts +++ b/tests/e2e/support/types.ts @@ -15,6 +15,7 @@ export interface Actor { context: BrowserContext page: Page close(): Promise + newPage(page: Page): Promise } export interface User {