Skip to content

Commit

Permalink
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 e95da31 commit c70d957
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
})
})
Expand Down

0 comments on commit c70d957

Please sign in to comment.