Skip to content

Commit

Permalink
[Tests-Only] Dont crash the test build if dav properties are not found
Browse files Browse the repository at this point in the history
  • Loading branch information
dpakach committed Jul 12, 2021
1 parent 0078b68 commit ce4f630
Showing 1 changed file with 28 additions and 22 deletions.
50 changes: 28 additions & 22 deletions tests/acceptance/helpers/webdavHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,30 +135,36 @@ exports.getTrashBinElements = function(user, depth = 2) {
depth
)
.then(str => {
let trashData = convert.xml2js(str, { compact: true })['d:multistatus']['d:response']
const trashItems = []
// 'trashData' gets object instead of array when there are no any files/folders in the trashbin
// so trashData.map() will cause error if trashData gets object
// following wraps the object in array
if (!Array.isArray(trashData)) {
trashData = [trashData]
}
trashData.forEach(trash => {
if (trash['d:propstat']['d:prop'] === undefined) {
reject(new Error('trashbin data not defined'))
} else {
trashItems.push({
href: trash['d:href']._text,
originalFilename:
try {
let trashData = convert.xml2js(str, { compact: true })['d:multistatus']['d:response']
const trashItems = []
// 'trashData' gets object instead of array when there are no any files/folders in the trashbin
// so trashData.map() will cause error if trashData gets object
// following wraps the object in array
if (!Array.isArray(trashData)) {
trashData = [trashData]
}
console.log(JSON.stringify(trashData))
trashData.forEach(trash => {
if (trash['d:propstat']['d:prop'] === undefined) {
reject(new Error('trashbin data not defined'))
} else {
trashItems.push({
href: trash['d:href']._text,
originalFilename:
trash['d:propstat']['d:prop']['oc:trashbin-original-filename']._text,
originalLocation:
originalLocation:
trash['d:propstat']['d:prop']['oc:trashbin-original-location']._text,
deleteTimestamp: trash['d:propstat']['d:prop']['oc:trashbin-delete-timestamp']._text,
lastModified: trash['d:propstat']['d:prop']['d:getlastmodified']._text
})
}
})
resolve(trashItems)
deleteTimestamp: trash['d:propstat']['d:prop']['oc:trashbin-delete-timestamp']._text,
lastModified: trash['d:propstat']['d:prop']['d:getlastmodified']._text
})
}
})
resolve(trashItems)
} catch (err) {
// Trying to read the nested properties can crash the test
reject(err)
}
})
})
}
Expand Down

0 comments on commit ce4f630

Please sign in to comment.