Skip to content

Commit

Permalink
fix: allow both 200 and 201 since backend is flaky on this
Browse files Browse the repository at this point in the history
  • Loading branch information
jenniferarnesen committed Apr 5, 2024
1 parent f02ecc2 commit 3d536a7
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 23 deletions.
21 changes: 11 additions & 10 deletions cypress/integration/edit/edit_dashboard/show_description.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { When, Then } from 'cypress-cucumber-preprocessor/steps'
import { clickViewActionButton } from '../../../elements/viewDashboard'
import { getApiBaseUrl } from '../../../support/server/utils'
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 @@ -14,8 +15,8 @@ before(() => {
'content-type': 'application/json',
},
body: 'false',
}).then(response =>
expect(response.status).to.equal(SHOW_DESC_RESP_CODE_SUCCESS)
}).then((response) =>
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)
.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
19 changes: 14 additions & 5 deletions cypress/integration/view/view_dashboard/resize_dashboards_bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ import { When, Then } from 'cypress-cucumber-preprocessor/steps'
import {
dragHandleSel,
dashboardsBarSel,
} from '../../../elements/viewDashboard'
import { EXTENDED_TIMEOUT } from '../../../support/utils'
} 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', () => {
Expand All @@ -13,7 +16,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 @@ -27,7 +32,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 @@ -37,5 +44,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 @@ -3,13 +3,16 @@ import {
dashboardTitleSel,
dashboardsBarContainerSel,
showMoreLessSel,
} from '../../../elements/viewDashboard'
import { getApiBaseUrl } from '../../../support/server/utils'
import { EXTENDED_TIMEOUT } from '../../../support/utils'
} from '../../../elements/viewDashboard.js'
import { getApiBaseUrl } from '../../../support/server/utils.js'
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
@@ -1,7 +1,9 @@
import { When, Then } from 'cypress-cucumber-preprocessor/steps'
import { getApiBaseUrl } from '../../../support/server/utils'
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
Expand All @@ -12,7 +14,7 @@ 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', () => {
Expand All @@ -25,7 +27,7 @@ When('clicking to show description fails', () => {

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

Then(
Expand Down

0 comments on commit 3d536a7

Please sign in to comment.