From 645fdcdb3d64d4fcd1e3554221e90d962ce7d86c Mon Sep 17 00:00:00 2001 From: lgestc Date: Mon, 8 Jan 2024 10:16:29 +0100 Subject: [PATCH] pr change requests --- .../alerts/alerts_cell_actions.cy.ts | 178 +++++++++--------- .../cypress/tasks/search_bar.ts | 3 - 2 files changed, 84 insertions(+), 97 deletions(-) diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/investigations/alerts/alerts_cell_actions.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/investigations/alerts/alerts_cell_actions.cy.ts index 8fd0d30412ee2..49dd7dc2259fc 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/investigations/alerts/alerts_cell_actions.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/investigations/alerts/alerts_cell_actions.cy.ts @@ -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'; @@ -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`); }); }); diff --git a/x-pack/test/security_solution_cypress/cypress/tasks/search_bar.ts b/x-pack/test/security_solution_cypress/cypress/tasks/search_bar.ts index 3a4355cad2e7e..bd6ca6775c12f 100644 --- a/x-pack/test/security_solution_cypress/cypress/tasks/search_bar.ts +++ b/x-pack/test/security_solution_cypress/cypress/tasks/search_bar.ts @@ -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(); }; @@ -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}`);