Skip to content

Commit

Permalink
fixup! fixup! fixup! wrap axios promise
Browse files Browse the repository at this point in the history
  • Loading branch information
juliushaertl committed Jun 23, 2023
1 parent c70d957 commit 4f9f742
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -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))
})
})
})
Expand Down Expand Up @@ -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 = {}) => {
Expand Down

0 comments on commit 4f9f742

Please sign in to comment.