Skip to content

Commit

Permalink
Not working yet...
Browse files Browse the repository at this point in the history
  • Loading branch information
VicDeo committed Sep 25, 2019
1 parent 13bbf2c commit 73ce873
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 1 deletion.
2 changes: 1 addition & 1 deletion apps/files/src/components/FilesAppBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<oc-breadcrumb id="files-breadcrumb" :items="breadcrumbs" v-if="showBreadcrumb" home></oc-breadcrumb>
<span class="uk-margin-small-left" v-if="showBreadcrumb && currentFolder.privateLink">
<oc-icon name="ready" v-show="linkCopied" />
<oc-icon name="link" v-clipboard="() => currentFolder.privateLink"
<oc-icon id="files-permalink-copy" name="link" v-clipboard="() => currentFolder.privateLink"
v-show="!linkCopied"
v-clipboard:success="clipboardSuccessHandler"
/>
Expand Down
13 changes: 13 additions & 0 deletions tests/acceptance/features/webUIFiles/copyCurrentPath.feature
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions tests/acceptance/helpers/webdavHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
})
}
8 changes: 8 additions & 0 deletions tests/acceptance/pageObjects/filesPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ module.exports = {
.isVisible(selector, (result) => {
callback(result.value)
})
},
copyPermalink: function () {
return this
.waitForElementVisible('@permalinkCopyButton')
.click('@permalinkCopyButton')
}
},
elements: {
Expand All @@ -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)'
},
Expand Down
26 changes: 26 additions & 0 deletions tests/acceptance/stepDefinitions/filesContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
})
})

0 comments on commit 73ce873

Please sign in to comment.