Skip to content

Commit

Permalink
[test-only] check lock sse event (#10873)
Browse files Browse the repository at this point in the history
* check lock sse event

* lint fix
  • Loading branch information
ScharfViktor authored May 6, 2024
1 parent 29e6fc4 commit 4cd3988
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 18 deletions.
30 changes: 19 additions & 11 deletions tests/e2e/cucumber/features/app-provider/lock.feature
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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 | |
Expand Down Expand Up @@ -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 |
Expand Down
27 changes: 27 additions & 0 deletions tests/e2e/cucumber/steps/ui/shares.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
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()
}
}
)
15 changes: 14 additions & 1 deletion tests/e2e/support/objects/app-files/share/actions.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
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'
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")]'
Expand Down Expand Up @@ -292,3 +293,15 @@ export const getAccessDetails = async (args: {
export const getMessage = ({ page }: { page: Page }): Promise<string> => {
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))
}
4 changes: 2 additions & 2 deletions tests/e2e/support/objects/app-files/share/collaborator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
11 changes: 10 additions & 1 deletion tests/e2e/support/objects/app-files/share/index.ts
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -103,4 +104,12 @@ export class Share {
getMessage(): Promise<string> {
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 })
}
}

0 comments on commit 4cd3988

Please sign in to comment.