Skip to content

Commit

Permalink
pr change requests
Browse files Browse the repository at this point in the history
  • Loading branch information
lgestc committed Jan 8, 2024
1 parent 96e07dd commit 645fdcd
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 97 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
clickExpandActions,
filterOutAlertProperty,
} from '../../../tasks/alerts';
import { deleteAlertsAndRules } from '../../../tasks/api_calls/common';
import { createRule } from '../../../tasks/api_calls/rules';
import { waitForAlertsToPopulate } from '../../../tasks/create_new_rule';
import { login } from '../../../tasks/login';
Expand All @@ -39,113 +40,102 @@ import { ALERTS_URL } from '../../../urls/navigation';

describe('Alerts cell actions', { tags: ['@ess', '@serverless'] }, () => {
beforeEach(() => {
deleteAlertsAndRules();
createRule(getNewRule());
login();
visit(ALERTS_URL);
waitForAlertsToPopulate();
});

describe('Filter', () => {
it('should filter for and out', () => {
cy.log('should work for a non-empty property');
cy.get(ALERT_TABLE_SEVERITY_VALUES)
.first()
.invoke('text')
.then((severityVal) => {
scrollAlertTableColumnIntoView(ALERT_TABLE_SEVERITY_HEADER);
filterForAlertProperty(ALERT_TABLE_SEVERITY_VALUES, 0);
cy.get(FILTER_BADGE).first().should('have.text', `kibana.alert.severity: ${severityVal}`);
});

removeKqlFilter();

cy.log('should work for empty properties');
// add query condition to make sure the field is empty
fillKqlQueryBar('not file.name: *{enter}');

scrollAlertTableColumnIntoView(ALERT_TABLE_FILE_NAME_HEADER);

cy.log('filter for alert property');

filterForAlertProperty(ALERT_TABLE_FILE_NAME_VALUES, 0);

cy.get(FILTER_BADGE).first().should('have.text', 'NOT file.name: exists');

cy.log('filter out alert property');

filterOutAlertProperty(ALERT_TABLE_FILE_NAME_VALUES, 0);

cy.get(FILTER_BADGE).first().should('have.text', 'file.name: exists');

removeKqlFilter();
scrollAlertTableColumnIntoView(ALERT_TABLE_SEVERITY_HEADER);

cy.log('should allow copy paste');

cy.get(ALERT_TABLE_SEVERITY_VALUES)
.first()
.invoke('text')
.then(() => {
scrollAlertTableColumnIntoView(ALERT_TABLE_SEVERITY_HEADER);
cy.window().then((win) => {
cy.stub(win, 'prompt').returns('DISABLED WINDOW PROMPT');
});
clickExpandActions(ALERT_TABLE_SEVERITY_VALUES, 0);
cy.get(CELL_COPY_BUTTON).should('exist');
// We are not able to test the "copy to clipboard" action execution
// due to browsers security limitation accessing the clipboard services.
// We assume external `copy` library works
});

cy.log('should filter out a non-empty property');

cy.get(ALERT_TABLE_SEVERITY_VALUES)
.first()
.invoke('text')
.then((severityVal) => {
scrollAlertTableColumnIntoView(ALERT_TABLE_SEVERITY_HEADER);
filterOutAlertProperty(ALERT_TABLE_SEVERITY_VALUES, 0);
cy.get(FILTER_BADGE)
.first()
.should('have.text', `NOT kibana.alert.severity: ${severityVal}`);
});
it('should filter for and out', () => {
cy.log('should work for a non-empty property');
cy.get(ALERT_TABLE_SEVERITY_VALUES)
.first()
.invoke('text')
.then((severityVal) => {
scrollAlertTableColumnIntoView(ALERT_TABLE_SEVERITY_HEADER);
filterForAlertProperty(ALERT_TABLE_SEVERITY_VALUES, 0);
cy.get(FILTER_BADGE).first().should('have.text', `kibana.alert.severity: ${severityVal}`);
});

removeKqlFilter();

cy.log('should work for empty properties');
// add query condition to make sure the field is empty
fillKqlQueryBar('not file.name: *{enter}');

scrollAlertTableColumnIntoView(ALERT_TABLE_FILE_NAME_HEADER);

cy.log('filter for alert property');

filterForAlertProperty(ALERT_TABLE_FILE_NAME_VALUES, 0);

cy.get(FILTER_BADGE).first().should('have.text', 'NOT file.name: exists');

cy.log('filter out alert property');

filterOutAlertProperty(ALERT_TABLE_FILE_NAME_VALUES, 0);

cy.get(FILTER_BADGE).first().should('have.text', 'file.name: exists');

removeKqlFilter();
scrollAlertTableColumnIntoView(ALERT_TABLE_SEVERITY_HEADER);

cy.log('should allow copy paste');

cy.window().then((win) => {
cy.stub(win, 'prompt').returns('DISABLED WINDOW PROMPT');
});
clickExpandActions(ALERT_TABLE_SEVERITY_VALUES, 0);
// We are not able to test the "copy to clipboard" action execution
// due to browsers security limitation accessing the clipboard services.
// We assume external `copy` library works
cy.get(CELL_COPY_BUTTON).should('exist');

cy.log('should filter out a non-empty property');

cy.get(ALERT_TABLE_SEVERITY_VALUES)
.first()
.invoke('text')
.then((severityVal) => {
scrollAlertTableColumnIntoView(ALERT_TABLE_SEVERITY_HEADER);
filterOutAlertProperty(ALERT_TABLE_SEVERITY_VALUES, 0);
cy.get(FILTER_BADGE)
.first()
.should('have.text', `NOT kibana.alert.severity: ${severityVal}`);
});
});

describe('Add to timeline', () => {
it('should add a non-empty property to default timeline', () => {
cy.get(ALERT_TABLE_SEVERITY_VALUES)
.first()
.invoke('text')
.then((severityVal) => {
scrollAlertTableColumnIntoView(ALERT_TABLE_SEVERITY_HEADER);
addAlertPropertyToTimeline(ALERT_TABLE_SEVERITY_VALUES, 0);
openActiveTimeline();
cy.get(PROVIDER_BADGE)
.first()
.should('have.text', `kibana.alert.severity: "${severityVal}"`);
});
});
it('should add a non-empty property to default timeline', () => {
cy.get(ALERT_TABLE_SEVERITY_VALUES)
.first()
.invoke('text')
.then((severityVal) => {
scrollAlertTableColumnIntoView(ALERT_TABLE_SEVERITY_HEADER);
addAlertPropertyToTimeline(ALERT_TABLE_SEVERITY_VALUES, 0);
openActiveTimeline();
cy.get(PROVIDER_BADGE)
.first()
.should('have.text', `kibana.alert.severity: "${severityVal}"`);
});
});

it('should add an empty property to default timeline', () => {
// add condition to make sure the field is empty
openAddFilterPopover();
it('should add an empty property to default timeline', () => {
// add condition to make sure the field is empty
openAddFilterPopover();

fillAddFilterForm({ key: 'file.name', operator: 'does not exist' });
scrollAlertTableColumnIntoView(ALERT_TABLE_FILE_NAME_HEADER);
addAlertPropertyToTimeline(ALERT_TABLE_FILE_NAME_VALUES, 0);
openActiveTimeline();
cy.get(PROVIDER_BADGE).first().should('have.text', 'NOT file.name exists');
});
fillAddFilterForm({ key: 'file.name', operator: 'does not exist' });
scrollAlertTableColumnIntoView(ALERT_TABLE_FILE_NAME_HEADER);
addAlertPropertyToTimeline(ALERT_TABLE_FILE_NAME_VALUES, 0);
openActiveTimeline();
cy.get(PROVIDER_BADGE).first().should('have.text', 'NOT file.name exists');
});

describe('Show Top N', () => {
it('should show top for a property', () => {
cy.get(ALERT_TABLE_SEVERITY_VALUES);
it('should show top for a property', () => {
cy.get(ALERT_TABLE_SEVERITY_VALUES);

scrollAlertTableColumnIntoView(ALERT_TABLE_SEVERITY_HEADER);
showTopNAlertProperty(ALERT_TABLE_SEVERITY_VALUES, 0);
cy.get(SHOW_TOP_N_HEADER).first().should('have.text', `Top kibana.alert.severity`);
});
scrollAlertTableColumnIntoView(ALERT_TABLE_SEVERITY_HEADER);
showTopNAlertProperty(ALERT_TABLE_SEVERITY_VALUES, 0);
cy.get(SHOW_TOP_N_HEADER).first().should('have.text', `Top kibana.alert.severity`);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {

export const openAddFilterPopover = () => {
cy.get(GLOBAL_SEARCH_BAR_SUBMIT_BUTTON).should('be.enabled');
cy.get(GLOBAL_SEARCH_BAR_ADD_FILTER).should('be.visible');
cy.get(GLOBAL_SEARCH_BAR_ADD_FILTER).click();
};

Expand Down Expand Up @@ -53,8 +52,6 @@ export const removeKqlFilter = () => {
};

export const fillAddFilterForm = ({ key, operator, value }: SearchBarFilter) => {
cy.get(ADD_FILTER_FORM_FIELD_INPUT).should('exist');
cy.get(ADD_FILTER_FORM_FIELD_INPUT).should('be.visible');
cy.get(ADD_FILTER_FORM_FIELD_INPUT).type(`${key}{downarrow}{enter}`);

cy.get(ADD_FILTER_FORM_OPERATOR_FIELD).type(`${operator}{downarrow}{enter}`);
Expand Down

0 comments on commit 645fdcd

Please sign in to comment.