diff --git a/cypress/integration/1_detectors.spec.js b/cypress/integration/1_detectors.spec.js index 17e97594e..6a08e3852 100644 --- a/cypress/integration/1_detectors.spec.js +++ b/cypress/integration/1_detectors.spec.js @@ -474,6 +474,40 @@ describe('Detectors', () => { validateFieldMappingsTable('rules are changed'); }); + it('...can be stopped and started back from detectors list action menu', () => { + cy.wait(1000); + cy.get('tbody > tr') + .first() + .within(() => { + cy.get('[class="euiCheckbox__input"]').click({ force: true }); + }); + + // Waiting for Actions menu button to be enabled + cy.wait(1000); + + setupIntercept(cy, '/_plugins/_security_analytics/detectors/_search', 'detectorsSearch'); + + cy.get('[data-test-subj="detectorsActionsButton').click({ force: true }); + cy.get('[data-test-subj="toggleDetectorButton').contains('Stop'); + cy.get('[data-test-subj="toggleDetectorButton').click({ force: true }); + + cy.wait('@detectorsSearch').should('have.property', 'state', 'Complete'); + // Need this extra wait time for the Actions button to become enabled again + cy.wait(1000); + + setupIntercept(cy, '/_plugins/_security_analytics/detectors/_search', 'detectorsSearch'); + cy.get('[data-test-subj="detectorsActionsButton').click({ force: true }); + cy.get('[data-test-subj="toggleDetectorButton').contains('Start'); + cy.get('[data-test-subj="toggleDetectorButton').click({ force: true }); + + cy.wait('@detectorsSearch').should('have.property', 'state', 'Complete'); + // Need this extra wait time for the Actions button to become enabled again + cy.wait(1000); + + cy.get('[data-test-subj="detectorsActionsButton').click({ force: true }); + cy.get('[data-test-subj="toggleDetectorButton').contains('Stop'); + }); + it('...can be deleted', () => { setupIntercept(cy, '/rules/_search', 'getRules'); diff --git a/public/pages/Detectors/containers/Detectors/Detectors.tsx b/public/pages/Detectors/containers/Detectors/Detectors.tsx index df7fb0296..3533c7897 100644 --- a/public/pages/Detectors/containers/Detectors/Detectors.tsx +++ b/public/pages/Detectors/containers/Detectors/Detectors.tsx @@ -122,8 +122,12 @@ export default class Detectors extends Component } catch (e: any) { errorNotificationToast(notifications, 'update', 'detector', e); } - this.getDetectors(); - this.setState({ loadingDetectors: false }); + await this.getDetectors(); + const selectedItemIds = new Set(this.state.selectedItems.map(({ _id }) => _id)); + const updatedSelectedItems: DetectorHit[] = this.state.detectorHits.filter((hit) => + selectedItemIds.has(hit._id) + ); + this.setState({ loadingDetectors: false, selectedItems: updatedSelectedItems }); }; onClickDelete = async () => {