Skip to content

Commit

Permalink
[test-only][full-ci] locking file test (#10479)
Browse files Browse the repository at this point in the history
* lock file test

* lint fix
  • Loading branch information
ScharfViktor authored Feb 19, 2024
1 parent 3416e96 commit 448cd01
Show file tree
Hide file tree
Showing 9 changed files with 129 additions and 171 deletions.
2 changes: 0 additions & 2 deletions .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ config = {
"webUIPreview",
"webUILogin",
],
"webUIWebdavLockProtection": "oCISWebdavLockProtection",
"oCISSharingBasic": [
"webUISharingAcceptShares",
],
Expand Down Expand Up @@ -219,7 +218,6 @@ basicTestSuites = [
"webUITrashbinFilesFolders",
"webUITrashbinRestore",
"webUIUpload",
"webUIWebdavLockProtection",
]

ocisSpecificTestSuites = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,6 @@ Other free text and markdown formatting can be used elsewhere in the document if

- [webUISharingPublicManagement/shareByPublicLink.feature:24](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUISharingPublicManagement/shareByPublicLink.feature#L24)

### [Resources cannot be locked under ocis](https://github.com/owncloud/ocis/issues/1284)

- [webUIWebdavLockProtection/delete.feature:33](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUIWebdavLockProtection/delete.feature#L33)
- [webUIWebdavLockProtection/delete.feature:34](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUIWebdavLockProtection/delete.feature#L34)
- [webUIWebdavLockProtection/move.feature:36](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUIWebdavLockProtection/move.feature#L36)
- [webUIWebdavLockProtection/move.feature:37](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUIWebdavLockProtection/move.feature#L37)
- [webUIWebdavLockProtection/upload.feature:32](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUIWebdavLockProtection/upload.feature#L32)

### [Resources cannot be locked under ocis](https://github.com/owncloud/ocis/issues/1284)

- [webUIWebdavLockProtection/upload.feature:33](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUIWebdavLockProtection/upload.feature#L33)

### [Writing to locked files/folders give only a generic error message](https://github.com/owncloud/web/issues/5741)

- [webUIWebdavLockProtection/upload.feature:32](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUIWebdavLockProtection/upload.feature#L32)
- [webUIWebdavLockProtection/upload.feature:33](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUIWebdavLockProtection/upload.feature#L33)

### [empty subfolder inside a folder to be uploaded is not created on the server](https://github.com/owncloud/web/issues/6348)

- [webUIUpload/upload.feature:43](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUIUpload/upload.feature#L43)
Expand Down
34 changes: 0 additions & 34 deletions tests/acceptance/features/webUIWebdavLockProtection/delete.feature

This file was deleted.

58 changes: 0 additions & 58 deletions tests/acceptance/features/webUIWebdavLockProtection/move.feature

This file was deleted.

33 changes: 0 additions & 33 deletions tests/acceptance/features/webUIWebdavLockProtection/upload.feature

This file was deleted.

50 changes: 50 additions & 0 deletions tests/e2e/cucumber/features/smoke/app-provider/lock.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
Feature: lock
As a user
I can see that a file is locked if it is opened by a user with edit permissions,
and I am restricted in some actions such as moving deleting renaming a locked file


Scenario: file lock indication
Given "Admin" creates following users using API
| id |
| Alice |
| Brian |
| Carol |
And "Alice" logs in
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" opens the "files" app
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"

When "Alice" opens the "files" app
Then for "Alice" file "test.odt" should be locked

# checking that sharing/unsharing and creating link of the locked file is possible
And "Alice" creates a public link 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

When "Alice" reloads the page
Then for "Alice" file "test.odt" should not be locked
And "Alice" logs out
22 changes: 20 additions & 2 deletions tests/e2e/cucumber/steps/ui/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -493,15 +493,20 @@ When(
)

When(
/^"([^"].*)" opens the following file(?:s)? in (mediaviewer|pdfviewer|texteditor)$/,
/^"([^"].*)" opens the following file(?:s)? in (mediaviewer|pdfviewer|texteditor|Collabora|OnlyOffice)$/,
async function (this: World, stepUser: string, actionType: string, stepTable: DataTable) {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const resourceObject = new objects.applicationFiles.Resource({ page })

for (const info of stepTable.hashes()) {
await resourceObject.openFileInViewer({
name: info.resource,
actionType: actionType as 'mediaviewer' | 'pdfviewer' | 'texteditor'
actionType: actionType as
| 'mediaviewer'
| 'pdfviewer'
| 'texteditor'
| 'Collabora'
| 'OnlyOffice'
})
}
}
Expand Down Expand Up @@ -732,3 +737,16 @@ Then(
await resourceObject.openShotcut({ name: name, url: url })
}
)

Then(
/^for "([^"]*)" file "([^"]*)" (should|should not) be locked$/,
async function (this: World, stepUser: string, file: string, actionType: string) {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const resourceObject = new objects.applicationFiles.Resource({ page })
const lockLocator = await resourceObject.getLockLocator({ resource: file })

actionType === 'should'
? expect(lockLocator).toBeVisible()
: expect(lockLocator).not.toBeVisible()
}
)
78 changes: 54 additions & 24 deletions tests/e2e/support/objects/app-files/resource/actions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Download, Page, expect } from '@playwright/test'
import { Download, Locator, Page, expect } from '@playwright/test'
import util from 'util'
import path from 'path'
import { resourceExists, waitForResources } from './utils'
Expand Down Expand Up @@ -112,6 +112,8 @@ const collaboraCanvasEditorSelector = '.leaflet-layer'
const filesContextMenuAction = 'div[id^="context-menu-drop"] button.oc-files-actions-%s-trigger'
const highlightedFileRowSelector = '#files-space-table tr.oc-table-highlighted'
const emptyTrashbinButtonSelector = '.oc-files-actions-empty-trash-bin-trigger'
const resourceLockIcon =
'//*[@data-test-resource-name="%s"]/ancestor::tr//td//span[contains(@class, "oc-resource-icon-status-badge-inner")]'

export const clickResource = async ({
page,
Expand Down Expand Up @@ -560,20 +562,20 @@ export const startResourceUpload = (args: uploadResourceArgs): Promise<void> =>
return performUpload(args)
}

const puaseResumeUpload = (page: Page): Promise<void> => {
const pauseResumeUpload = (page: Page): Promise<void> => {
return page.locator(pauseResumeUploadButton).click()
}

export const pauseResourceUpload = async (page: Page): Promise<void> => {
await puaseResumeUpload(page)
await pauseResumeUpload(page)
await Promise.all([
page.locator(uploadResumeTooltip).waitFor(),
page.locator(pauseResumeUploadButton).hover()
])
}

export const resumeResourceUpload = async (page: Page): Promise<void> => {
await puaseResumeUpload(page)
await pauseResumeUpload(page)
await Promise.all([
page.locator(uploadPauseTooltip).waitFor(),
page.locator(pauseResumeUploadButton).hover()
Expand Down Expand Up @@ -1454,32 +1456,50 @@ export const removeTagsFromResource = async (args: resourceTagsArgs): Promise<vo
export interface openFileInViewerArgs {
page: Page
name: string
actionType: 'mediaviewer' | 'pdfviewer' | 'texteditor'
actionType: 'mediaviewer' | 'pdfviewer' | 'texteditor' | 'Collabora' | 'OnlyOffice'
}

export const openFileInViewer = async (args: openFileInViewerArgs): Promise<void> => {
const { page, name, actionType } = args

if (actionType === 'mediaviewer') {
await Promise.all([
page.waitForResponse(
(resp) =>
resp.url().includes('preview') &&
resp.status() === 200 &&
resp.request().method() === 'GET'
),
page.locator(util.format(resourceNameSelector, name)).click()
])
switch (actionType) {
case 'OnlyOffice':
case 'Collabora':
await Promise.all([
page.waitForResponse(
(resp) =>
resp.url().includes(`app_name=${actionType}`) &&
resp.status() === 200 &&
resp.request().method() === 'POST'
),
page.locator(util.format(resourceNameSelector, name)).click()
])
break
case 'mediaviewer': {
await Promise.all([
page.waitForResponse(
(resp) =>
resp.url().includes('preview') &&
resp.status() === 200 &&
resp.request().method() === 'GET'
),
page.locator(util.format(resourceNameSelector, name)).click()
])

// in case of error <img> doesn't contain src="blob:https://url"
expect(await page.locator(previewImage).getAttribute('src')).toContain('blob')
} else {
await Promise.all([
page.waitForResponse(
(resp) => resp.status() === 207 && resp.request().method() === 'PROPFIND'
),
page.locator(util.format(resourceNameSelector, name)).click()
])
// in case of error <img> doesn't contain src="blob:https://url"
expect(await page.locator(previewImage).getAttribute('src')).toContain('blob')
break
}
case 'pdfviewer':
case 'texteditor': {
await Promise.all([
page.waitForResponse(
(resp) => resp.status() === 207 && resp.request().method() === 'PROPFIND'
),
page.locator(util.format(resourceNameSelector, name)).click()
])
break
}
}
}

Expand Down Expand Up @@ -1645,3 +1665,13 @@ export const openShotcut = async ({
])
}
}

export interface expectFileToBeLockedArgs {
page: Page
resource: string
}

export const getLockLocator = async (args: expectFileToBeLockedArgs): Promise<Locator> => {
const { page, resource } = args
return await page.locator(util.format(resourceLockIcon, resource))
}
6 changes: 5 additions & 1 deletion tests/e2e/support/objects/app-files/resource/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Download, Page } from '@playwright/test'
import { Download, Locator, Page } from '@playwright/test'
import * as po from './actions'
import { Space } from '../../../types'

Expand Down Expand Up @@ -281,4 +281,8 @@ export class Resource {
async openShotcut({ name, url }: { name: string; url?: string }): Promise<void> {
await po.openShotcut({ page: this.#page, name: name, url: url })
}

async getLockLocator(args: Omit<po.expectFileToBeLockedArgs, 'page'>): Promise<Locator> {
return po.getLockLocator({ ...args, page: this.#page })
}
}

0 comments on commit 448cd01

Please sign in to comment.