Skip to content

Commit

Permalink
test(cypress): fix URL matching in intercept
Browse files Browse the repository at this point in the history
  • Loading branch information
edoardo committed Mar 31, 2023
1 parent ec132e2 commit b3e39ac
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 13 deletions.
4 changes: 2 additions & 2 deletions cypress/e2e/edit/edit_dashboard/show_description.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
)

Expand All @@ -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')

Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/edit/edit_dashboard/star_dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/edit/edit_errors/error_during_delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
4 changes: 2 additions & 2 deletions cypress/e2e/edit/edit_errors/error_during_save.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand All @@ -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')
})
8 changes: 6 additions & 2 deletions cypress/e2e/view/view_dashboard/resize_dashboards_bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand All @@ -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 })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/view/view_errors/no_dashboards.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})

Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/view/view_errors/no_edit_access.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down

0 comments on commit b3e39ac

Please sign in to comment.