diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 887e258d1ba..2b5c33920ca 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -60,23 +60,24 @@ Cypress.Commands.add('uploadFile', (fileName, mimeType, target) => { if (typeof target !== 'undefined') { fileName = target } - return cy.request('/csrftoken') - .then(async ({ body }) => { + cy.request('/csrftoken') + .then(({ body }) => { const requesttoken = body.token - const response = await axios.put(`${url}/remote.php/webdav/${fileName}`, file, { + return axios.put(`${url}/remote.php/webdav/${fileName}`, file, { headers: { requesttoken, 'Content-Type': mimeType, }, - }) - const fileId = Number( - response.headers['oc-fileid']?.split('oc')?.[0] - ) - cy.log(`Uploaded ${fileName}`, - response.status, - { fileId } - ) - return cy.wrap(fileId) + }).then(response => { + const fileId = Number( + response.headers['oc-fileid']?.split('oc')?.[0] + ) + cy.log(`Uploaded ${fileName}`, + response.status, + { fileId } + ) + return fileId + }).catch(e => cy.log(e.response.data)) }) }) }) @@ -110,7 +111,6 @@ Cypress.Commands.add('createFile', (target, content, mimeType = 'text/markdown') return cy.log(`Uploaded ${fileName}`, response.status) }) - }) Cypress.Commands.add('shareFileToUser', (path, targetUser, shareData = {}) => {