From a0ee0884fa9a33adccd389a3bfd1c4c704dd3e97 Mon Sep 17 00:00:00 2001 From: ScharfViktor Date: Wed, 11 Aug 2021 23:22:53 +0200 Subject: [PATCH 1/4] 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 | 2 ++ ...-failures-with-ocis-server-ocis-storage.md | 4 +-- .../features/webUIFiles/download.feature | 2 +- .../webUIFilesActionMenu/versions.feature | 31 ++++++++++++------ .../FilesPageElement/versionsDialog.js | 12 +++++++ .../stepDefinitions/filesContext.js | 32 +++++++++++++++++-- 9 files changed, 82 insertions(+), 15 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 e6e6f96d493..e0b7989cd63 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -59,6 +59,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..7f819c6428a --- /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 2742375c7e5..69cb9a30122 100644 --- a/tests/acceptance/expected-failures-with-oc10-server-oauth2-login.md +++ b/tests/acceptance/expected-failures-with-oc10-server-oauth2-login.md @@ -199,3 +199,5 @@ Other free text and markdown formatting can be used elsewhere in the document if - [webUISharingFilePermissionsGroups/sharePermissionsGroup.feature:66](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUISharingFilePermissionsGroups/sharePermissionsGroup.feature#L66) - [webUISharingPermissionToRoot/shareFileWithMultipleUsers.feature:66](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUISharingPermissionToRoot/shareFileWithMultipleUsers.feature#L66) +### [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) 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 13ac7308cff..62e7cc67e53 100644 --- a/tests/acceptance/expected-failures-with-ocis-server-ocis-storage.md +++ b/tests/acceptance/expected-failures-with-ocis-server-ocis-storage.md @@ -122,8 +122,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 18ff8a7b534..b052133232a 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 has browsed 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 21b08e3eaac..2e59f900e29 100644 --- a/tests/acceptance/features/webUIFilesActionMenu/versions.feature +++ b/tests/acceptance/features/webUIFilesActionMenu/versions.feature @@ -83,16 +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 the setting "shareapi_auto_accept_share" of app "core" has been set to "no" - And the administrator has set the default folder for received shares to "Shares" - And user "user0" has uploaded file with content "a text file" to "lorem.txt" - And user "user0" has shared file "lorem.txt" with user "Alice" with "all" permissions - And user "Alice" has accepted the share "Shares/lorem.txt" offered by user "user0" + 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 - When the user opens folder "Shares" using the webUI - And the user uploads overwriting file "lorem.txt" 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 + 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 + diff --git a/tests/acceptance/pageObjects/FilesPageElement/versionsDialog.js b/tests/acceptance/pageObjects/FilesPageElement/versionsDialog.js index 77d46e4b062..3a7ab6bc4ca 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 bc7a21bed7b..89a71ca53c5 100644 --- a/tests/acceptance/stepDefinitions/filesContext.js +++ b/tests/acceptance/stepDefinitions/filesContext.js @@ -516,7 +516,12 @@ When('the user restores the file to last version using the webUI', function () { return client.page.FilesPageElement.versionsDialog().restoreToPreviousVersion() }) -When('the user/public reloads the current page of the webUI', function () { + +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() }) @@ -1247,8 +1252,31 @@ Then( ']' ) } +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 +) { + for (const { fileName, expectedIndicators } of dataTable.hashes()) { + const indicatorsArray = await client.page.FilesPageElement.filesList().getShareIndicatorsForResourceWithRetry( + fileName, + true + ) + const expectedIndicatorsArray = expectedIndicators.split(',').map(s => s.trim()) + assert.ok( + _.intersection(indicatorsArray, expectedIndicatorsArray).length === + expectedIndicatorsArray.length, + `Expected share indicators to be the same for "${fileName}": expected [` + + expectedIndicatorsArray.join(', ') + + '] got [' + + indicatorsArray.join(', ') + + ']' + ) } -) +}) Then( 'the following resources should not have share indicators on the webUI', From 123c336fc1202325d37b66199390696d82aceafc Mon Sep 17 00:00:00 2001 From: ScharfViktor Date: Thu, 12 Aug 2021 13:39:57 +0200 Subject: [PATCH 2/4] skip test witch don't work in chrome. Add new test --- tests/acceptance/features/webUIFiles/download.feature | 9 +++++++++ tests/acceptance/stepDefinitions/filesContext.js | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/acceptance/features/webUIFiles/download.feature b/tests/acceptance/features/webUIFiles/download.feature index b052133232a..a4c027da58d 100644 --- a/tests/acceptance/features/webUIFiles/download.feature +++ b/tests/acceptance/features/webUIFiles/download.feature @@ -21,8 +21,17 @@ Feature: download files And as "Alice" file "lorem.txt" should not exist + # don't work in chrome + @skip Scenario: download file with comma in the filename Given user "Alice" has created file "sample,1.txt" When the user has browsed to the files page And the user downloads file "sample,1.txt" using the webUI Then file "sample,1.txt" should be downloaded successfully + + + Scenario: download file + Given user "Alice" has created file "lorem.txt" + When the user browses to the files page + And the user downloads file "lorem.txt" using the webUI + Then file "lorem.txt" should be downloaded successfully diff --git a/tests/acceptance/stepDefinitions/filesContext.js b/tests/acceptance/stepDefinitions/filesContext.js index 89a71ca53c5..e8c01bcd88f 100644 --- a/tests/acceptance/stepDefinitions/filesContext.js +++ b/tests/acceptance/stepDefinitions/filesContext.js @@ -1253,7 +1253,7 @@ Then( ) } Then('file {string} should be downloaded successfully', function(file) { - client.pause(5000) // We should waiting for the file to download + client.pause(2000) // We should waiting for the file to download return client.checkFileExists(path.join(__dirname, '/../download/', file)) }) From 8c389a8dfdaa75d86cf4ce27bb467caae769c78e Mon Sep 17 00:00:00 2001 From: ScharfViktor Date: Mon, 16 Aug 2021 18:20:23 +0200 Subject: [PATCH 3/4] add volume to drone --- .drone.star | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/.drone.star b/.drone.star index 8972ad356a8..ea6ed7518b0 100644 --- a/.drone.star +++ b/.drone.star @@ -1338,6 +1338,9 @@ def acceptance(ctx): # Copy files for upload steps += copyFilesForUpload() + # Add folder download to volume + steps += addDownloadToVolume() + # run the acceptance tests steps += runWebuiAcceptanceTests(ctx, suite, alternateSuiteName, params["filterTags"], params["extraEnvironment"], browser, params["visualTesting"], params["screenShots"]) @@ -1509,6 +1512,9 @@ def browserService(alternateSuiteName, browser): "volumes": [{ "name": "uploads", "path": "/uploads", + }, { + "name": "download", + "path": "/home/seluser/Downloads" }], }] @@ -1519,6 +1525,9 @@ def browserService(alternateSuiteName, browser): "volumes": [{ "name": "uploads", "path": "/uploads", + }, { + "name": "download", + "path": "/home/seluser/Downloads" }], }] @@ -2284,6 +2293,19 @@ def copyFilesForUpload(): }] def runWebuiAcceptanceTests(ctx, suite, alternateSuiteName, filterTags, extraEnvironment, browser, visualTesting, screenShots): + +def addDownloadToVolume(): + return [{ + "name": "add-folder-download", + "pull": "always", + "image": "selenium/standalone-firefox-debug:3.141.59", + "volumes": [{ + "name": "download", + "path": "tests/acceptance/download", + }] + }] + +def runWebuiAcceptanceTests(suite, alternateSuiteName, filterTags, extraEnvironment, browser, visualTesting, screenShots): environment = {} if (filterTags != ""): environment["TEST_TAGS"] = filterTags From 09ac427880d76aa3536b4af50f758bf7fac90e15 Mon Sep 17 00:00:00 2001 From: ScharfViktor Date: Tue, 17 Aug 2021 07:55:41 +0200 Subject: [PATCH 4/4] fix --- .drone.star | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.drone.star b/.drone.star index ea6ed7518b0..b1065a47ff2 100644 --- a/.drone.star +++ b/.drone.star @@ -1514,7 +1514,7 @@ def browserService(alternateSuiteName, browser): "path": "/uploads", }, { "name": "download", - "path": "/home/seluser/Downloads" + "path": "/home/seluser/Downloads", }], }] @@ -1527,7 +1527,7 @@ def browserService(alternateSuiteName, browser): "path": "/uploads", }, { "name": "download", - "path": "/home/seluser/Downloads" + "path": "/home/seluser/Downloads", }], }]