Skip to content

Commit

Permalink
fixes alerts flaky test (#78424)
Browse files Browse the repository at this point in the history
Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
MadameSheema and elasticmachine committed Sep 24, 2020
1 parent f712cda commit 05cbf6b
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 36 deletions.
67 changes: 34 additions & 33 deletions x-pack/plugins/security_solution/cypress/integration/alerts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ import { loginAndWaitForPage } from '../tasks/login';

import { DETECTIONS_URL } from '../urls/navigation';

// FLAKY: https://github.com/elastic/kibana/issues/77957
describe.skip('Alerts', () => {
describe('Alerts', () => {
context('Closing alerts', () => {
beforeEach(() => {
esArchiverLoad('alerts');
Expand Down Expand Up @@ -141,20 +140,20 @@ describe.skip('Alerts', () => {
waitForAlerts();

const expectedNumberOfAlerts = +numberOfAlerts - numberOfAlertsToBeClosed;
cy.get(NUMBER_OF_ALERTS).invoke('text').should('eq', expectedNumberOfAlerts.toString());
cy.get(SHOWING_ALERTS)
.invoke('text')
.should('eql', `Showing ${expectedNumberOfAlerts.toString()} alerts`);
cy.get(NUMBER_OF_ALERTS).should('have.text', expectedNumberOfAlerts.toString());
cy.get(SHOWING_ALERTS).should(
'have.text',
`Showing ${expectedNumberOfAlerts.toString()} alerts`
);

goToClosedAlerts();
waitForAlerts();

cy.get(NUMBER_OF_ALERTS)
.invoke('text')
.should('eql', numberOfAlertsToBeClosed.toString());
cy.get(SHOWING_ALERTS)
.invoke('text')
.should('eql', `Showing ${numberOfAlertsToBeClosed.toString()} alert`);
cy.get(NUMBER_OF_ALERTS).should('have.text', numberOfAlertsToBeClosed.toString());
cy.get(SHOWING_ALERTS).should(
'have.text',
`Showing ${numberOfAlertsToBeClosed.toString()} alert`
);
cy.get(ALERTS).should('have.length', numberOfAlertsToBeClosed);
});
});
Expand Down Expand Up @@ -187,20 +186,20 @@ describe.skip('Alerts', () => {
waitForAlerts();

const expectedNumberOfAlerts = +numberOfAlerts - numberOfAlertsToBeOpened;
cy.get(NUMBER_OF_ALERTS).invoke('text').should('eq', expectedNumberOfAlerts.toString());
cy.get(SHOWING_ALERTS)
.invoke('text')
.should('eql', `Showing ${expectedNumberOfAlerts.toString()} alerts`);
cy.get(NUMBER_OF_ALERTS).should('have.text', expectedNumberOfAlerts.toString());
cy.get(SHOWING_ALERTS).should(
'have.text',
`Showing ${expectedNumberOfAlerts.toString()} alerts`
);

goToOpenedAlerts();
waitForAlerts();

cy.get(NUMBER_OF_ALERTS)
.invoke('text')
.should('eql', numberOfAlertsToBeOpened.toString());
cy.get(SHOWING_ALERTS)
.invoke('text')
.should('eql', `Showing ${numberOfAlertsToBeOpened.toString()} alert`);
cy.get(NUMBER_OF_ALERTS).should('have.text', numberOfAlertsToBeOpened.toString());
cy.get(SHOWING_ALERTS).should(
'have.text',
`Showing ${numberOfAlertsToBeOpened.toString()} alert`
);
cy.get(ALERTS).should('have.length', numberOfAlertsToBeOpened);
});
});
Expand Down Expand Up @@ -229,23 +228,25 @@ describe.skip('Alerts', () => {
cy.reload();
goToOpenedAlerts();
waitForAlertsToBeLoaded();
waitForAlerts();

const expectedNumberOfAlerts = +numberOfAlerts - numberOfAlertsToBeMarkedInProgress;
cy.get(NUMBER_OF_ALERTS).invoke('text').should('eq', expectedNumberOfAlerts.toString());
cy.get(SHOWING_ALERTS)
.invoke('text')
.should('eql', `Showing ${expectedNumberOfAlerts.toString()} alerts`);
cy.get(NUMBER_OF_ALERTS).should('have.text', expectedNumberOfAlerts.toString());
cy.get(SHOWING_ALERTS).should(
'have.text',
`Showing ${expectedNumberOfAlerts.toString()} alerts`
);

goToInProgressAlerts();
waitForAlerts();

cy.get(NUMBER_OF_ALERTS)
.invoke('text')
.should('eql', numberOfAlertsToBeMarkedInProgress.toString());
cy.get(SHOWING_ALERTS)
.invoke('text')
.should('eql', `Showing ${numberOfAlertsToBeMarkedInProgress.toString()} alert`);
cy.get(NUMBER_OF_ALERTS).should(
'have.text',
numberOfAlertsToBeMarkedInProgress.toString()
);
cy.get(SHOWING_ALERTS).should(
'have.text',
`Showing ${numberOfAlertsToBeMarkedInProgress.toString()} alert`
);
cy.get(ALERTS).should('have.length', numberOfAlertsToBeMarkedInProgress);
});
});
Expand Down
6 changes: 3 additions & 3 deletions x-pack/plugins/security_solution/cypress/tasks/alerts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const expandFirstAlert = () => {
};

export const goToClosedAlerts = () => {
cy.get(CLOSED_ALERTS_FILTER_BTN).click({ force: true });
cy.get(CLOSED_ALERTS_FILTER_BTN).click();
};

export const goToManageAlertsDetectionRules = () => {
Expand All @@ -62,7 +62,7 @@ export const openAlerts = () => {
};

export const goToInProgressAlerts = () => {
cy.get(IN_PROGRESS_ALERTS_FILTER_BTN).click({ force: true });
cy.get(IN_PROGRESS_ALERTS_FILTER_BTN).click();
};

export const markInProgressFirstAlert = () => {
Expand All @@ -86,7 +86,7 @@ export const investigateFirstAlertInTimeline = () => {
};

export const waitForAlerts = () => {
cy.get(REFRESH_BUTTON).invoke('text').should('not.equal', 'Updating');
cy.get(REFRESH_BUTTON).should('not.have.text', 'Updating');
};

export const waitForAlertsIndexToBeCreated = () => {
Expand Down

0 comments on commit 05cbf6b

Please sign in to comment.