Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Secuirty Solution] Fixes alerts flaky test #78424

Merged
merged 2 commits into from
Sep 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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