From 4f9f742537953321dc92628487c3c3d24fa79be4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Fri, 23 Jun 2023 12:08:35 +0200 Subject: [PATCH] fixup! fixup! fixup! wrap axios promise --- cypress/support/commands.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) 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 = {}) => {