Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e2e tests. Download old version of the file #6960

Merged
merged 2 commits into from
May 12, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,6 @@ Other free text and markdown formatting can be used elsewhere in the document if
- [webUIFilesActionMenu/versions.feature:48](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUIFilesActionMenu/versions.feature#L48)
- [webUIFilesActionMenu/versions.feature:63](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUIFilesActionMenu/versions.feature#L63)

### [downloading an old version of a file returns 501](https://github.com/owncloud/ocis/issues/2261)
- [webUIFilesActionMenu/versions.feature:105](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUIFilesActionMenu/versions.feature#L105)

### [No occ command in ocis](https://github.com/owncloud/ocis/issues/1317)
- [webUIRestrictSharing/restrictReSharing.feature:23](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUIRestrictSharing/restrictReSharing.feature#L23)
- [webUIRestrictSharing/restrictReSharing.feature:42](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUIRestrictSharing/restrictReSharing.feature#L42)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,3 @@ Feature: Versions of a file
When the user browses to display the "versions" details of file "lorem-file.txt"
Then the content of file "lorem-file.txt" for user "Alice" should be "new lorem content" in the server
And the versions list should contain 2 entries


Scenario: user downloads a previous version of the file
Given user "Alice" has uploaded file with content "lorem" to "lorem.txt" in the server
And user "Alice" has uploaded file with content "lorem content" to "lorem.txt" in the server
And user "Alice" has logged in using the webUI
And the user browses to display the "versions" details of file "lorem.txt"
When the user downloads a previous version of the file using the webUI
ScharfViktor marked this conversation as resolved.
Show resolved Hide resolved
Then no message should be displayed on the webUI
3 changes: 3 additions & 0 deletions tests/e2e/cucumber/features/integrations/share.oc10.feature
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ Feature: share
| resource | to | create_version |
| PARENT/simple.pdf | folder_to_shared | true |
#Then "Alice" should see that the resource "folder_to_shared/simple.pdf" has 1 version
And "Brian" downloads old version of the following resource
ScharfViktor marked this conversation as resolved.
Show resolved Hide resolved
| resource | to |
| simple.pdf | folder_to_shared |
When "Brian" restores following resources
| resource | to | version |
| simple.pdf | Shares/folder_to_shared | 1 |
Expand Down
3 changes: 3 additions & 0 deletions tests/e2e/cucumber/features/integrations/share.ocis.feature
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ Feature: share
| resource | to | create_version |
| PARENT/simple.pdf | folder_to_shared | true |
#Then "Alice" should see that the resource "folder_to_shared/simple.pdf" has 1 version
And "Brian" downloads old version of the following resource
| resource | to |
| simple.pdf | folder_to_shared |
When "Brian" restores following resources
| resource | to | version |
| simple.pdf | folder_to_shared | 1 |
Expand Down
23 changes: 23 additions & 0 deletions tests/e2e/cucumber/steps/app-files/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,26 @@ When(
}
}
)

When(
'{string} downloads old version of the following resource(s)',
async function (this: World, stepUser: string, stepTable: DataTable): Promise<void> {
const { page } = this.actorsEnvironment.getActor({ key: stepUser })
const resourceObject = new objects.applicationFiles.Resource({ page })
const fileInfo = stepTable.hashes().reduce((acc, stepRow) => {
const { to, resource } = stepRow

if (!acc[to]) {
acc[to] = []
}

acc[to].push(this.filesEnvironment.getFile({ name: resource }))

return acc
}, {})

for (const folder of Object.keys(fileInfo)) {
await resourceObject.downloadVersion({ folder, files: fileInfo[folder] })
}
}
)
28 changes: 28 additions & 0 deletions tests/e2e/support/objects/app-files/resource/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,3 +310,31 @@ export const deleteResource = async (args: deleteResourceArgs): Promise<void> =>
(resp) => resp.url().includes(encodeURIComponent(resourceName)) && resp.status() === 204
)
}

export interface downloadResourceVersionArgs {
page: Page
files: File[]
folder?: string
}

export const downloadResourceVersion = async (
args: downloadResourceVersionArgs
): Promise<Download[]> => {
const { page, files, folder } = args
const fileName = files.map((file) => path.basename(file.name))
const downloads = []
await clickResource({ page, path: folder })
await sidebar.open({ page, resource: fileName[0] })
await sidebar.openPanel({ page, name: 'versions' })

const [download] = await Promise.all([
page.waitForResponse(
(resp) =>
resp.url().includes('/v/') && resp.status() === 200 && resp.request().method() === 'HEAD'
),
page.waitForEvent('download'),
await page.locator('//*[@data-testid="file-versions-download-button"]').first().click()
])
downloads.push(download)
return downloads
}
9 changes: 9 additions & 0 deletions tests/e2e/support/objects/app-files/resource/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {
deleteResourceArgs,
downloadResources,
downloadResourcesArgs,
downloadResourceVersion,
downloadResourceVersionArgs,
moveOrCopyResource,
moveOrCopyResourceArgs,
renameResource,
Expand Down Expand Up @@ -81,4 +83,11 @@ export class Resource {
await this.#page.reload()
await this.#page.goto(startUrl)
}

async downloadVersion(args: Omit<downloadResourceVersionArgs, 'page'>): Promise<Download[]> {
const startUrl = this.#page.url()
const downloads = await downloadResourceVersion({ ...args, page: this.#page })
await this.#page.goto(startUrl)
return downloads
}
}