Skip to content

Commit

Permalink
chore: use 200 and 201 as acceptable response status
Browse files Browse the repository at this point in the history
  • Loading branch information
jenniferarnesen committed Oct 23, 2023
1 parent 4261280 commit a291c31
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 10 deletions.
6 changes: 3 additions & 3 deletions cypress/integration/edit/edit_dashboard/show_description.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getApiBaseUrl } from '../../../support/utils.js'

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

before(() => {
//ensure that the description is not currently shown
Expand Down Expand Up @@ -45,14 +45,14 @@ When('I click to hide the description', () => {
// 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
15 changes: 12 additions & 3 deletions cypress/integration/view/view_dashboard/resize_dashboards_bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import {
} from '../../../elements/viewDashboard.js'
import { EXTENDED_TIMEOUT } from '../../../support/utils.js'

const RESP_CODE_200 = 200
const RESP_CODE_201 = 201

// Scenario: I change the height of the control bar
When('I drag to increase the height of the control bar', () => {
cy.intercept('PUT', '/userDataStore/dashboard/controlBarRows').as('putRows')
Expand All @@ -14,7 +17,9 @@ When('I drag to increase the height of the control bar', () => {
.trigger('mousemove', { clientY: 300 })
.trigger('mouseup')

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

Then('the control bar height should be updated', () => {
Expand All @@ -29,7 +34,9 @@ Then('the control bar height should be updated', () => {
.trigger('mousedown')
.trigger('mousemove', { clientY: 71 })
.trigger('mouseup')
cy.wait('@putRows').its('response.statusCode').should('eq', 201)
cy.wait('@putRows')
.its('response.statusCode')
.should('be.oneOf', [RESP_CODE_200, RESP_CODE_201])
})

When('I drag to decrease the height of the control bar', () => {
Expand All @@ -40,5 +47,7 @@ When('I drag to decrease the height of the control bar', () => {
.trigger('mousemove', { clientY: 300 })
.trigger('mouseup')

cy.wait('@putRows').its('response.statusCode').should('eq', 201)
cy.wait('@putRows')
.its('response.statusCode')
.should('be.oneOf', [RESP_CODE_200, RESP_CODE_201])
})
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import { getApiBaseUrl, 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 @@ -17,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
@@ -1,6 +1,10 @@
import { When, Then } from 'cypress-cucumber-preprocessor/steps'
import { getApiBaseUrl } from '../../../support/utils.js'

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

// Error scenario

before(() => {
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 a291c31

Please sign in to comment.