diff --git a/apps/files/src/components/FilesAppBar.vue b/apps/files/src/components/FilesAppBar.vue index 8f9e9eb3e2f..e4267dc485d 100644 --- a/apps/files/src/components/FilesAppBar.vue +++ b/apps/files/src/components/FilesAppBar.vue @@ -7,7 +7,7 @@ - diff --git a/tests/acceptance/features/webUIFiles/copyCurrentPath.feature b/tests/acceptance/features/webUIFiles/copyCurrentPath.feature new file mode 100644 index 00000000000..3750d680cc9 --- /dev/null +++ b/tests/acceptance/features/webUIFiles/copyCurrentPath.feature @@ -0,0 +1,13 @@ +Feature: copy current path as a permanent link + As a user + I want to copy the permanent link to the current folder + So that I can paste paste it else where + + Background: + Given user "user1" has been created with default attributes + And user "user1" has logged in using the webUI + And the user has browsed to the files page + + Scenario: Copy permalink to clipboard + When the user copies permalink to the current folder + Then the clipboard content should match current folder permalink diff --git a/tests/acceptance/helpers/webdavHelper.js b/tests/acceptance/helpers/webdavHelper.js index 34ec1785b61..df546ab1528 100644 --- a/tests/acceptance/helpers/webdavHelper.js +++ b/tests/acceptance/helpers/webdavHelper.js @@ -167,3 +167,26 @@ exports.createFile = function (user, fileName, contents = '') { .then(res => httpHelper.checkStatus(res, `Could not create the file "${fileName}" for user "${user}".`)) .then(res => res.text()) } + +/** + * Get file or folder properties using webDAV api. + * + * @param {string} path + * @param {string} userId + * @param {array} properties + * @param {number} folderDepth +*/ +exports.getProperties = function (path, userId, properties, folderDepth = 1) { + return new Promise((resolve) => { + exports.propfind(`/files/${userId}${path}`, userId, userSettings.getPasswordForUser(userId), properties, + folderDepth) + .then(str => { + const response = JSON.parse(convert.xml2json(str, { compact: true }))['d:multistatus']['d:response'] + const folderProps = {} + properties.map(propertyName => { + folderProps[propertyName] = response['d:propstat']['d:prop'][propertyName]._text + }) + resolve(folderProps) + }) + }) +} diff --git a/tests/acceptance/pageObjects/filesPage.js b/tests/acceptance/pageObjects/filesPage.js index 4a3d62c7c36..1509a79e610 100644 --- a/tests/acceptance/pageObjects/filesPage.js +++ b/tests/acceptance/pageObjects/filesPage.js @@ -153,6 +153,11 @@ module.exports = { .isVisible(selector, (result) => { callback(result.value) }) + }, + copyPermalink: function () { + return this + .waitForElementVisible('@permalinkCopyButton') + .click('@permalinkCopyButton') } }, elements: { @@ -174,6 +179,9 @@ module.exports = { newFolderOkButton: { selector: '#new-folder-ok' }, + permalinkCopyButton: { + selector: '#files-permalink-copy' + }, breadcrumb: { selector: '#files-breadcrumb li:nth-of-type(2)' }, diff --git a/tests/acceptance/stepDefinitions/filesContext.js b/tests/acceptance/stepDefinitions/filesContext.js index fdf6dd3400c..686c83cb166 100644 --- a/tests/acceptance/stepDefinitions/filesContext.js +++ b/tests/acceptance/stepDefinitions/filesContext.js @@ -474,3 +474,29 @@ Given('the user has created the following files', function (entryList) { }) return client }) + +When('the user copies permalink to the current folder', function () { + client.page.copyPermalink() +}) +Then('the clipboard content should match current folder permalink', function () { + let clipboardContent + client.execute(function () { + var myInput = document.createElement('INPUT') + var inputId = document.createAttribute('id') + inputId.value = 'helperClipboardInput' + myInput.style.position = 'fixed' + myInput.setAttributeNode(inputId) + document.body.appendChild(myInput) + return myInput + }, [], function (result) { + client.click('#helperClipboardInput') + .keys([client.Keys.CONTROL, 'v']) + .getValue('#helperClipboardInput', function (result) { + clipboardContent = result + }) + webdav.getProperties('/', client.globals.currentUser, ['oc:privatelink']) + .then(folderData => { + assert.strictEqual(folderData['oc:privatelink'], clipboardContent) + }) + }) +})