Skip to content

Commit

Permalink
Extract into getClipBoardContent method
Browse files Browse the repository at this point in the history
  • Loading branch information
VicDeo committed Sep 25, 2019
1 parent da3d91c commit a376fa1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
22 changes: 22 additions & 0 deletions tests/acceptance/customCommands/getClipBoardContent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
exports.command = function (callback) {
const helperElementId = 'helperClipboardInput'
this.execute(function (elementId) {
const myInput = document.createElement('INPUT')
const inputId = document.createAttribute('id')
inputId.value = elementId
myInput.setAttributeNode(inputId)
myInput.setAttribute('style', 'position: absolute; left:0; top:0;') // make sure its visible
document.body.appendChild(myInput)
}, [helperElementId])
.setValue(`#${helperElementId}`, '') // just to focus the element
.keys([this.Keys.CONTROL, 'v']) // copy the content of the clipboard into that field
.getValue(`#${helperElementId}`, function (clipboard) {
callback(clipboard.value)
})
.execute(function (elementId) {
const el = document.getElementById(elementId)
el.parentNode.removeChild(el)
}, [helperElementId])

return this
}
23 changes: 5 additions & 18 deletions tests/acceptance/stepDefinitions/filesContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -479,23 +479,10 @@ When('the user copies the permalink of the current folder using the webUI', func
return client.page.filesPage().copyPermalinkFromFilesAppBar()
})
Then('the clipboard content should match current folder permalink', function () {
return client.execute(function () {
const myInput = document.createElement('INPUT')
const inputId = document.createAttribute('id')
inputId.value = 'helperClipboardInput'
myInput.setAttributeNode(inputId)
myInput.setAttribute('style', 'position: absolute; left:0; top:0;') // make sure its visible
document.body.appendChild(myInput)
return client.getClipBoardContent(function (value) {
webdav.getProperties('/', client.globals.currentUser, ['oc:privatelink'])
.then(folderData => {
assert.strictEqual(folderData['oc:privatelink'], value)
})
})
.setValue('#helperClipboardInput', '') // just to focus the element
.keys([client.Keys.CONTROL, 'v']) // copy the content of the clipboard into that field
.getValue('#helperClipboardInput', function (clipboard) {
console.log('clipboardValue ' + clipboard.value)
const clipboardContent = clipboard.value
webdav.getProperties('/', client.globals.currentUser, ['oc:privatelink'])
.then(folderData => {
console.log(folderData)
client.assert.equal(folderData.privateLink, clipboardContent)
})
})
})

0 comments on commit a376fa1

Please sign in to comment.