Skip to content

Commit

Permalink
Merge pull request #5511 from owncloud/dont-crash-on-failure
Browse files Browse the repository at this point in the history
[Tests-Only] Dont crash the test build if dav properties are not found
  • Loading branch information
phil-davis authored Jul 12, 2021
2 parents 0078b68 + b41e74c commit 20ab232
Showing 1 changed file with 30 additions and 23 deletions.
53 changes: 30 additions & 23 deletions tests/acceptance/helpers/webdavHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,30 +135,37 @@ 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:
trash['d:propstat']['d:prop']['oc:trashbin-original-filename']._text,
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
})
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]
}
})
resolve(trashItems)
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:
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)
} catch (err) {
// Trying to read the nested properties can crash the test
reject(err)
}
})
})
}
Expand Down

0 comments on commit 20ab232

Please sign in to comment.