From b138a0261ea24f992df5322704b790c2c557f3a9 Mon Sep 17 00:00:00 2001 From: Jan Monschke Date: Thu, 14 Dec 2023 12:31:51 +0100 Subject: [PATCH 01/10] `trigger('click')` -> `click()` --- x-pack/test/security_solution_cypress/cypress/tasks/timeline.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/test/security_solution_cypress/cypress/tasks/timeline.ts b/x-pack/test/security_solution_cypress/cypress/tasks/timeline.ts index d621fd2d832a2..3b9c013e04fcf 100644 --- a/x-pack/test/security_solution_cypress/cypress/tasks/timeline.ts +++ b/x-pack/test/security_solution_cypress/cypress/tasks/timeline.ts @@ -551,6 +551,6 @@ export const openTimelineFromOpenTimelineModal = (timelineName: string) => { export const showDataProviderQueryBuilder = () => { cy.get(TOGGLE_DATA_PROVIDER_BTN).should('have.attr', 'aria-pressed', 'false'); - cy.get(TOGGLE_DATA_PROVIDER_BTN).trigger('click'); + cy.get(TOGGLE_DATA_PROVIDER_BTN).click(); cy.get(TOGGLE_DATA_PROVIDER_BTN).should('have.attr', 'aria-pressed', 'true'); }; From e4bfd279d8d22f255f4a0bd18210c19fe766ed5b Mon Sep 17 00:00:00 2001 From: Jan Monschke Date: Thu, 14 Dec 2023 12:32:12 +0100 Subject: [PATCH 02/10] checking for existence after clicking does not make sense --- .../cypress/e2e/investigations/timelines/search_or_filter.cy.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/search_or_filter.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/search_or_filter.cy.ts index a7b4191d8b470..ecad82fd550e4 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/search_or_filter.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/search_or_filter.cy.ts @@ -64,7 +64,6 @@ describe('Timeline search and filters', { tags: ['@ess', '@serverless'] }, () => cy.get(LOADING_INDICATOR).should('not.exist'); showDataProviderQueryBuilder(); cy.get(TIMELINE_SEARCH_OR_FILTER).click(); - cy.get(TIMELINE_SEARCH_OR_FILTER).should('exist'); }); it('should be able to update timeline kqlMode with filter', () => { From b15c9eb4968b31421d3fbc2408baa35b85ccc08b Mon Sep 17 00:00:00 2001 From: Jan Monschke Date: Thu, 14 Dec 2023 12:44:37 +0100 Subject: [PATCH 03/10] delete timelines --- .../e2e/investigations/timelines/search_or_filter.cy.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/search_or_filter.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/search_or_filter.cy.ts index ecad82fd550e4..7429333de53d2 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/search_or_filter.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/search_or_filter.cy.ts @@ -25,6 +25,7 @@ import { showDataProviderQueryBuilder, } from '../../../tasks/timeline'; import { waitForTimelinesPanelToBeLoaded } from '../../../tasks/timelines'; +import { deleteTimelines } from '../../../tasks/api_calls/common'; import { hostsUrl, TIMELINES_URL } from '../../../urls/navigation'; @@ -32,6 +33,7 @@ describe('Timeline search and filters', { tags: ['@ess', '@serverless'] }, () => describe('timeline search or filter KQL bar', () => { beforeEach(() => { login(); + deleteTimelines(); visitWithTimeRange(hostsUrl('allHosts')); }); @@ -57,6 +59,7 @@ describe('Timeline search and filters', { tags: ['@ess', '@serverless'] }, () => describe.skip('Update kqlMode for timeline', () => { beforeEach(() => { login(); + deleteTimelines(); visit(TIMELINES_URL); waitForTimelinesPanelToBeLoaded(); openTimelineUsingToggle(); From 1aa8a5e675d83740a7f4a7a31f808dc24a750592 Mon Sep 17 00:00:00 2001 From: Jan Monschke Date: Thu, 14 Dec 2023 12:44:45 +0100 Subject: [PATCH 04/10] unskip test --- .../e2e/investigations/timelines/search_or_filter.cy.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/search_or_filter.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/search_or_filter.cy.ts index 7429333de53d2..f717fefdb2808 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/search_or_filter.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/search_or_filter.cy.ts @@ -55,8 +55,7 @@ describe('Timeline search and filters', { tags: ['@ess', '@serverless'] }, () => }); }); - // FLAKY: https://github.com/elastic/kibana/issues/169882 - describe.skip('Update kqlMode for timeline', () => { + describe('Update kqlMode for timeline', () => { beforeEach(() => { login(); deleteTimelines(); From 76af23e2f3f287ddae6d8e0203118bc33ac6969b Mon Sep 17 00:00:00 2001 From: Jan Monschke Date: Thu, 14 Dec 2023 12:45:57 +0100 Subject: [PATCH 05/10] flaky test runner setup --- x-pack/test/security_solution_cypress/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/test/security_solution_cypress/package.json b/x-pack/test/security_solution_cypress/package.json index fe8585e530f4e..761db189feec0 100644 --- a/x-pack/test/security_solution_cypress/package.json +++ b/x-pack/test/security_solution_cypress/package.json @@ -16,7 +16,7 @@ "cypress:detection_engine:exceptions:run:ess": "yarn cypress:ess --spec './cypress/e2e/detection_response/detection_engine/exceptions/**/*.cy.ts'", "cypress:ai_assistant:run:ess":"yarn cypress:ess --spec './cypress/e2e/ai_assistant/**/*.cy.ts'", "cypress:run:respops:ess": "yarn cypress:ess --spec './cypress/e2e/(detection_response)/**/*.cy.ts'", - "cypress:investigations:run:ess": "yarn cypress:ess --spec './cypress/e2e/investigations/**/*.cy.ts'", + "cypress:investigations:run:ess": "yarn cypress:ess --spec './cypress/e2e/investigations/timelines/search_or_filter.cy.ts'", "cypress:explore:run:ess": "yarn cypress:ess --spec './cypress/e2e/explore/**/*.cy.ts'", "cypress:changed-specs-only:ess": "yarn cypress:ess --changed-specs-only --env burn=5", "cypress:burn:ess": "yarn cypress:ess --env burn=5", @@ -32,7 +32,7 @@ "cypress:detection_engine:run:serverless": "yarn cypress:serverless --spec './cypress/e2e/detection_response/detection_engine/!(exceptions)/**/*.cy.ts'", "cypress:detection_engine:exceptions:run:serverless": "yarn cypress:serverless --spec './cypress/e2e/detection_response/detection_engine/exceptions/**/*.cy.ts'", "cypress:ai_assistant:run:serverless": "yarn cypress:serverless --spec './cypress/e2e/ai_assistant/**/*.cy.ts'", - "cypress:investigations:run:serverless": "yarn cypress:serverless --spec './cypress/e2e/investigations/**/*.cy.ts'", + "cypress:investigations:run:serverless": "yarn cypress:serverless --spec './cypress/e2e/investigations/timelines/search_or_filter.cy.ts'", "cypress:explore:run:serverless": "yarn cypress:serverless --spec './cypress/e2e/explore/**/*.cy.ts'", "cypress:changed-specs-only:serverless": "yarn cypress:serverless --changed-specs-only --env burn=5", "cypress:burn:serverless": "yarn cypress:serverless --env burn=2", From c651b396fb4c4564e6659d18978c8ed5e4d89e9b Mon Sep 17 00:00:00 2001 From: Jan Monschke Date: Thu, 14 Dec 2023 13:30:16 +0100 Subject: [PATCH 06/10] Revert "flaky test runner setup" This reverts commit 76af23e2f3f287ddae6d8e0203118bc33ac6969b. --- x-pack/test/security_solution_cypress/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/test/security_solution_cypress/package.json b/x-pack/test/security_solution_cypress/package.json index 761db189feec0..fe8585e530f4e 100644 --- a/x-pack/test/security_solution_cypress/package.json +++ b/x-pack/test/security_solution_cypress/package.json @@ -16,7 +16,7 @@ "cypress:detection_engine:exceptions:run:ess": "yarn cypress:ess --spec './cypress/e2e/detection_response/detection_engine/exceptions/**/*.cy.ts'", "cypress:ai_assistant:run:ess":"yarn cypress:ess --spec './cypress/e2e/ai_assistant/**/*.cy.ts'", "cypress:run:respops:ess": "yarn cypress:ess --spec './cypress/e2e/(detection_response)/**/*.cy.ts'", - "cypress:investigations:run:ess": "yarn cypress:ess --spec './cypress/e2e/investigations/timelines/search_or_filter.cy.ts'", + "cypress:investigations:run:ess": "yarn cypress:ess --spec './cypress/e2e/investigations/**/*.cy.ts'", "cypress:explore:run:ess": "yarn cypress:ess --spec './cypress/e2e/explore/**/*.cy.ts'", "cypress:changed-specs-only:ess": "yarn cypress:ess --changed-specs-only --env burn=5", "cypress:burn:ess": "yarn cypress:ess --env burn=5", @@ -32,7 +32,7 @@ "cypress:detection_engine:run:serverless": "yarn cypress:serverless --spec './cypress/e2e/detection_response/detection_engine/!(exceptions)/**/*.cy.ts'", "cypress:detection_engine:exceptions:run:serverless": "yarn cypress:serverless --spec './cypress/e2e/detection_response/detection_engine/exceptions/**/*.cy.ts'", "cypress:ai_assistant:run:serverless": "yarn cypress:serverless --spec './cypress/e2e/ai_assistant/**/*.cy.ts'", - "cypress:investigations:run:serverless": "yarn cypress:serverless --spec './cypress/e2e/investigations/timelines/search_or_filter.cy.ts'", + "cypress:investigations:run:serverless": "yarn cypress:serverless --spec './cypress/e2e/investigations/**/*.cy.ts'", "cypress:explore:run:serverless": "yarn cypress:serverless --spec './cypress/e2e/explore/**/*.cy.ts'", "cypress:changed-specs-only:serverless": "yarn cypress:serverless --changed-specs-only --env burn=5", "cypress:burn:serverless": "yarn cypress:serverless --env burn=2", From 159fd6e34e092cfd0844df86a4f8a7a26bec9501 Mon Sep 17 00:00:00 2001 From: Jan Monschke Date: Thu, 14 Dec 2023 19:22:28 +0100 Subject: [PATCH 07/10] remove unused tasks and selectors --- .../cypress/screens/timeline.ts | 60 +--------------- .../cypress/tasks/timeline.ts | 72 ------------------- 2 files changed, 1 insertion(+), 131 deletions(-) diff --git a/x-pack/test/security_solution_cypress/cypress/screens/timeline.ts b/x-pack/test/security_solution_cypress/cypress/screens/timeline.ts index 32cf43e3de2cf..85b3f32df8292 100644 --- a/x-pack/test/security_solution_cypress/cypress/screens/timeline.ts +++ b/x-pack/test/security_solution_cypress/cypress/screens/timeline.ts @@ -6,7 +6,7 @@ */ import type { TimelineFilter } from '../objects/timeline'; -import { getDataTestSubjectSelector, getDataTestSubjectSelectorStartWith } from '../helpers/common'; +import { getDataTestSubjectSelector } from '../helpers/common'; export const ADD_NOTE_BUTTON = '[data-test-subj="add-note"]'; @@ -24,9 +24,6 @@ export const SELECT_CASE = (id: string) => { return `[data-test-subj="cases-table-row-select-${id}"]`; }; -export const CORRELATION_EVENT_TABLE_CELL = - '[data-test-subj="eql-events-table"] [data-test-subj="statefulCell"]'; - export const CLOSE_TIMELINE_BTN = '[data-test-subj="close-timeline"]'; export const COMBO_BOX_INPUT = '[data-test-subj="comboBoxInput"]'; @@ -45,24 +42,8 @@ export const DATAGRID_HEADER = (header: string) => { return `[data-test-subj="dataGridHeaderCell-${header}"]`; }; -export const DATE_PICKER_END = '[data-test-subj="superDatePickerendDatePopoverButton"]'; - -export const DATE_PICKER_START = '[data-test-subj="superDatePickerstartDatePopoverButton"]'; - -export const DELETE_TIMELINE_BTN = '[data-test-subj="delete-timeline"]'; - -export const DELETION_CONFIRMATION = '[data-test-subj="confirmModalConfirmButton"]'; - -export const DESTINATION_IP_KPI = '[data-test-subj="siem-timeline-destination-ip-kpi"]'; - -export const FAVORITE_TIMELINE = '[data-test-subj="timeline-favorite-filled-star"]'; - export const FIELD_BROWSER = '[data-test-subj="show-field-browser"]'; -export const GRAPH_TAB_BUTTON = '[data-test-subj="timelineTabs-graph"]'; - -export const HOST_KPI = '[data-test-subj="siem-timeline-host-kpi"]'; - export const ID_HEADER_FIELD = '[data-test-subj="timeline"] [data-test-subj="header-text-_id"]'; export const ID_TOGGLE_FIELD = @@ -75,16 +56,10 @@ export const LOCKED_ICON = '[data-test-subj="timeline-date-picker-lock-button"]' export const UNLOCKED_ICON = '[data-test-subj="timeline-date-picker-unlock-button"]'; -export const NOTES = '[data-test-subj="note-card-body"]'; - export const NOTE_CARD_CONTENT = '[data-test-subj="notes"]'; -export const EVENT_NOTE = '[data-test-subj="timeline-notes-button-small"]'; - export const NOTE_DESCRIPTION = '[data-test-subj="note-preview-description"]'; -export const NOTE_PREVIEW = '[data-test-subj^="note-preview"]'; - export const NOTES_TEXT_AREA = '[data-test-subj="add-a-note"] textarea'; export const NOTES_TAB_BUTTON = '[data-test-subj="timelineTabs-notes"]'; @@ -106,18 +81,10 @@ export const OPEN_TIMELINE_ICON = '[data-test-subj="open-timeline-button"]'; export const OPEN_TIMELINE_MODAL = '[data-test-subj="open-timeline-modal"]'; -export const CLOSE_OPEN_TIMELINE_MODAL_BTN = `${OPEN_TIMELINE_MODAL} > button`; - export const PIN_EVENT = '[data-test-subj="pin"]'; -export const PINNED_TAB_BUTTON = '[data-test-subj="timelineTabs-pinned"]'; - -export const PROCESS_KPI = '[data-test-subj="siem-timeline-process-kpi"'; - export const PROVIDER_BADGE = '[data-test-subj="providerBadge"]'; -export const PROVIDER_BADGE_DELETE = '.delete-data-provider'; - export const RESET_FIELDS = '[data-test-subj="fields-browser-container"] [data-test-subj="reset-fields"]'; @@ -128,17 +95,12 @@ export const SEARCH_OR_FILTER_CONTAINER = export const INDICATOR_MATCH_ROW_RENDER = '[data-test-subj="threat-match-row"]'; -export const QUERY_EVENT_TABLE_CELL = - '[data-test-subj="query-events-table"] [data-test-subj="statefulCell"]'; - export const QUERY_TAB_BUTTON = '[data-test-subj="timelineTabs-query"]'; export const SERVER_SIDE_EVENT_COUNT = '[data-test-subj="server-side-event-count"]'; export const ALERTS_TABLE_COUNT = `[data-test-subj="toolbar-alerts-count"]`; -export const SOURCE_IP_KPI = '[data-test-subj="siem-timeline-source-ip-kpi"]'; - export const STAR_ICON = '[data-test-subj="timeline-favorite-empty-star"]'; export const TIMELINE_COLUMN_SPINNER = '[data-test-subj="timeline-loading-spinner"]'; @@ -168,8 +130,6 @@ export const TIMELINE_DATA_PROVIDER_VALUE = `[data-test-subj="value"]`; export const SAVE_DATA_PROVIDER_BTN = `[data-test-subj="save"]`; -export const TIMELINE_DESCRIPTION = '[data-test-subj="timeline-description"]'; - export const TIMELINE_DESCRIPTION_INPUT = '[data-test-subj="save-timeline-description"]'; export const TIMELINE_DROPPED_DATA_PROVIDERS = '[data-test-subj="providerContainer"]'; @@ -213,8 +173,6 @@ export const TIMELINE_FLYOUT = '[data-test-subj="timeline-flyout"]'; export const TIMELINE_FLYOUT_HEADER = '[data-test-subj="query-tab-flyout-header"]'; -export const TIMELINE_FLYOUT_BODY = '[data-test-subj="query-tab-flyout-body"]'; - export const TIMELINE_HEADER = '[data-test-subj="timeline-hide-show-container"]'; export const TIMELINE_INSPECT_BUTTON = `${TIMELINE_FLYOUT} [data-test-subj="inspect-empty-button"]`; @@ -250,8 +208,6 @@ export const TIMESTAMP_TOGGLE_FIELD = export const TOGGLE_TIMELINE_EXPAND_EVENT = '[data-test-subj="expand-event"]'; -export const TIMELINE_SAVE_MODAL_OPEN_BUTTON = '[data-test-subj="save-timeline-btn"]'; - export const TIMELINE_SAVE_MODAL = '[data-test-subj="save-timeline-modal"]'; export const TIMELINE_EDIT_MODAL_SAVE_BUTTON = '[data-test-subj="save-button"]'; @@ -294,17 +250,11 @@ export const TIMELINE_TAB_CONTENT_GRAPHS_NOTES = export const TIMESTAMP_HOVER_ACTION_OVERFLOW_BTN = '[data-test-subj="event-fields-table-row-@timestamp"] [data-test-subj="showExtraActionsButton"]'; -export const USER_KPI = '[data-test-subj="siem-timeline-user-kpi"]'; - export const TIMELINE_STATUS = '[data-test-subj="timeline-status"]'; -export const SAVE_TIMELINE_BTN_TOOLTIP = '[data-test-subj="save-timeline-btn-tooltip"]'; - export const ALERT_TABLE_SEVERITY_VALUES = '[data-test-subj="formatted-field-kibana.alert.severity"]'; -export const ALERT_TABLE_ACTIONS_HEADER = '[data-gridcell-column-id="expandColumn"]'; - export const ALERT_TABLE_FILE_NAME_HEADER = '[data-gridcell-column-id="file.name"]'; export const ALERT_TABLE_SEVERITY_HEADER = '[data-gridcell-column-id="kibana.alert.severity"]'; @@ -344,14 +294,6 @@ export const TIMELINE_DATE_PICKER_CONTAINER = getDataTestSubjectSelector( 'timeline-date-picker-container' ); -export const OPEN_TIMELINE_MODAL_SEARCH_BAR = `${OPEN_TIMELINE_MODAL} ${getDataTestSubjectSelector( - 'search-bar' -)}`; - -export const OPEN_TIMELINE_MODAL_TIMELINE_NAMES = `${OPEN_TIMELINE_MODAL} ${getDataTestSubjectSelectorStartWith( - 'timeline-title-' -)}`; - export const TIMELINE_FILTER_BADGE = `[data-test-subj^='timeline-filters-container'] [data-test-subj^="filter-badge"]`; export const NEW_TIMELINE_ACTION = getDataTestSubjectSelector('new-timeline-action'); diff --git a/x-pack/test/security_solution_cypress/cypress/tasks/timeline.ts b/x-pack/test/security_solution_cypress/cypress/tasks/timeline.ts index 3b9c013e04fcf..06dc3443c3845 100644 --- a/x-pack/test/security_solution_cypress/cypress/tasks/timeline.ts +++ b/x-pack/test/security_solution_cypress/cypress/tasks/timeline.ts @@ -9,7 +9,6 @@ import { recurse } from 'cypress-recurse'; import type { Timeline, TimelineFilter } from '../objects/timeline'; import { ALL_CASES_CREATE_NEW_CASE_TABLE_BTN } from '../screens/all_cases'; -import { BASIC_TABLE_LOADING } from '../screens/common'; import { FIELDS_BROWSER_CHECKBOX } from '../screens/fields_browser'; import { LOADING_INDICATOR } from '../screens/security_header'; import { EQL_QUERY_VALIDATION_SPINNER } from '../screens/create_new_rule'; @@ -23,8 +22,6 @@ import { CLOSE_TIMELINE_BTN, COMBO_BOX_INPUT, CREATE_NEW_TIMELINE, - DELETE_TIMELINE_BTN, - DELETION_CONFIRMATION, FIELD_BROWSER, ID_HEADER_FIELD, ID_TOGGLE_FIELD, @@ -56,13 +53,11 @@ import { TIMELINE_EDIT_MODAL_SAVE_AS_NEW_SWITCH, TIMELINE_PROGRESS_BAR, QUERY_TAB_BUTTON, - CLOSE_OPEN_TIMELINE_MODAL_BTN, TIMELINE_ADD_FIELD_BUTTON, TIMELINE_DATA_PROVIDER_FIELD, TIMELINE_DATA_PROVIDER_OPERATOR, TIMELINE_DATA_PROVIDER_VALUE, SAVE_DATA_PROVIDER_BTN, - EVENT_NOTE, TIMELINE_CORRELATION_INPUT, TIMELINE_CORRELATION_TAB, TIMELINE_CREATE_TIMELINE_FROM_TEMPLATE_BTN, @@ -81,12 +76,7 @@ import { TIMELINE_LUCENELANGUAGE_BUTTON, TIMELINE_KQLLANGUAGE_BUTTON, TIMELINE_QUERY, - PROVIDER_BADGE, - PROVIDER_BADGE_DELETE, ESQL_TAB, - OPEN_TIMELINE_MODAL_TIMELINE_NAMES, - OPEN_TIMELINE_MODAL_SEARCH_BAR, - OPEN_TIMELINE_MODAL, NEW_TIMELINE_ACTION, SAVE_TIMELINE_ACTION, TOGGLE_DATA_PROVIDER_BTN, @@ -303,20 +293,11 @@ export const clickIdToggleField = () => { }); }; -export const closeOpenTimelineModal = () => { - cy.get(CLOSE_OPEN_TIMELINE_MODAL_BTN).click({ force: true }); -}; - export const closeTimeline = () => { cy.get(CLOSE_TIMELINE_BTN).filter(':visible').click(); cy.get(QUERY_TAB_BUTTON).should('not.be.visible'); }; -export const removeDataProvider = () => { - cy.get(PROVIDER_BADGE).click(); - cy.get(PROVIDER_BADGE_DELETE).click(); -}; - export const createNewTimeline = () => { cy.get(NEW_TIMELINE_ACTION).should('be.visible').trigger('click'); cy.get(CREATE_NEW_TIMELINE).eq(0).should('be.visible').click({ force: true }); @@ -326,18 +307,6 @@ export const openCreateTimelineOptionsPopover = () => { cy.get(NEW_TIMELINE_ACTION).filter(':visible').should('be.visible').click(); }; -export const createTimelineOptionsPopoverBottomBar = () => { - recurse( - () => { - cy.get(TIMELINE_SETTINGS_ICON).filter(':visible').should('be.visible').click(); - return cy.get(CREATE_NEW_TIMELINE).eq(0); - }, - (sub) => sub.is(':visible') - ); - - cy.get(CREATE_NEW_TIMELINE).eq(0).should('be.visible').click(); -}; - export const createTimelineTemplateOptionsPopoverBottomBar = () => { recurse( () => { @@ -350,10 +319,6 @@ export const createTimelineTemplateOptionsPopoverBottomBar = () => { cy.get(CREATE_NEW_TIMELINE_TEMPLATE).eq(0).should('be.visible').click(); }; -export const closeCreateTimelineOptionsPopover = () => { - cy.get(TIMELINE_SETTINGS_ICON).filter(':visible').should('be.visible').type('{esc}'); -}; - export const createNewTimelineTemplate = () => { openCreateTimelineOptionsPopover(); cy.get(CREATE_NEW_TIMELINE_TEMPLATE).click(); @@ -391,12 +356,6 @@ export const saveTimeline = () => { }); }; -export const deleteTimeline = () => { - cy.get(TIMELINE_COLLAPSED_ITEMS_BTN).click(); - cy.get(DELETE_TIMELINE_BTN).click(); - cy.get(DELETION_CONFIRMATION).click(); -}; - export const markAsFavorite = () => { cy.intercept('PATCH', 'api/timeline/_favorite').as('markedAsFavourite'); cy.get(STAR_ICON).click({ force: true }); @@ -444,13 +403,6 @@ export const pinFirstEvent = (): Cypress.Chainable> => { return cy.get(PIN_EVENT).first().click({ force: true }); }; -export const persistNoteToFirstEvent = (notes: string) => { - cy.get(EVENT_NOTE).first().click({ force: true }); - cy.get(NOTES_TEXT_AREA).type(notes); - cy.get(ADD_NOTE_BUTTON).click(); - cy.get(NOTES_TAB_BUTTON).find('.euiBadge'); -}; - export const populateTimeline = () => { executeTimelineKQL(hostExistsQuery); cy.get(SERVER_SIDE_EVENT_COUNT).should('not.have.text', '0'); @@ -525,30 +477,6 @@ export const expandEventAction = () => { cy.get(TIMELINE_COLLAPSED_ITEMS_BTN).first().click(); }; -export const setKibanaTimezoneToUTC = () => - cy - .request({ - method: 'POST', - url: 'internal/kibana/settings', - body: { changes: { 'dateFormat:tz': 'UTC' } }, - headers: { - 'kbn-xsrf': 'set-kibana-timezone-utc', - 'x-elastic-internal-origin': 'security-solution', - }, - }) - .then(() => { - cy.reload(); - }); - -export const openTimelineFromOpenTimelineModal = (timelineName: string) => { - cy.get(OPEN_TIMELINE_MODAL_TIMELINE_NAMES).should('have.lengthOf.gt', 0); - cy.get(BASIC_TABLE_LOADING).should('not.exist'); - cy.get(OPEN_TIMELINE_MODAL_SEARCH_BAR).type(`${timelineName}{enter}`); - cy.get(OPEN_TIMELINE_MODAL_TIMELINE_NAMES).should('have.lengthOf', 1); - cy.get(OPEN_TIMELINE_MODAL).should('contain.text', timelineName); - cy.get(OPEN_TIMELINE_MODAL_TIMELINE_NAMES).first().click(); -}; - export const showDataProviderQueryBuilder = () => { cy.get(TOGGLE_DATA_PROVIDER_BTN).should('have.attr', 'aria-pressed', 'false'); cy.get(TOGGLE_DATA_PROVIDER_BTN).click(); From a60f931812099c268c65e0a1d5cb5e14a986c27a Mon Sep 17 00:00:00 2001 From: Jan Monschke Date: Thu, 14 Dec 2023 19:48:44 +0100 Subject: [PATCH 08/10] remove { force: true } --- x-pack/test/security_solution_cypress/cypress/tasks/timeline.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/test/security_solution_cypress/cypress/tasks/timeline.ts b/x-pack/test/security_solution_cypress/cypress/tasks/timeline.ts index 06dc3443c3845..e981c7269c84c 100644 --- a/x-pack/test/security_solution_cypress/cypress/tasks/timeline.ts +++ b/x-pack/test/security_solution_cypress/cypress/tasks/timeline.ts @@ -330,7 +330,7 @@ export const executeTimelineKQL = (query: string) => { }; export const executeTimelineSearch = (query: string) => { - cy.get(TIMELINE_QUERY).type(`${query} {enter}`, { force: true }); + cy.get(TIMELINE_QUERY).type(`${query} {enter}`); }; export const expandFirstTimelineEventDetails = () => { From 581d66501d99ee01470ecf951263042c660b2310 Mon Sep 17 00:00:00 2001 From: Jan Monschke Date: Thu, 14 Dec 2023 19:52:50 +0100 Subject: [PATCH 09/10] should --- .../e2e/investigations/timelines/search_or_filter.cy.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/search_or_filter.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/search_or_filter.cy.ts index f717fefdb2808..41a79a2777e69 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/search_or_filter.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/search_or_filter.cy.ts @@ -37,7 +37,7 @@ describe('Timeline search and filters', { tags: ['@ess', '@serverless'] }, () => visitWithTimeRange(hostsUrl('allHosts')); }); - it('executes a KQL query', () => { + it('should execute a KQL query', () => { const hostExistsQuery = 'host.name: *'; openTimelineUsingToggle(); executeTimelineKQL(hostExistsQuery); @@ -45,7 +45,7 @@ describe('Timeline search and filters', { tags: ['@ess', '@serverless'] }, () => cy.get(SERVER_SIDE_EVENT_COUNT).should(($count) => expect(+$count.text()).to.be.gt(0)); }); - it('executes a Lucene query', () => { + it('should execute a Lucene query', () => { const messageProcessQuery = 'message:Process\\ zsh*'; openTimelineUsingToggle(); changeTimelineQueryLanguage('lucene'); From 76a9814698b1d07820f94193cb3250d818ef2360 Mon Sep 17 00:00:00 2001 From: Jan Monschke Date: Thu, 14 Dec 2023 19:58:32 +0100 Subject: [PATCH 10/10] extract into functions --- .../timelines/search_or_filter.cy.ts | 17 +++++------------ .../cypress/tasks/timeline.ts | 17 ++++++++++++++++- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/search_or_filter.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/search_or_filter.cy.ts index 41a79a2777e69..ad72dfd2f6ca3 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/search_or_filter.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/search_or_filter.cy.ts @@ -5,13 +5,7 @@ * 2.0. */ -import { - ADD_FILTER, - SERVER_SIDE_EVENT_COUNT, - TIMELINE_KQLMODE_FILTER, - TIMELINE_KQLMODE_SEARCH, - TIMELINE_SEARCH_OR_FILTER, -} from '../../../screens/timeline'; +import { ADD_FILTER, SERVER_SIDE_EVENT_COUNT } from '../../../screens/timeline'; import { LOADING_INDICATOR } from '../../../screens/security_header'; import { login } from '../../../tasks/login'; @@ -22,7 +16,8 @@ import { changeTimelineQueryLanguage, executeTimelineKQL, executeTimelineSearch, - showDataProviderQueryBuilder, + selectKqlFilterMode, + selectKqlSearchMode, } from '../../../tasks/timeline'; import { waitForTimelinesPanelToBeLoaded } from '../../../tasks/timelines'; import { deleteTimelines } from '../../../tasks/api_calls/common'; @@ -64,12 +59,10 @@ describe('Timeline search and filters', { tags: ['@ess', '@serverless'] }, () => openTimelineUsingToggle(); cy.intercept('PATCH', '/api/timeline').as('update'); cy.get(LOADING_INDICATOR).should('not.exist'); - showDataProviderQueryBuilder(); - cy.get(TIMELINE_SEARCH_OR_FILTER).click(); }); it('should be able to update timeline kqlMode with filter', () => { - cy.get(TIMELINE_KQLMODE_FILTER).click(); + selectKqlFilterMode(); addNameToTimelineAndSave('Test'); cy.wait('@update').then(({ response }) => { cy.wrap(response?.statusCode).should('eql', 200); @@ -79,7 +72,7 @@ describe('Timeline search and filters', { tags: ['@ess', '@serverless'] }, () => }); it('should be able to update timeline kqlMode with search', () => { - cy.get(TIMELINE_KQLMODE_SEARCH).click(); + selectKqlSearchMode(); addNameToTimelineAndSave('Test'); cy.wait('@update').then(({ response }) => { cy.wrap(response?.statusCode).should('eql', 200); diff --git a/x-pack/test/security_solution_cypress/cypress/tasks/timeline.ts b/x-pack/test/security_solution_cypress/cypress/tasks/timeline.ts index e981c7269c84c..c71eb590f1fea 100644 --- a/x-pack/test/security_solution_cypress/cypress/tasks/timeline.ts +++ b/x-pack/test/security_solution_cypress/cypress/tasks/timeline.ts @@ -81,6 +81,9 @@ import { SAVE_TIMELINE_ACTION, TOGGLE_DATA_PROVIDER_BTN, SAVE_TIMELINE_ACTION_BTN, + TIMELINE_SEARCH_OR_FILTER, + TIMELINE_KQLMODE_FILTER, + TIMELINE_KQLMODE_SEARCH, } from '../screens/timeline'; import { REFRESH_BUTTON, TIMELINE, TIMELINES_TAB_TEMPLATE } from '../screens/timelines'; @@ -477,8 +480,20 @@ export const expandEventAction = () => { cy.get(TIMELINE_COLLAPSED_ITEMS_BTN).first().click(); }; -export const showDataProviderQueryBuilder = () => { +const showDataProviderQueryBuilder = () => { cy.get(TOGGLE_DATA_PROVIDER_BTN).should('have.attr', 'aria-pressed', 'false'); cy.get(TOGGLE_DATA_PROVIDER_BTN).click(); cy.get(TOGGLE_DATA_PROVIDER_BTN).should('have.attr', 'aria-pressed', 'true'); }; + +export const selectKqlFilterMode = () => { + showDataProviderQueryBuilder(); + cy.get(TIMELINE_SEARCH_OR_FILTER).click(); + cy.get(TIMELINE_KQLMODE_FILTER).click(); +}; + +export const selectKqlSearchMode = () => { + showDataProviderQueryBuilder(); + cy.get(TIMELINE_SEARCH_OR_FILTER).click(); + cy.get(TIMELINE_KQLMODE_SEARCH).click(); +};