From 9493b89ca6d5d5fa3b3f726e1c4e9a3dea6fdcee Mon Sep 17 00:00:00 2001 From: ScharfViktor Date: Wed, 11 Aug 2021 23:22:53 +0200 Subject: [PATCH] add test download previos version of file. Add check download file --- docker-compose.yml | 1 + .../customCommands/checkFileExists.js | 13 ++++++++++ tests/acceptance/download/.gitkeep | 0 ...-failures-with-oc10-server-oauth2-login.md | 4 +-- ...-failures-with-ocis-server-ocis-storage.md | 4 +-- .../features/webUIFiles/download.feature | 2 +- .../webUIFilesActionMenu/versions.feature | 25 ++++++++++++++----- .../FilesPageElement/versionsDialog.js | 12 +++++++++ .../stepDefinitions/filesContext.js | 9 +++++++ 9 files changed, 59 insertions(+), 11 deletions(-) create mode 100644 tests/acceptance/customCommands/checkFileExists.js create mode 100644 tests/acceptance/download/.gitkeep diff --git a/docker-compose.yml b/docker-compose.yml index 30c909a415f..eae8ddf7ed7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -57,6 +57,7 @@ services: volumes: - /dev/shm:/dev/shm - ./tests/acceptance/filesForUpload:/uploads:ro + - ./tests/acceptance/download:/home/seluser/Downloads extra_hosts: - host.docker.internal:${DOCKER_HOST:-host-gateway} environment: diff --git a/tests/acceptance/customCommands/checkFileExists.js b/tests/acceptance/customCommands/checkFileExists.js new file mode 100644 index 00000000000..0d2acd9f41a --- /dev/null +++ b/tests/acceptance/customCommands/checkFileExists.js @@ -0,0 +1,13 @@ +const fs = require('fs-extra') + +function checkFileExists() {} + +checkFileExists.prototype.command = function(path) { + if (fs.existsSync(path)) { + console.log('The file Exists') + } else { + throw new Error("The File Doesn't exist") + } +} + +module.exports = checkFileExists diff --git a/tests/acceptance/download/.gitkeep b/tests/acceptance/download/.gitkeep new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/acceptance/expected-failures-with-oc10-server-oauth2-login.md b/tests/acceptance/expected-failures-with-oc10-server-oauth2-login.md index 71b98c65d8d..f3ad81a2ee5 100644 --- a/tests/acceptance/expected-failures-with-oc10-server-oauth2-login.md +++ b/tests/acceptance/expected-failures-with-oc10-server-oauth2-login.md @@ -170,5 +170,5 @@ Other free text and markdown formatting can be used elsewhere in the document if ### [reshared share that is shared with a group the sharer is part of shows twice on "Share with me" page](https://github.com/owncloud/web/issues/2512) - [webUISharingAcceptShares/acceptShares.feature:31](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUISharingAcceptShares/acceptShares.feature#L31) -### [Change the file content of a received shared file](https://github.com/owncloud/ocis/issues/2319) -- [webUIFilesActionMenu/versions.feature:88](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUIFilesActionMenu/versions.feature#L88) \ No newline at end of file +### [downloading an old version of a file returns 501](https://github.com/owncloud/ocis/issues/2261) +- [webUIFilesActionMenu/versions.feature:102](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUIFilesActionMenu/versions.feature#L102) \ No newline at end of file diff --git a/tests/acceptance/expected-failures-with-ocis-server-ocis-storage.md b/tests/acceptance/expected-failures-with-ocis-server-ocis-storage.md index b754f6762a2..3216c70df9a 100644 --- a/tests/acceptance/expected-failures-with-ocis-server-ocis-storage.md +++ b/tests/acceptance/expected-failures-with-ocis-server-ocis-storage.md @@ -153,8 +153,8 @@ Other free text and markdown formatting can be used elsewhere in the document if - [webUIFilesActionMenu/versions.feature:59](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUIFilesActionMenu/versions.feature#L59) - [webUIFilesActionMenu/versions.feature:74](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUIFilesActionMenu/versions.feature#L74) -### [Change the file content of a received shared file](https://github.com/owncloud/ocis/issues/2319) -- [webUIFilesActionMenu/versions.feature:88](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUIFilesActionMenu/versions.feature#L88) +### [downloading an old version of a file returns 501](https://github.com/owncloud/ocis/issues/2261) +- [webUIFilesActionMenu/versions.feature:102](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUIFilesActionMenu/versions.feature#L102) ### [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) diff --git a/tests/acceptance/features/webUIFiles/download.feature b/tests/acceptance/features/webUIFiles/download.feature index a9048ba7307..f9bf5ccc529 100644 --- a/tests/acceptance/features/webUIFiles/download.feature +++ b/tests/acceptance/features/webUIFiles/download.feature @@ -25,4 +25,4 @@ Feature: download files Given user "Alice" has created file "sample,1.txt" When the user browses to the files page And the user downloads file "sample,1.txt" using the webUI - Then no message should be displayed on the webUI + Then file "sample,1.txt" should be downloaded successfully diff --git a/tests/acceptance/features/webUIFilesActionMenu/versions.feature b/tests/acceptance/features/webUIFilesActionMenu/versions.feature index 01f76995aaf..e7152969d24 100644 --- a/tests/acceptance/features/webUIFilesActionMenu/versions.feature +++ b/tests/acceptance/features/webUIFilesActionMenu/versions.feature @@ -83,14 +83,27 @@ Feature: Versions of a file When the user re-logs in as "Alice" using the webUI And the user browses to display the "versions" details of file "lorem-file.txt" Then the versions list should contain 0 entries - + @issue-ocis-2319 - Scenario: change the file content of a received shared file - Given user "Brian" has created file "lorem.txt" - And user "Brian" has shared file "lorem.txt" with user "Alice" with "all" permissions - And user "Alice" has accepted the share "lorem.txt" offered by user "Brian" + Scenario: change the file content of a received shared folder + Given user "Brian" has been created with default attributes and without skeleton files + And user "Brian" has created folder "simple-folder" + And user "Brian" has created file "simple-folder/lorem.txt" + And user "Brian" has shared folder "simple-folder" with user "Alice" with "all" permissions + And user "Alice" has accepted the share "simple-folder" offered by user "Brian" And user "Alice" has logged in using the webUI - And the user has opened folder "Shares" using the webUI + And the user has opened folder "Shares" + And the user has opened folder "simple-folder" When the user uploads overwriting file "lorem.txt" using the webUI + And the user browses to display the "versions" details of file "lorem.txt" Then the versions list should contain 1 entries + + @issue-ocis-2261 + Scenario: user downloads a previous version of the file + Given user "Alice" has uploaded file with content "lorem" to "lorem.txt" + And user "Alice" has uploaded file with content "lorem content" to "lorem.txt" + And user "Alice" has logged in using the webUI + When the user browses to display the "versions" details of file "lorem.txt" + When the user downloads a file of a previous version using the webUI + Then file "lorem.txt" should be downloaded successfully \ No newline at end of file diff --git a/tests/acceptance/pageObjects/FilesPageElement/versionsDialog.js b/tests/acceptance/pageObjects/FilesPageElement/versionsDialog.js index 09154da5d94..a7e4d814db7 100644 --- a/tests/acceptance/pageObjects/FilesPageElement/versionsDialog.js +++ b/tests/acceptance/pageObjects/FilesPageElement/versionsDialog.js @@ -18,6 +18,14 @@ module.exports = { .initAjaxCounters() .click('@restorePreviousVersion') .waitForOutstandingAjaxCalls() + }, + /** + * @returns {*} + */ + downloadFilePreviousVersion: function() { + return this.waitForElementVisible('@downloadPreviousVersion').click( + '@downloadPreviousVersion' + ) } }, elements: { @@ -29,6 +37,10 @@ module.exports = { selector: '(//div[contains(@id,"oc-file-versions")]//tbody/tr[@class="file-row"])[1]//button[1]', locateStrategy: 'xpath' + }, + downloadPreviousVersion: { + selector: '//button[contains(@aria-label, "Download older version")]', + locateStrategy: 'xpath' } } } diff --git a/tests/acceptance/stepDefinitions/filesContext.js b/tests/acceptance/stepDefinitions/filesContext.js index 85926d96d63..53ff9ac07dd 100644 --- a/tests/acceptance/stepDefinitions/filesContext.js +++ b/tests/acceptance/stepDefinitions/filesContext.js @@ -515,6 +515,10 @@ When('the user restores the file to last version using the webUI', function() { return client.page.FilesPageElement.versionsDialog().restoreToPreviousVersion() }) +When('the user downloads a file of a previous version using the webUI', function() { + return client.page.FilesPageElement.versionsDialog().downloadFilePreviousVersion() +}) + When('the user/public reloads the current page of the webUI', function() { return client.refresh() }) @@ -1153,6 +1157,11 @@ When('the user downloads file/folder {string} using the webUI', function(file) { return client.page.FilesPageElement.filesList().downloadFile(file) }) +Then('file {string} should be downloaded successfully', function(file) { + client.pause(5000) // We should waiting for the file to download + return client.checkFileExists(path.join(__dirname, '/../download/', file)) +}) + Then('the following resources should have share indicators on the webUI', async function( dataTable ) {