From 111519664d370690b78044e21cd29c54105d8637 Mon Sep 17 00:00:00 2001 From: Jen Jones Arnesen Date: Mon, 23 Oct 2023 15:27:56 +0200 Subject: [PATCH 1/4] chore: allow for both 200 and 201 response from backend --- .../integration/edit/edit_dashboard/show_description.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cypress/integration/edit/edit_dashboard/show_description.js b/cypress/integration/edit/edit_dashboard/show_description.js index 3f059664a..9b7ce046e 100644 --- a/cypress/integration/edit/edit_dashboard/show_description.js +++ b/cypress/integration/edit/edit_dashboard/show_description.js @@ -2,7 +2,8 @@ import { When, Then } from 'cypress-cucumber-preprocessor/steps' import { clickViewActionButton } from '../../../elements/viewDashboard.js' import { getApiBaseUrl } from '../../../support/utils.js' -const SHOW_DESC_RESP_CODE_SUCCESS = 201 +const RESP_CODE_201 = 201 +const RESP_CODE_200 = 200 const SHOW_DESC_RESP_CODE_FAIL = 409 before(() => { @@ -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]) ) }) @@ -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', () => { @@ -38,7 +39,7 @@ 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 From 4261280cb433afd520188c2692a71791f7d799f4 Mon Sep 17 00:00:00 2001 From: Jen Jones Arnesen Date: Mon, 23 Oct 2023 15:47:17 +0200 Subject: [PATCH 2/4] chore: reorder --- cypress/integration/edit/edit_dashboard/show_description.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/integration/edit/edit_dashboard/show_description.js b/cypress/integration/edit/edit_dashboard/show_description.js index 9b7ce046e..007d19f4c 100644 --- a/cypress/integration/edit/edit_dashboard/show_description.js +++ b/cypress/integration/edit/edit_dashboard/show_description.js @@ -2,8 +2,8 @@ import { When, Then } from 'cypress-cucumber-preprocessor/steps' import { clickViewActionButton } from '../../../elements/viewDashboard.js' import { getApiBaseUrl } from '../../../support/utils.js' -const RESP_CODE_201 = 201 const RESP_CODE_200 = 200 +const RESP_CODE_201 = 201 const SHOW_DESC_RESP_CODE_FAIL = 409 before(() => { From a291c3138d1055a24f6cbb0461bd42fdde2ee19b Mon Sep 17 00:00:00 2001 From: Jen Jones Arnesen Date: Mon, 23 Oct 2023 20:13:57 +0200 Subject: [PATCH 3/4] chore: use 200 and 201 as acceptable response status --- .../edit/edit_dashboard/show_description.js | 6 +++--- .../view/view_dashboard/resize_dashboards_bar.js | 15 ++++++++++++--- .../view_dashboard/toggle_show_more_dashboards.js | 6 +++++- .../view_errors/error_while_show_description.js | 10 +++++++--- 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/cypress/integration/edit/edit_dashboard/show_description.js b/cypress/integration/edit/edit_dashboard/show_description.js index 007d19f4c..de6d8d19e 100644 --- a/cypress/integration/edit/edit_dashboard/show_description.js +++ b/cypress/integration/edit/edit_dashboard/show_description.js @@ -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 @@ -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( diff --git a/cypress/integration/view/view_dashboard/resize_dashboards_bar.js b/cypress/integration/view/view_dashboard/resize_dashboards_bar.js index 51a312716..b7419dc36 100644 --- a/cypress/integration/view/view_dashboard/resize_dashboards_bar.js +++ b/cypress/integration/view/view_dashboard/resize_dashboards_bar.js @@ -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') @@ -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', () => { @@ -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', () => { @@ -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]) }) diff --git a/cypress/integration/view/view_dashboard/toggle_show_more_dashboards.js b/cypress/integration/view/view_dashboard/toggle_show_more_dashboards.js index 6f3aed6f7..3b753c9a1 100644 --- a/cypress/integration/view/view_dashboard/toggle_show_more_dashboards.js +++ b/cypress/integration/view/view_dashboard/toggle_show_more_dashboards.js @@ -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', @@ -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', () => { diff --git a/cypress/integration/view/view_errors/error_while_show_description.js b/cypress/integration/view/view_errors/error_while_show_description.js index f3b94adb6..436a3cf20 100644 --- a/cypress/integration/view/view_errors/error_while_show_description.js +++ b/cypress/integration/view/view_errors/error_while_show_description.js @@ -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(() => { @@ -12,12 +16,12 @@ 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() @@ -25,7 +29,7 @@ When('clicking to show description fails', () => { cy.wait('@showDescriptionFails') .its('response.statusCode') - .should('eq', 409) + .should('eq', RESP_CODE_FAIL) }) Then( From b7c328c2eb64f9cbbb341be2d0d7fa20c3f6b3c9 Mon Sep 17 00:00:00 2001 From: Jen Jones Arnesen Date: Tue, 24 Oct 2023 08:40:26 +0200 Subject: [PATCH 4/4] chore: lint --- .../view/view_dashboard/toggle_show_more_dashboards.js | 5 +++-- .../view/view_errors/error_while_show_description.js | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cypress/integration/view/view_dashboard/toggle_show_more_dashboards.js b/cypress/integration/view/view_dashboard/toggle_show_more_dashboards.js index 3b753c9a1..dd9c41852 100644 --- a/cypress/integration/view/view_dashboard/toggle_show_more_dashboards.js +++ b/cypress/integration/view/view_dashboard/toggle_show_more_dashboards.js @@ -12,7 +12,6 @@ const MAX_DASHBOARDS_BAR_HEIGHT = 431 const RESP_CODE_200 = 200 const RESP_CODE_201 = 201 - beforeEach(() => { cy.request({ method: 'PUT', @@ -21,7 +20,9 @@ beforeEach(() => { 'content-type': 'application/json', }, body: '1', - }).then((response) => expect(response.status).to.be.oneOf([RESP_CODE_201, RESP_CODE_200]) + }).then((response) => + expect(response.status).to.be.oneOf([RESP_CODE_201, RESP_CODE_200]) + ) }) When('I toggle show more dashboards', () => { diff --git a/cypress/integration/view/view_errors/error_while_show_description.js b/cypress/integration/view/view_errors/error_while_show_description.js index 436a3cf20..ac6830f01 100644 --- a/cypress/integration/view/view_errors/error_while_show_description.js +++ b/cypress/integration/view/view_errors/error_while_show_description.js @@ -16,7 +16,9 @@ before(() => { 'content-type': 'application/json', }, body: 'false', - }).then((response) => expect(response.status).to.be.oneOf([RESP_CODE_201, RESP_CODE_200]) + }).then((response) => + expect(response.status).to.be.oneOf([RESP_CODE_201, RESP_CODE_200]) + ) }) When('clicking to show description fails', () => {