diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 118a3d194d5..887e258d1ba 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -61,26 +61,22 @@ Cypress.Commands.add('uploadFile', (fileName, mimeType, target) => { fileName = target } return cy.request('/csrftoken') - .then(({ body }) => { - cy.wait(1000) - return cy.wrap(body.token) - }) - .then(requesttoken => { - return cy.wrap(axios.put(`${url}/remote.php/webdav/${fileName}`, file, { + .then(async ({ body }) => { + const requesttoken = body.token + const response = await axios.put(`${url}/remote.php/webdav/${fileName}`, file, { headers: { requesttoken, 'Content-Type': mimeType, }, - }).then(response => { - const fileId = Number( - response.headers['oc-fileid']?.split('oc')?.[0] - ) - cy.log(`Uploaded ${fileName}`, - response.status, - { fileId } - ) - return fileId - })) + }) + const fileId = Number( + response.headers['oc-fileid']?.split('oc')?.[0] + ) + cy.log(`Uploaded ${fileName}`, + response.status, + { fileId } + ) + return cy.wrap(fileId) }) }) })