From b3e39ac43695fb9ad7d7ed54bad46144e3e36bbb Mon Sep 17 00:00:00 2001 From: Edoardo Sabadelli Date: Fri, 31 Mar 2023 15:32:21 +0200 Subject: [PATCH] test(cypress): fix URL matching in intercept --- cypress/e2e/edit/edit_dashboard/show_description.js | 4 ++-- cypress/e2e/edit/edit_dashboard/star_dashboard.js | 4 ++-- cypress/e2e/edit/edit_errors/error_during_delete.js | 2 +- cypress/e2e/edit/edit_errors/error_during_save.js | 4 ++-- cypress/e2e/view/view_dashboard/resize_dashboards_bar.js | 8 ++++++-- .../e2e/view/view_errors/error_while_show_description.js | 2 +- .../view/view_errors/error_while_starring_dashboard.js | 2 +- cypress/e2e/view/view_errors/no_dashboards.js | 2 +- cypress/e2e/view/view_errors/no_edit_access.js | 2 +- 9 files changed, 17 insertions(+), 13 deletions(-) diff --git a/cypress/e2e/edit/edit_dashboard/show_description.js b/cypress/e2e/edit/edit_dashboard/show_description.js index 2a35ff2e1..7cf5e9aa2 100644 --- a/cypress/e2e/edit/edit_dashboard/show_description.js +++ b/cypress/e2e/edit/edit_dashboard/show_description.js @@ -20,7 +20,7 @@ before(() => { }) When('I click to show description', () => { - cy.intercept('PUT', 'userDataStore/dashboard/showDescription').as( + cy.intercept('PUT', '**/userDataStore/dashboard/showDescription').as( 'toggleDescription' ) @@ -43,7 +43,7 @@ When('I click to hide the description', () => { // Error scenario When('clicking to show description fails', () => { - cy.intercept('PUT', 'userDataStore/dashboard/showDescription', { + cy.intercept('PUT', '**/userDataStore/dashboard/showDescription', { statusCode: SHOW_DESC_RESP_CODE_FAIL, }).as('showDescriptionFails') diff --git a/cypress/e2e/edit/edit_dashboard/star_dashboard.js b/cypress/e2e/edit/edit_dashboard/star_dashboard.js index 7b9cde5cd..df8ed49e0 100644 --- a/cypress/e2e/edit/edit_dashboard/star_dashboard.js +++ b/cypress/e2e/edit/edit_dashboard/star_dashboard.js @@ -10,14 +10,14 @@ import { TEST_DASHBOARD_TITLE } from './edit_dashboard.js' // Scenario: I star the dashboard When('I click to star the dashboard', () => { - cy.intercept('POST', `/favorite`).as('starDashboard') + cy.intercept('POST', '**/favorite').as('starDashboard') cy.get(starSel).click() cy.wait('@starDashboard').its('response.statusCode').should('eq', 200) }) When('I click to unstar the dashboard', () => { - cy.intercept('DELETE', `/favorite`).as('unstarDashboard') + cy.intercept('DELETE', '**/favorite').as('unstarDashboard') cy.get(starSel).click() cy.wait('@unstarDashboard').its('response.statusCode').should('eq', 200) diff --git a/cypress/e2e/edit/edit_errors/error_during_delete.js b/cypress/e2e/edit/edit_errors/error_during_delete.js index 9baa0796b..211b27495 100644 --- a/cypress/e2e/edit/edit_errors/error_during_delete.js +++ b/cypress/e2e/edit/edit_errors/error_during_delete.js @@ -5,7 +5,7 @@ import { } from '../../../elements/editDashboard.js' When('A 500 error is thrown when I delete the dashboard', () => { - cy.intercept('DELETE', '/dashboards', { statusCode: 500 }) + cy.intercept('DELETE', '**/dashboards', { statusCode: 500 }) clickEditActionButton('Delete') cy.get(confirmActionDialogSel).find('button').contains('Delete').click() }) diff --git a/cypress/e2e/edit/edit_errors/error_during_save.js b/cypress/e2e/edit/edit_errors/error_during_save.js index ac1dca053..c33112c61 100644 --- a/cypress/e2e/edit/edit_errors/error_during_save.js +++ b/cypress/e2e/edit/edit_errors/error_during_save.js @@ -2,7 +2,7 @@ import { When, Then } from '@badeball/cypress-cucumber-preprocessor' import { clickEditActionButton } from '../../../elements/editDashboard.js' When("I save dashboard that I don't have access to save", () => { - cy.intercept('PUT', '/dashboards', { statusCode: 409 }) + cy.intercept('PUT', '**/dashboards', { statusCode: 409 }) clickEditActionButton('Save changes') }) Then('I remain in edit mode and error message is displayed', () => { @@ -14,6 +14,6 @@ Then('I remain in edit mode and error message is displayed', () => { }) When('A 500 error is thrown when I save the dashboard', () => { - cy.intercept('PUT', '/dashboards', { statusCode: 500 }) + cy.intercept('PUT', '**/dashboards', { statusCode: 500 }) clickEditActionButton('Save changes') }) diff --git a/cypress/e2e/view/view_dashboard/resize_dashboards_bar.js b/cypress/e2e/view/view_dashboard/resize_dashboards_bar.js index 6affa6e79..aa4f1d492 100644 --- a/cypress/e2e/view/view_dashboard/resize_dashboards_bar.js +++ b/cypress/e2e/view/view_dashboard/resize_dashboards_bar.js @@ -7,7 +7,9 @@ import { EXTENDED_TIMEOUT } from '../../../support/utils.js' // 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') + cy.intercept('PUT', '**/userDataStore/dashboard/controlBarRows').as( + 'putRows' + ) cy.get(dragHandleSel, EXTENDED_TIMEOUT) .trigger('mousedown') .trigger('mousemove', { clientY: 300 }) @@ -31,7 +33,9 @@ Then('the control bar height should be updated', () => { }) When('I drag to decrease the height of the control bar', () => { - cy.intercept('PUT', '/userDataStore/dashboard/controlBarRows').as('putRows') + cy.intercept('PUT', '**/userDataStore/dashboard/controlBarRows').as( + 'putRows' + ) cy.get(dragHandleSel, EXTENDED_TIMEOUT) .trigger('mousedown') .trigger('mousemove', { clientY: 300 }) diff --git a/cypress/e2e/view/view_errors/error_while_show_description.js b/cypress/e2e/view/view_errors/error_while_show_description.js index 4b58e2515..00f23b4c0 100644 --- a/cypress/e2e/view/view_errors/error_while_show_description.js +++ b/cypress/e2e/view/view_errors/error_while_show_description.js @@ -16,7 +16,7 @@ before(() => { }) When('clicking to show description fails', () => { - cy.intercept('PUT', 'userDataStore/dashboard/showDescription', { + cy.intercept('PUT', /userDataStore\/dashboard\/showDescription/, { statusCode: 409, }).as('showDescriptionFails') diff --git a/cypress/e2e/view/view_errors/error_while_starring_dashboard.js b/cypress/e2e/view/view_errors/error_while_starring_dashboard.js index 451e21081..165d919ba 100644 --- a/cypress/e2e/view/view_errors/error_while_starring_dashboard.js +++ b/cypress/e2e/view/view_errors/error_while_starring_dashboard.js @@ -9,7 +9,7 @@ import { When('clicking to star {string} dashboard fails', (title) => { cy.log('url', `dashboards/${dashboards[title].id}/favorite`) - cy.intercept('POST', `dashboards/${dashboards[title].id}/favorite`, { + cy.intercept('POST', `**/dashboards/${dashboards[title].id}/favorite`, { statusCode: 409, }).as('starDashboardFail') diff --git a/cypress/e2e/view/view_errors/no_dashboards.js b/cypress/e2e/view/view_errors/no_dashboards.js index 08389d661..620b83c1b 100644 --- a/cypress/e2e/view/view_errors/no_dashboards.js +++ b/cypress/e2e/view/view_errors/no_dashboards.js @@ -4,7 +4,7 @@ import { EXTENDED_TIMEOUT } from '../../../support/utils.js' // Scenario: There are no dashboards Given('I open an app with no dashboards', () => { - cy.intercept('/dashboards', { dashboards: [] }) + cy.intercept('**/dashboards?*', { body: { dashboards: [] } }) cy.visit('/', EXTENDED_TIMEOUT) }) diff --git a/cypress/e2e/view/view_errors/no_edit_access.js b/cypress/e2e/view/view_errors/no_edit_access.js index ecc8a1717..3233fe00f 100644 --- a/cypress/e2e/view/view_errors/no_edit_access.js +++ b/cypress/e2e/view/view_errors/no_edit_access.js @@ -3,7 +3,7 @@ import { dashboards } from '../../../assets/backends/index.js' import { EXTENDED_TIMEOUT } from '../../../support/utils.js' Given('I open a non-editable dashboard in edit mode', () => { - cy.intercept(`/dashboards/${dashboards.Delivery.id}`, (req) => { + cy.intercept(`**/dashboards/${dashboards.Delivery.id}?*`, (req) => { req.reply((res) => { const noAccessResponse = Object.assign({}, res.body, { access: { update: false, delete: false },