diff --git a/tests/acceptance/helpers/webdavHelper.js b/tests/acceptance/helpers/webdavHelper.js index 76dae8018e1..86383f9e643 100644 --- a/tests/acceptance/helpers/webdavHelper.js +++ b/tests/acceptance/helpers/webdavHelper.js @@ -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) + } }) }) }