From 4cd3988fa8ee4514c910ad7d670d80c7fe537bc3 Mon Sep 17 00:00:00 2001 From: Viktor Scharf Date: Mon, 6 May 2024 09:56:19 +0200 Subject: [PATCH] [test-only] check lock sse event (#10873) * check lock sse event * lint fix --- .../features/app-provider/lock.feature | 30 ++++++++----- .../features/{spaces => smoke}/sse.feature | 43 +++++++++++++++++-- tests/e2e/cucumber/steps/ui/shares.ts | 27 ++++++++++++ .../objects/app-files/share/actions.ts | 15 ++++++- .../objects/app-files/share/collaborator.ts | 4 +- .../support/objects/app-files/share/index.ts | 11 ++++- 6 files changed, 112 insertions(+), 18 deletions(-) rename tests/e2e/cucumber/features/{spaces => smoke}/sse.feature (79%) diff --git a/tests/e2e/cucumber/features/app-provider/lock.feature b/tests/e2e/cucumber/features/app-provider/lock.feature index a3a29fa00e0..5436e69fb03 100644 --- a/tests/e2e/cucumber/features/app-provider/lock.feature +++ b/tests/e2e/cucumber/features/app-provider/lock.feature @@ -1,3 +1,4 @@ +@sse Feature: lock As a user I can see that a file is locked if it is opened by a user with edit permissions, @@ -14,33 +15,40 @@ Feature: lock And "Alice" creates the following files into personal space using API | pathToFile | content | | test.odt | some content | - And "Alice" creates the following folder in personal space using API - | name | - | folder | And "Alice" shares the following resource using API | resource | recipient | type | role | | test.odt | Brian | user | Can edit | - And "Brian" logs in And "Brian" navigates to the shared with me page When "Brian" opens the following file in Collabora | resource | | test.odt | - Then "Brian" should see the content "some content" in editor "Collabora" + Then "Brian" should see the content "some content" in editor "OnlyOffice" + + # file-locked + And "Alice" should get "file-locked" SSE event And for "Alice" file "test.odt" should be locked - # checking that sharing/unsharing and creating link of the locked file is possible + # checking that user cannot 'move', 'rename', 'delete' locked file + And "Alice" should not be able to edit file "test.odt" + + # checking that user cannot delete or change share of the locked file + # https://github.com/owncloud/web/issues/10507 + And "Alice" should not be able to manage share with user "Brian" + + # checking that sharing and creating link of the locked file is possible And "Alice" creates a public link of following resource using the sidebar panel | resource | password | | test.odt | %public% | And "Alice" shares the following resource using the sidebar panel | resource | recipient | type | role | resourceType | | test.odt | Carol | user | Can view | file | - # unsharing should remove lock https://github.com/owncloud/ocis/issues/8273 - # And "Alice" removes following sharee - # | resource | recipient | - # | test.odt | Brian | - And "Brian" logs out + # file-unlocked + When "Brian" closes the file viewer + Then "Alice" should get "file-unlocked" SSE event And for "Alice" file "test.odt" should not be locked + And "Alice" should be able to manage share with user "Brian" + + And "Brian" logs out And "Alice" logs out diff --git a/tests/e2e/cucumber/features/spaces/sse.feature b/tests/e2e/cucumber/features/smoke/sse.feature similarity index 79% rename from tests/e2e/cucumber/features/spaces/sse.feature rename to tests/e2e/cucumber/features/smoke/sse.feature index d971b69791b..6cc4e624e3d 100644 --- a/tests/e2e/cucumber/features/spaces/sse.feature +++ b/tests/e2e/cucumber/features/smoke/sse.feature @@ -3,8 +3,8 @@ Feature: server sent events events: | userlog-notification | | | postprocessing-finished | | - | file-locked | | - | file-unlocked | | + | file-locked | x | checked in the app-provider/lock.feature + | file-unlocked | x | checked in the app-provider/lock.feature | file-touched | | | item-renamed | | | item-trashed | | @@ -133,7 +133,44 @@ Feature: server sent events And "Alice" creates the following folder in personal space using API | name | | sharedFolder/subFolder | - + + # share-created + When "Alice" shares the following resource using the sidebar panel + | resource | recipient | type | role | + | sharedFolder | Brian | user | Can view | + Then "Alice" should get "share-created" SSE event + And "Brian" should get "share-created" SSE event + And "Brian" should not be able to edit folder "sharedFolder" + + # share-updated + When "Brian" opens folder "sharedFolder" + And "Alice" updates following sharee role + | resource | recipient | type | role | resourceType | + | sharedFolder | Brian | user | Can edit | folder | + Then "Alice" should get "share-updated" SSE event + And "Brian" should get "share-updated" SSE event + And "Brian" should be able to edit folder "subFolder" + + # share-removed + When "Alice" removes following sharee + | resource | recipient | + | sharedFolder | Brian | + Then "Alice" should get "share-removed" SSE event + And "Brian" should get "share-removed" SSE event + And "Brian" should see the message "Your access to this share has been revoked. Please navigate to another location." on the webUI + + And "Brian" logs out + And "Alice" logs out + + + Scenario: public link sse events + When "Brian" logs in + And "Brian" navigates to the shared with me page + And "Alice" logs in + And "Alice" creates the following folder in personal space using API + | name | + | sharedFolder/subFolder | + # share-created When "Alice" shares the following resource using the sidebar panel | resource | recipient | type | role | diff --git a/tests/e2e/cucumber/steps/ui/shares.ts b/tests/e2e/cucumber/steps/ui/shares.ts index 603b5e3a7eb..54af5bf4244 100644 --- a/tests/e2e/cucumber/steps/ui/shares.ts +++ b/tests/e2e/cucumber/steps/ui/shares.ts @@ -321,3 +321,30 @@ Then( expect(actualMessage).toBe(message) } ) + +Then( + /^"([^"]*)" (should|should not) be able to manage share with user "([^"]*)"$/, + async function ( + this: World, + stepUser: any, + actionType: string, + recipient: string + ): Promise { + const { page } = this.actorsEnvironment.getActor({ key: stepUser }) + const shareObject = new objects.applicationFiles.Share({ page }) + const changeRole = shareObject.changeRoleLocator( + this.usersEnvironment.getUser({ key: recipient }) + ) + const changeShare = shareObject.changeShareLocator( + this.usersEnvironment.getUser({ key: recipient }) + ) + + if (actionType === 'should') { + await expect(changeRole).not.toBeDisabled() + await expect(changeShare).not.toBeDisabled() + } else { + await expect(changeRole).toBeDisabled() + await expect(changeShare).toBeDisabled() + } + } +) diff --git a/tests/e2e/support/objects/app-files/share/actions.ts b/tests/e2e/support/objects/app-files/share/actions.ts index 2cca8d5374e..28df18f5f3a 100644 --- a/tests/e2e/support/objects/app-files/share/actions.ts +++ b/tests/e2e/support/objects/app-files/share/actions.ts @@ -1,4 +1,4 @@ -import { Page, expect } from '@playwright/test' +import { Page, expect, Locator } from '@playwright/test' import util from 'util' import Collaborator, { ICollaborator, IAccessDetails } from './collaborator' import { sidebar } from '../utils' @@ -6,6 +6,7 @@ import { clickResource } from '../resource/actions' import { clearCurrentPopup, createLinkArgs } from '../link/actions' import { config } from '../../../../config.js' import { createdLinkStore } from '../../../store' +import { User } from '../../../types' const quickShareButton = '//*[@data-test-resource-name="%s"]/ancestor::tr//button[contains(@class, "files-quick-action-show-shares")]' @@ -292,3 +293,15 @@ export const getAccessDetails = async (args: { export const getMessage = ({ page }: { page: Page }): Promise => { return page.locator(informMessage).textContent() } + +export const changeRoleLocator = (args: { page: Page; recipient: User }): Locator => { + const { page, recipient } = args + const recipientRow = Collaborator.getCollaboratorUserOrGroupSelector(recipient, 'user') + return page.locator(util.format(Collaborator.collaboratorRoleDropdownButton, recipientRow)) +} + +export const changeShareLocator = (args: { page: Page; recipient: User }): Locator => { + const { page, recipient } = args + const recipientRow = Collaborator.getCollaboratorUserOrGroupSelector(recipient, 'user') + return page.locator(util.format(Collaborator.collaboratorEditDropdownButton, recipientRow)) +} diff --git a/tests/e2e/support/objects/app-files/share/collaborator.ts b/tests/e2e/support/objects/app-files/share/collaborator.ts index 8af6df39c5f..6e423bba7c6 100644 --- a/tests/e2e/support/objects/app-files/share/collaborator.ts +++ b/tests/e2e/support/objects/app-files/share/collaborator.ts @@ -61,11 +61,11 @@ export default class Collaborator { private static readonly newCollaboratorRoleDropdown = '//*[@id="files-collaborators-role-button-new"]' private static readonly sendInvitationButton = '#new-collaborators-form-create-button' - private static readonly collaboratorRoleDropdownButton = + public static readonly collaboratorRoleDropdownButton = '%s//button[contains(@class,"files-recipient-role-select-btn")]' private static readonly collaboratorRoleItemSelector = '%s//span[contains(@class,"roles-select-role-item")]/span[text()="%s"]' - private static readonly collaboratorEditDropdownButton = + public static readonly collaboratorEditDropdownButton = '%s//button[contains(@class,"collaborator-edit-dropdown-options-btn")]' private static readonly collaboratorUserSelector = '//*[@data-testid="collaborator-user-item-%s"]' private static readonly collaboratorGroupSelector = diff --git a/tests/e2e/support/objects/app-files/share/index.ts b/tests/e2e/support/objects/app-files/share/index.ts index 7030929c312..8727f1a6436 100644 --- a/tests/e2e/support/objects/app-files/share/index.ts +++ b/tests/e2e/support/objects/app-files/share/index.ts @@ -1,8 +1,9 @@ -import { Page } from '@playwright/test' +import { Page, Locator } from '@playwright/test' import * as po from './actions' import { resourceIsNotOpenable, isAcceptedSharePresent, resourceIsSynced } from './utils' import { createLinkArgs } from '../link/actions' import { ICollaborator, IAccessDetails } from './collaborator' +import { User } from '../../../types' export class Share { #page: Page @@ -103,4 +104,12 @@ export class Share { getMessage(): Promise { return po.getMessage({ page: this.#page }) } + + changeRoleLocator(recipient: User): Locator { + return po.changeRoleLocator({ page: this.#page, recipient }) + } + + changeShareLocator(recipient: User): Locator { + return po.changeRoleLocator({ page: this.#page, recipient }) + } }