diff --git a/x-pack/plugins/security_solution/cypress/integration/timelines/row_renderers.spec.ts b/x-pack/plugins/security_solution/cypress/integration/timelines/row_renderers.spec.ts index c3e04aaaf6a1f..9986d9d2afbd9 100644 --- a/x-pack/plugins/security_solution/cypress/integration/timelines/row_renderers.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/timelines/row_renderers.spec.ts @@ -63,8 +63,9 @@ describe('Row renderers', () => { cy.get(TIMELINE_ROW_RENDERERS_SEARCHBOX).should('exist'); cy.get(TIMELINE_ROW_RENDERERS_SEARCHBOX).type('flow'); - cy.get(TIMELINE_ROW_RENDERERS_MODAL_ITEMS_CHECKBOX).first().uncheck(); + // Intercepts should be before click handlers that activate them rather than afterwards or you have race conditions cy.intercept('PATCH', '/api/timeline').as('updateTimeline'); + cy.get(TIMELINE_ROW_RENDERERS_MODAL_ITEMS_CHECKBOX).first().uncheck(); cy.wait('@updateTimeline').then((interception) => { expect(interception.request.body.timeline.excludedRowRendererIds).to.contain('netflow'); @@ -84,6 +85,9 @@ describe('Row renderers', () => { cy.get(TIMELINE_ROW_RENDERERS_DISABLE_ALL_BTN).should('exist'); cy.get(TIMELINE_ROW_RENDERERS_MODAL_ITEMS_CHECKBOX).should('be.checked'); + // Intercepts should be before click handlers that activate them rather than afterwards or you have race conditions + cy.intercept('PATCH', '/api/timeline').as('updateTimeline'); + // Keep clicking on the disable all button until the first element of all the elements are no longer checked. // In cases where the click handler is not present on the page just yet, this will cause the button to be clicked // multiple times until it sees that the click took effect. You could go through the whole list but I just check @@ -95,7 +99,6 @@ describe('Row renderers', () => { }) .should('not.be.checked'); - cy.intercept('PATCH', '/api/timeline').as('updateTimeline'); cy.wait('@updateTimeline').its('response.statusCode').should('eq', 200); cy.wait('@updateTimeline').then((interception) => {