[Security Solution] Cypress alerts cell actions test improvement (#151891)

This commit is contained in:
Sergi Massaneda 2023-02-22 21:08:46 +01:00 committed by GitHub
parent e09ecd048e
commit 81a4b39847
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 4 deletions

View file

@ -20,12 +20,13 @@ import {
filterForAlertProperty,
showTopNAlertProperty,
clickExpandActions,
filterOutAlertProperty,
} from '../../tasks/alerts';
import { createCustomRuleEnabled } from '../../tasks/api_calls/rules';
import { cleanKibana } from '../../tasks/common';
import { waitForAlertsToPopulate } from '../../tasks/create_new_rule';
import { login, visit } from '../../tasks/login';
import { fillAddFilterForm, openAddFilterPopover } from '../../tasks/search_bar';
import { fillAddFilterForm, fillKqlQueryBar, openAddFilterPopover } from '../../tasks/search_bar';
import { openActiveTimeline } from '../../tasks/timeline';
import { ALERTS_URL } from '../../urls/navigation';
@ -60,13 +61,36 @@ describe('Alerts cell actions', () => {
});
it('should filter for an empty property', () => {
// add condition to make sure the field is empty
openAddFilterPopover();
fillAddFilterForm({ key: 'file.name', operator: 'does not exist' });
// add query condition to make sure the field is empty
fillKqlQueryBar('not file.name: *{enter}');
scrollAlertTableColumnIntoView(ALERT_TABLE_FILE_NAME_HEADER);
filterForAlertProperty(ALERT_TABLE_FILE_NAME_VALUES, 0);
cy.get(FILTER_BADGE).first().should('have.text', 'NOT file.name: exists');
});
it('should filter out a non-empty property', () => {
cy.get(ALERT_TABLE_SEVERITY_VALUES)
.first()
.invoke('text')
.then((severityVal) => {
scrollAlertTableColumnIntoView(ALERT_TABLE_FILE_NAME_HEADER);
filterOutAlertProperty(ALERT_TABLE_SEVERITY_VALUES, 0);
cy.get(FILTER_BADGE)
.first()
.should('have.text', `NOT kibana.alert.severity: ${severityVal}`);
});
});
it('should filter out an empty property', () => {
// add query condition to make sure the field is empty
fillKqlQueryBar('not file.name: *{enter}');
scrollAlertTableColumnIntoView(ALERT_TABLE_FILE_NAME_HEADER);
filterOutAlertProperty(ALERT_TABLE_FILE_NAME_VALUES, 0);
cy.get(FILTER_BADGE).first().should('have.text', 'file.name: exists');
});
});
describe('Add to timeline', () => {

View file

@ -36,6 +36,7 @@ import {
CELL_SHOW_TOP_FIELD_BUTTON,
ACTIONS_EXPAND_BUTTON,
SELECT_HISTOGRAM,
CELL_FILTER_OUT_BUTTON,
} from '../screens/alerts';
import { LOADING_INDICATOR, REFRESH_BUTTON } from '../screens/security_header';
import { TIMELINE_COLUMN_SPINNER } from '../screens/timeline';
@ -324,6 +325,9 @@ export const addAlertPropertyToTimeline = (propertySelector: string, rowIndex: n
export const filterForAlertProperty = (propertySelector: string, rowIndex: number) => {
clickAction(propertySelector, rowIndex, CELL_FILTER_IN_BUTTON);
};
export const filterOutAlertProperty = (propertySelector: string, rowIndex: number) => {
clickAction(propertySelector, rowIndex, CELL_FILTER_OUT_BUTTON);
};
export const showTopNAlertProperty = (propertySelector: string, rowIndex: number) => {
clickExpandActions(propertySelector, rowIndex);
cy.get(CELL_SHOW_TOP_FIELD_BUTTON).first().click({ force: true });