Skip to content

Commit

Permalink
debug: cypress failure on upload
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <jus@bitgrid.net>

wrap axios promise

Signed-off-by: Julius Härtl <jus@bitgrid.net>

session api refactor

Signed-off-by: Julius Härtl <jus@bitgrid.net>
  • Loading branch information
juliusknorr committed Jun 23, 2023
1 parent 0f9689f commit 2d3943b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 24 deletions.
36 changes: 16 additions & 20 deletions cypress/e2e/api/UsersApi.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,33 +72,29 @@ describe('The user mention API', function() {
})

const invalidRequestData = { ...requestData }
cy.wrap(() => {
invalidRequestData.body = {
...requestData.body,
sessionToken: 'invalid',
}
})
invalidRequestData.body = {
...requestData.body,
sessionToken: 'invalid',
}
cy.request(invalidRequestData).then(({ status }) => {
expect(status).to.eq(403)
})

cy.wrap(() => {
invalidRequestData.body = {
...requestData.body,
sessionId: 0,
}
})
cy.request(invalidRequestData).then(({ status }) => {
const invalidRequestDataId = { ...requestData }
invalidRequestDataId.body = {
...requestData.body,
sessionId: 0,
}
cy.request(invalidRequestDataId).then(({ status }) => {
expect(status).to.eq(403)
})

cy.wrap(() => {
invalidRequestData.body = {
...requestData.body,
documentId: 0,
}
})
cy.request(invalidRequestData).then(({ status }) => {
const invalidRequestDataDocumentId = { ...requestData }
invalidRequestDataDocumentId.body = {
...requestData.body,
sessionId: 0,
}
cy.request(invalidRequestDataDocumentId).then(({ status }) => {
expect(status).to.eq(403)
})

Expand Down
7 changes: 3 additions & 4 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ Cypress.Commands.add('uploadFile', (fileName, mimeType, target) => {
if (typeof target !== 'undefined') {
fileName = target
}
return cy.request('/csrftoken')
.then(({ body }) => body.token)
.then(requesttoken => {
cy.request('/csrftoken')
.then(({ body }) => {
const requesttoken = body.token
return axios.put(`${url}/remote.php/webdav/${fileName}`, file, {
headers: {
requesttoken,
Expand Down Expand Up @@ -111,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 2d3943b

Please sign in to comment.