Skip to content

Commit

Permalink
Add one more test case
Browse files Browse the repository at this point in the history
  • Loading branch information
VicDeo committed Sep 26, 2019
1 parent a376fa1 commit c480097
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
11 changes: 8 additions & 3 deletions tests/acceptance/features/webUIFiles/copyPrivateLinks.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ Feature: copy current path as a permanent link
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 the permalink of the current folder using the webUI
Then the clipboard content should match current folder permalink
Scenario Outline: Copy permalink to clipboard
When the user browses to the folder <folder_name> on the files page
And the user copies the permalink of the current folder using the webUI
Then the clipboard content should match folder <folder_name> permalink
Examples:
| folder_name |
| "/" |
| "simple-folder" |
17 changes: 13 additions & 4 deletions tests/acceptance/helpers/webdavHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,24 @@ exports.createFile = function (user, fileName, contents = '') {
*
* @param {string} path
* @param {string} userId
* @param {array} requestedProps
* @param {number} folderDepth
*/
exports.getProperties = function (path, userId, requestedProps, folderDepth = 1) {
exports.getProperties = function (path, userId, requestedProps) {
return new Promise((resolve) => {
exports.propfind(`/files/${userId}${path}`, userId, userSettings.getPasswordForUser(userId), requestedProps,
folderDepth)
const trimmedPath = path.replace(/^\/+/, '') // remove a leading slash
const relativePath = `/files/${userId}/${trimmedPath}`
exports.propfind(relativePath, userId, userSettings.getPasswordForUser(userId), requestedProps, 0)
.then(str => {
let propArray
const response = JSON.parse(convert.xml2json(str, { compact: true }))['d:multistatus']['d:response']
if (Array.isArray(response)) {
propArray = response.find(function (e) {
return e['d:href']._text === '/remote.php/dav' + relativePath
})
} else {
propArray = response
}
console.log(propArray)
const properties = {}
requestedProps.map(propertyName => {
properties[propertyName] = response['d:propstat']['d:prop'][propertyName]._text
Expand Down
10 changes: 8 additions & 2 deletions tests/acceptance/stepDefinitions/filesContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -475,12 +475,18 @@ Given('the user has created the following files', function (entryList) {
return client
})

When('the user browses to the folder {string} on the files page', (folderName) => {
const targetFolder = folderName === '/' ? '' : folderName
return client
.page.filesPage()
.navigateAndWaitTillLoaded(targetFolder)
})
When('the user copies the permalink of the current folder using the webUI', function () {
return client.page.filesPage().copyPermalinkFromFilesAppBar()
})
Then('the clipboard content should match current folder permalink', function () {
Then('the clipboard content should match folder {string} permalink', function (folderName) {
return client.getClipBoardContent(function (value) {
webdav.getProperties('/', client.globals.currentUser, ['oc:privatelink'])
webdav.getProperties(folderName, client.globals.currentUser, ['oc:privatelink'])
.then(folderData => {
assert.strictEqual(folderData['oc:privatelink'], value)
})
Expand Down

0 comments on commit c480097

Please sign in to comment.