Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tests-Only] Dont crash the test build if dav properties are not found #5511

Merged
merged 1 commit into from
Jul 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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))
phil-davis marked this conversation as resolved.
Show resolved Hide resolved
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