Skip to content

Commit

Permalink
chore: allow both 200 and 201 response
Browse files Browse the repository at this point in the history
  • Loading branch information
jenniferarnesen committed Apr 8, 2024
1 parent de1c94c commit 69060aa
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
15 changes: 8 additions & 7 deletions cypress/integration/edit/edit_dashboard/show_description.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import { When, Then } from 'cypress-cucumber-preprocessor/steps'
import { clickViewActionButton } from '../../../elements/viewDashboard.js'
import { getApiBaseUrl } from '../../../support/server/utils.js'

const SHOW_DESC_RESP_CODE_SUCCESS = 201
const SHOW_DESC_RESP_CODE_FAIL = 409
const RESP_CODE_200 = 200
const RESP_CODE_201 = 201
const RESP_CODE_FAIL = 409

before(() => {
//ensure that the description is not currently shown
Expand All @@ -15,7 +16,7 @@ before(() => {
},
body: 'false',
}).then((response) =>
expect(response.status).to.equal(SHOW_DESC_RESP_CODE_SUCCESS)
expect(response.status).to.be.oneOf([RESP_CODE_201, RESP_CODE_200])
)
})

Expand All @@ -29,7 +30,7 @@ When('I click to show description', () => {

cy.wait('@toggleDescription')
.its('response.statusCode')
.should('eq', SHOW_DESC_RESP_CODE_SUCCESS)
.sho.should('be.oneOf', [RESP_CODE_200, RESP_CODE_201])
})

When('I click to hide the description', () => {
Expand All @@ -38,20 +39,20 @@ When('I click to hide the description', () => {

cy.wait('@toggleDescription')
.its('response.statusCode')
.should('eq', SHOW_DESC_RESP_CODE_SUCCESS)
.should('be.oneOf', [RESP_CODE_200, RESP_CODE_201])
})

// Error scenario
When('clicking to show description fails', () => {
cy.intercept('PUT', 'userDataStore/dashboard/showDescription', {
statusCode: SHOW_DESC_RESP_CODE_FAIL,
statusCode: RESP_CODE_FAIL,
}).as('showDescriptionFails')

clickViewActionButton('More')
cy.contains('Show description').click()
cy.wait('@showDescriptionFails')
.its('response.statusCode')
.should('eq', SHOW_DESC_RESP_CODE_FAIL)
.should('eq', RESP_CODE_FAIL)
})

Then(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import { EXTENDED_TIMEOUT } from '../../../support/utils.js'
const MIN_DASHBOARDS_BAR_HEIGHT = 71
const MAX_DASHBOARDS_BAR_HEIGHT = 431

const RESP_CODE_200 = 200
const RESP_CODE_201 = 201

beforeEach(() => {
cy.request({
method: 'PUT',
Expand All @@ -18,7 +21,7 @@ beforeEach(() => {
'content-type': 'application/json',
},
body: '1',
}).then((response) => expect(response.status).to.equal(201))
}).then((response) => expect(response.status).to.be.oneOf([RESP_CODE_201, RESP_CODE_200])
})

When('I toggle show more dashboards', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import { getApiBaseUrl } from '../../../support/server/utils.js'

// Error scenario

const RESP_CODE_200 = 200
const RESP_CODE_201 = 201
const RESP_CODE_FAIL = 409

before(() => {
//first ensure that the description is not currently shown
cy.request({
Expand All @@ -12,20 +16,20 @@ before(() => {
'content-type': 'application/json',
},
body: 'false',
}).then((response) => expect(response.status).to.equal(201))
}).then((response) => expect(response.status).to.be.oneOf([RESP_CODE_201, RESP_CODE_200])
})

When('clicking to show description fails', () => {
cy.intercept('PUT', 'userDataStore/dashboard/showDescription', {
statusCode: 409,
statusCode: RESP_CODE_FAIL,
}).as('showDescriptionFails')

cy.get('button').contains('More').click()
cy.contains('Show description').click()

cy.wait('@showDescriptionFails')
.its('response.statusCode')
.should('eq', 409)
.should('eq', RESP_CODE_FAIL)
})

Then(
Expand Down

0 comments on commit 69060aa

Please sign in to comment.