Skip to content

Commit

Permalink
[Security Solution][Detections] Implements indicator match rule cypre…
Browse files Browse the repository at this point in the history
…ss test (elastic#84323)

* implemnts indicator match rule cypress test

* fixes merge issue

* fixes type check issues

* fixes mapping

* simplifies data

* fixes excpetions flakiness

* fixes alerts test

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
MadameSheema and kibanamachine committed Dec 3, 2020
1 parent fdb71b6 commit 6a23615
Show file tree
Hide file tree
Showing 12 changed files with 3,954 additions and 68 deletions.
36 changes: 15 additions & 21 deletions x-pack/plugins/security_solution/cypress/integration/alerts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
* you may not use this file except in compliance with the Elastic License.
*/
import {
NUMBER_OF_ALERTS,
ALERTS,
ALERTS_COUNT,
SELECTED_ALERTS,
SHOWING_ALERTS,
ALERTS,
TAKE_ACTION_POPOVER_BTN,
} from '../screens/alerts';

Expand Down Expand Up @@ -45,7 +45,7 @@ describe('Alerts', () => {
waitForAlertsPanelToBeLoaded();
waitForAlertsToBeLoaded();

cy.get(NUMBER_OF_ALERTS)
cy.get(ALERTS_COUNT)
.invoke('text')
.then((numberOfAlerts) => {
cy.get(SHOWING_ALERTS).should('have.text', `Showing ${numberOfAlerts} alerts`);
Expand All @@ -64,10 +64,7 @@ describe('Alerts', () => {
waitForAlerts();

const expectedNumberOfAlertsAfterClosing = +numberOfAlerts - numberOfAlertsToBeClosed;
cy.get(NUMBER_OF_ALERTS).should(
'have.text',
expectedNumberOfAlertsAfterClosing.toString()
);
cy.get(ALERTS_COUNT).should('have.text', expectedNumberOfAlertsAfterClosing.toString());

cy.get(SHOWING_ALERTS).should(
'have.text',
Expand All @@ -77,7 +74,7 @@ describe('Alerts', () => {
goToClosedAlerts();
waitForAlerts();

cy.get(NUMBER_OF_ALERTS).should('have.text', numberOfAlertsToBeClosed.toString());
cy.get(ALERTS_COUNT).should('have.text', numberOfAlertsToBeClosed.toString());
cy.get(SHOWING_ALERTS).should(
'have.text',
`Showing ${numberOfAlertsToBeClosed.toString()} alerts`
Expand All @@ -98,7 +95,7 @@ describe('Alerts', () => {
waitForAlerts();

const expectedNumberOfClosedAlertsAfterOpened = 2;
cy.get(NUMBER_OF_ALERTS).should(
cy.get(ALERTS_COUNT).should(
'have.text',
expectedNumberOfClosedAlertsAfterOpened.toString()
);
Expand Down Expand Up @@ -128,7 +125,7 @@ describe('Alerts', () => {
it('Closes one alert when more than one opened alerts are selected', () => {
waitForAlertsToBeLoaded();

cy.get(NUMBER_OF_ALERTS)
cy.get(ALERTS_COUNT)
.invoke('text')
.then((numberOfAlerts) => {
const numberOfAlertsToBeClosed = 1;
Expand All @@ -144,7 +141,7 @@ describe('Alerts', () => {
waitForAlerts();

const expectedNumberOfAlerts = +numberOfAlerts - numberOfAlertsToBeClosed;
cy.get(NUMBER_OF_ALERTS).should('have.text', expectedNumberOfAlerts.toString());
cy.get(ALERTS_COUNT).should('have.text', expectedNumberOfAlerts.toString());
cy.get(SHOWING_ALERTS).should(
'have.text',
`Showing ${expectedNumberOfAlerts.toString()} alerts`
Expand All @@ -153,7 +150,7 @@ describe('Alerts', () => {
goToClosedAlerts();
waitForAlerts();

cy.get(NUMBER_OF_ALERTS).should('have.text', numberOfAlertsToBeClosed.toString());
cy.get(ALERTS_COUNT).should('have.text', numberOfAlertsToBeClosed.toString());
cy.get(SHOWING_ALERTS).should(
'have.text',
`Showing ${numberOfAlertsToBeClosed.toString()} alert`
Expand All @@ -178,7 +175,7 @@ describe('Alerts', () => {
goToClosedAlerts();
waitForAlertsToBeLoaded();

cy.get(NUMBER_OF_ALERTS)
cy.get(ALERTS_COUNT)
.invoke('text')
.then((numberOfAlerts) => {
const numberOfAlertsToBeOpened = 1;
Expand All @@ -195,7 +192,7 @@ describe('Alerts', () => {
waitForAlerts();

const expectedNumberOfAlerts = +numberOfAlerts - numberOfAlertsToBeOpened;
cy.get(NUMBER_OF_ALERTS).should('have.text', expectedNumberOfAlerts.toString());
cy.get(ALERTS_COUNT).should('have.text', expectedNumberOfAlerts.toString());
cy.get(SHOWING_ALERTS).should(
'have.text',
`Showing ${expectedNumberOfAlerts.toString()} alerts`
Expand All @@ -204,7 +201,7 @@ describe('Alerts', () => {
goToOpenedAlerts();
waitForAlerts();

cy.get(NUMBER_OF_ALERTS).should('have.text', numberOfAlertsToBeOpened.toString());
cy.get(ALERTS_COUNT).should('have.text', numberOfAlertsToBeOpened.toString());
cy.get(SHOWING_ALERTS).should(
'have.text',
`Showing ${numberOfAlertsToBeOpened.toString()} alert`
Expand All @@ -228,7 +225,7 @@ describe('Alerts', () => {
waitForAlerts();
waitForAlertsToBeLoaded();

cy.get(NUMBER_OF_ALERTS)
cy.get(ALERTS_COUNT)
.invoke('text')
.then((numberOfAlerts) => {
const numberOfAlertsToBeMarkedInProgress = 1;
Expand All @@ -244,7 +241,7 @@ describe('Alerts', () => {
waitForAlertsToBeLoaded();

const expectedNumberOfAlerts = +numberOfAlerts - numberOfAlertsToBeMarkedInProgress;
cy.get(NUMBER_OF_ALERTS).should('have.text', expectedNumberOfAlerts.toString());
cy.get(ALERTS_COUNT).should('have.text', expectedNumberOfAlerts.toString());
cy.get(SHOWING_ALERTS).should(
'have.text',
`Showing ${expectedNumberOfAlerts.toString()} alerts`
Expand All @@ -253,10 +250,7 @@ describe('Alerts', () => {
goToInProgressAlerts();
waitForAlerts();

cy.get(NUMBER_OF_ALERTS).should(
'have.text',
numberOfAlertsToBeMarkedInProgress.toString()
);
cy.get(ALERTS_COUNT).should('have.text', numberOfAlertsToBeMarkedInProgress.toString());
cy.get(SHOWING_ALERTS).should(
'have.text',
`Showing ${numberOfAlertsToBeMarkedInProgress.toString()} alert`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import { exception } from '../objects/exception';
import { newRule } from '../objects/rule';

import { ALERTS_COUNT, NUMBER_OF_ALERTS } from '../screens/alerts';
import { RULE_STATUS } from '../screens/create_new_rule';
import { SERVER_SIDE_EVENT_COUNT } from '../screens/timeline';

import {
addExceptionFromFirstAlert,
Expand Down Expand Up @@ -52,7 +52,8 @@ describe('Exceptions', () => {
waitForAlertsToPopulate();
refreshPage();

cy.get(SERVER_SIDE_EVENT_COUNT)
cy.get(ALERTS_COUNT).should('exist');
cy.get(NUMBER_OF_ALERTS)
.invoke('text')
.then((numberOfInitialAlertsText) => {
cy.wrap(parseInt(numberOfInitialAlertsText, 10)).should(
Expand All @@ -77,7 +78,8 @@ describe('Exceptions', () => {
goToAlertsTab();
refreshPage();

cy.get(SERVER_SIDE_EVENT_COUNT)
cy.get(ALERTS_COUNT).should('exist');
cy.get(NUMBER_OF_ALERTS)
.invoke('text')
.then((numberOfAlertsAfterCreatingExceptionText) => {
cy.wrap(parseInt(numberOfAlertsAfterCreatingExceptionText, 10)).should('eql', 0);
Expand All @@ -86,7 +88,8 @@ describe('Exceptions', () => {
goToClosedAlerts();
refreshPage();

cy.get(SERVER_SIDE_EVENT_COUNT)
cy.get(ALERTS_COUNT).should('exist');
cy.get(NUMBER_OF_ALERTS)
.invoke('text')
.then((numberOfClosedAlertsAfterCreatingExceptionText) => {
cy.wrap(parseInt(numberOfClosedAlertsAfterCreatingExceptionText, 10)).should(
Expand All @@ -99,7 +102,8 @@ describe('Exceptions', () => {
waitForTheRuleToBeExecuted();
refreshPage();

cy.get(SERVER_SIDE_EVENT_COUNT)
cy.get(ALERTS_COUNT).should('exist');
cy.get(NUMBER_OF_ALERTS)
.invoke('text')
.then((numberOfOpenedAlertsAfterCreatingExceptionText) => {
cy.wrap(parseInt(numberOfOpenedAlertsAfterCreatingExceptionText, 10)).should('eql', 0);
Expand All @@ -113,7 +117,8 @@ describe('Exceptions', () => {
waitForAlertsToPopulate();
refreshPage();

cy.get(SERVER_SIDE_EVENT_COUNT)
cy.get(ALERTS_COUNT).should('exist');
cy.get(NUMBER_OF_ALERTS)
.invoke('text')
.then((numberOfAlertsAfterRemovingExceptionsText) => {
cy.wrap(parseInt(numberOfAlertsAfterRemovingExceptionsText, 10)).should(
Expand All @@ -130,7 +135,8 @@ describe('Exceptions', () => {
addsException(exception);
esArchiverLoad('auditbeat_for_exceptions2');

cy.get(SERVER_SIDE_EVENT_COUNT)
cy.get(ALERTS_COUNT).should('exist');
cy.get(NUMBER_OF_ALERTS)
.invoke('text')
.then((numberOfAlertsAfterCreatingExceptionText) => {
cy.wrap(parseInt(numberOfAlertsAfterCreatingExceptionText, 10)).should('eql', 0);
Expand All @@ -139,7 +145,8 @@ describe('Exceptions', () => {
goToClosedAlerts();
refreshPage();

cy.get(SERVER_SIDE_EVENT_COUNT)
cy.get(ALERTS_COUNT).should('exist');
cy.get(NUMBER_OF_ALERTS)
.invoke('text')
.then((numberOfClosedAlertsAfterCreatingExceptionText) => {
cy.wrap(parseInt(numberOfClosedAlertsAfterCreatingExceptionText, 10)).should(
Expand All @@ -152,7 +159,8 @@ describe('Exceptions', () => {
waitForTheRuleToBeExecuted();
refreshPage();

cy.get(SERVER_SIDE_EVENT_COUNT)
cy.get(ALERTS_COUNT).should('exist');
cy.get(NUMBER_OF_ALERTS)
.invoke('text')
.then((numberOfOpenedAlertsAfterCreatingExceptionText) => {
cy.wrap(parseInt(numberOfOpenedAlertsAfterCreatingExceptionText, 10)).should('eql', 0);
Expand All @@ -165,7 +173,8 @@ describe('Exceptions', () => {
waitForAlertsToPopulate();
refreshPage();

cy.get(SERVER_SIDE_EVENT_COUNT)
cy.get(ALERTS_COUNT).should('exist');
cy.get(NUMBER_OF_ALERTS)
.invoke('text')
.then((numberOfAlertsAfterRemovingExceptionsText) => {
cy.wrap(parseInt(numberOfAlertsAfterRemovingExceptionsText, 10)).should(
Expand Down
Loading

0 comments on commit 6a23615

Please sign in to comment.