From 69e81675a0874fb6ced50e7f62a31050420dc43f Mon Sep 17 00:00:00 2001 From: Jen Jones Arnesen Date: Tue, 9 Apr 2024 13:05:10 +0200 Subject: [PATCH] test: allow both 200 and 201 in response [v38] (#2948) * test: allow both 200 and 201 in response * chore: Organisation unit sentence case --- .../common/view/add_a_FILTERTYPE_filter.js | 2 +- .../edit/edit_dashboard/show_description.js | 9 +++++---- cypress/integration/edit/filter_restrict.feature | 4 ++-- .../edit/filter_restrict/filter_restrict.js | 6 +++--- cypress/integration/view/dashboard_filter.feature | 6 +++--- .../view/dashboard_filter/dashboard_filter.js | 6 +++--- .../view/view_dashboard/resize_dashboards_bar.js | 15 ++++++++++++--- .../view_dashboard/toggle_show_more_dashboards.js | 2 +- .../view_errors/error_while_show_description.js | 2 +- 9 files changed, 31 insertions(+), 21 deletions(-) diff --git a/cypress/integration/common/view/add_a_FILTERTYPE_filter.js b/cypress/integration/common/view/add_a_FILTERTYPE_filter.js index 48993c2c8..3e8fc7381 100644 --- a/cypress/integration/common/view/add_a_FILTERTYPE_filter.js +++ b/cypress/integration/common/view/add_a_FILTERTYPE_filter.js @@ -19,7 +19,7 @@ When('I add a {string} filter', dimensionType => { // select an item in the modal if (dimensionType === 'Period') { cy.get(unselectedItemsSel).contains(PERIOD).dblclick() - } else if (dimensionType === 'Organisation Unit') { + } else if (dimensionType === 'Organisation unit') { cy.get(orgUnitTreeSel, EXTENDED_TIMEOUT) .find('[type="checkbox"]', EXTENDED_TIMEOUT) .check(OU_ID) diff --git a/cypress/integration/edit/edit_dashboard/show_description.js b/cypress/integration/edit/edit_dashboard/show_description.js index f6084b1f9..cdea4582f 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' import { getApiBaseUrl } from '../../../support/server/utils' -const SHOW_DESC_RESP_CODE_SUCCESS = 201 +const RESP_CODE_200 = 200 +const RESP_CODE_201 = 201 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 diff --git a/cypress/integration/edit/filter_restrict.feature b/cypress/integration/edit/filter_restrict.feature index 29711c3cb..e616c5df0 100644 --- a/cypress/integration/edit/filter_restrict.feature +++ b/cypress/integration/edit/filter_restrict.feature @@ -17,11 +17,11 @@ Feature: Editing Filter Restrictions Then Filter Restrictions are not restricted @nonmutating - Scenario: I see Period and Organisation Unit if newly choosing to restrict dimensions + Scenario: I see Period and Organisation unit if newly choosing to restrict dimensions Given I open an existing dashboard with non-restricted Filter settings in edit mode And I click on Filter settings And I click to restrict Filter settings - Then Period and Organisation Unit are displayed as selected by default + Then Period and Organisation unit are displayed as selected by default @nonmutating Scenario: I change Filter Restrictions and the changes persist while editing Filter settings diff --git a/cypress/integration/edit/filter_restrict/filter_restrict.js b/cypress/integration/edit/filter_restrict/filter_restrict.js index be962cf42..453584c8e 100644 --- a/cypress/integration/edit/filter_restrict/filter_restrict.js +++ b/cypress/integration/edit/filter_restrict/filter_restrict.js @@ -75,17 +75,17 @@ Then('Filter Restrictions are not restricted', () => { }) /* -Scenario: I see Period and Organisation Unit if newly choosing to restrict dimensions +Scenario: I see Period and Organisation unit if newly choosing to restrict dimensions */ Then( - 'Period and Organisation Unit are displayed as selected by default', + 'Period and Organisation unit are displayed as selected by default', () => { cy.get('[data-test="dhis2-uicore-transfer-rightside"]') .contains('Period') .should('be.visible') cy.get('[data-test="dhis2-uicore-transfer-rightside"]') - .contains('Organisation Unit') + .contains('Organisation unit') .should('be.visible') } ) diff --git a/cypress/integration/view/dashboard_filter.feature b/cypress/integration/view/dashboard_filter.feature index 00c1fcf8e..b40594040 100644 --- a/cypress/integration/view/dashboard_filter.feature +++ b/cypress/integration/view/dashboard_filter.feature @@ -7,11 +7,11 @@ Feature: Dashboard filter When I add a "Period" filter Then the Period filter is applied to the dashboard - Scenario: I add a Organisation Unit filter + Scenario: I add a Organisation unit filter Given I open existing dashboard Then the dashboard displays in view mode - When I add a "Organisation Unit" filter - Then the Organisation Unit filter is applied to the dashboard + When I add a "Organisation unit" filter + Then the Organisation unit filter is applied to the dashboard Scenario: I add a Facility Type filter Given I open existing dashboard diff --git a/cypress/integration/view/dashboard_filter/dashboard_filter.js b/cypress/integration/view/dashboard_filter/dashboard_filter.js index d59db80f3..2b80d1df0 100644 --- a/cypress/integration/view/dashboard_filter/dashboard_filter.js +++ b/cypress/integration/view/dashboard_filter/dashboard_filter.js @@ -42,12 +42,12 @@ Then('the Period filter is applied to the dashboard', () => { }) /* -Scenario: I add an Organisation Unit filter +Scenario: I add an Organisation init filter */ -Then('the Organisation Unit filter is applied to the dashboard', () => { +Then('the Organisation unit filter is applied to the dashboard', () => { cy.get(filterBadgeSel) - .contains(`Organisation Unit: ${OU}`) + .contains(`Organisation unit: ${OU}`) .should('be.visible') cy.get(innerScrollContainerSel).scrollTo('bottom') diff --git a/cypress/integration/view/view_dashboard/resize_dashboards_bar.js b/cypress/integration/view/view_dashboard/resize_dashboards_bar.js index f3f10bc0e..d6803afff 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' import { EXTENDED_TIMEOUT } from '../../../support/utils' +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') @@ -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', () => { @@ -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', () => { @@ -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]) }) 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 b08e0cb8a..5c98255dd 100644 --- a/cypress/integration/view/view_dashboard/toggle_show_more_dashboards.js +++ b/cypress/integration/view/view_dashboard/toggle_show_more_dashboards.js @@ -18,7 +18,7 @@ beforeEach(() => { 'content-type': 'application/json', }, body: '1', - }).then(response => expect(response.status).to.equal(201)) + }).then(response => expect(response.status).to.be.oneOf([200, 201])) }) 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 07e09ffd3..f46d9740d 100644 --- a/cypress/integration/view/view_errors/error_while_show_description.js +++ b/cypress/integration/view/view_errors/error_while_show_description.js @@ -12,7 +12,7 @@ before(() => { 'content-type': 'application/json', }, body: 'false', - }).then(response => expect(response.status).to.equal(201)) + }).then(response => expect(response.status).to.be.oneOf([200, 201])) }) When('clicking to show description fails', () => {