Skip to content

Commit

Permalink
test(api): Try different approach of chaining api calls
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliusknorr committed Jun 13, 2023
1 parent 61e0420 commit 858fba0
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions cypress/e2e/api/UsersApi.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ describe('The user mention API', function() {
cy.wrap(connection)
.its('document.id')
.should('equal', fileId)

const requestData = {
method: 'POST',
url: '/apps/text/api/v1/users',
Expand All @@ -66,43 +67,39 @@ describe('The user mention API', function() {
},
failOnStatusCode: false,
}
const invalidRequestData = { ...requestData }

cy.request(requestData).then(({ status }) => {
expect(status).to.eq(200)
})

const invalidRequestData = { ...requestData }
cy.wrap(() => {
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 }) => {
expect(status).to.eq(403)
})

cy.wrap(() => {
invalidRequestData.body = {
...requestData.body,
documentId: 0,
}
})

cy.request(invalidRequestData).then(({ status }) => {
expect(status).to.eq(403)
})

cy.wrap(connection.close())
cy.wrap(null).then(() => connection.close())

cy.request(requestData).then(({ status, body }) => {
expect(status).to.eq(403)
Expand Down

0 comments on commit 858fba0

Please sign in to comment.