From 189525660fcb1337305b7c626b6a2a867483f073 Mon Sep 17 00:00:00 2001 From: Jan Monschke Date: Wed, 10 Jan 2024 13:53:02 +0100 Subject: [PATCH 01/10] context -> describe --- .../cypress/e2e/investigations/timelines/fields_browser.cy.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/fields_browser.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/fields_browser.cy.ts index 776770060e85..8d7e9841050f 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/fields_browser.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/fields_browser.cy.ts @@ -49,10 +49,8 @@ const defaultHeaders = [ { id: 'user.name' }, ]; -// Flaky in serverless tests -// FLAKY: https://github.com/elastic/kibana/issues/169363 -describe.skip('Fields Browser', { tags: ['@ess', '@serverless'] }, () => { context('Fields Browser rendering', () => { +describe('Fields Browser', { tags: ['@ess', '@serverless'] }, () => { beforeEach(() => { login(); visitWithTimeRange(hostsUrl('allHosts')); From 91a20738024c4887ebc05dedec04f88fc2956090 Mon Sep 17 00:00:00 2001 From: Jan Monschke Date: Wed, 10 Jan 2024 13:57:50 +0100 Subject: [PATCH 02/10] remove force clicks/checks/unchecks --- .../cypress/tasks/fields_browser.ts | 24 +++++++------------ .../cypress/tasks/timeline.ts | 2 +- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/x-pack/test/security_solution_cypress/cypress/tasks/fields_browser.ts b/x-pack/test/security_solution_cypress/cypress/tasks/fields_browser.ts index c31196a96a55..f9e83fb449b7 100644 --- a/x-pack/test/security_solution_cypress/cypress/tasks/fields_browser.ts +++ b/x-pack/test/security_solution_cypress/cypress/tasks/fields_browser.ts @@ -29,15 +29,11 @@ export const addsFields = (fields: string[]) => { }; export const addsHostGeoCityNameToTimeline = () => { - cy.get(FIELDS_BROWSER_HOST_GEO_CITY_NAME_CHECKBOX).check({ - force: true, - }); + cy.get(FIELDS_BROWSER_HOST_GEO_CITY_NAME_CHECKBOX).check(); }; export const addsHostGeoContinentNameToTimeline = () => { - cy.get(FIELDS_BROWSER_HOST_GEO_CONTINENT_NAME_CHECKBOX).check({ - force: true, - }); + cy.get(FIELDS_BROWSER_HOST_GEO_CONTINENT_NAME_CHECKBOX).check(); }; export const clearFieldsBrowser = () => { @@ -67,7 +63,7 @@ export const filterFieldsBrowser = (fieldName: string) => { }; export const toggleCategoryFilter = () => { - cy.get(FIELDS_BROWSER_CATEGORIES_FILTER_BUTTON).click({ force: true }); + cy.get(FIELDS_BROWSER_CATEGORIES_FILTER_BUTTON).click(); }; export const toggleCategory = (category: string) => { @@ -79,9 +75,7 @@ export const toggleCategory = (category: string) => { }; export const removesMessageField = () => { - cy.get(FIELDS_BROWSER_MESSAGE_CHECKBOX).uncheck({ - force: true, - }); + cy.get(FIELDS_BROWSER_MESSAGE_CHECKBOX).uncheck(); }; export const removeField = (fieldName: string) => { @@ -89,14 +83,14 @@ export const removeField = (fieldName: string) => { }; export const resetFields = () => { - cy.get(FIELDS_BROWSER_RESET_FIELDS).click({ force: true }); + cy.get(FIELDS_BROWSER_RESET_FIELDS).click(); }; export const activateViewSelected = () => { - cy.get(FIELDS_BROWSER_VIEW_BUTTON).click({ force: true }); - cy.get(FIELDS_BROWSER_VIEW_SELECTED).click({ force: true }); + cy.get(FIELDS_BROWSER_VIEW_BUTTON).click(); + cy.get(FIELDS_BROWSER_VIEW_SELECTED).click(); }; export const activateViewAll = () => { - cy.get(FIELDS_BROWSER_VIEW_BUTTON).click({ force: true }); - cy.get(FIELDS_BROWSER_VIEW_ALL).click({ force: true }); + cy.get(FIELDS_BROWSER_VIEW_BUTTON).click(); + cy.get(FIELDS_BROWSER_VIEW_ALL).click(); }; 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 767123c9875b..93e98cc849f0 100644 --- a/x-pack/test/security_solution_cypress/cypress/tasks/timeline.ts +++ b/x-pack/test/security_solution_cypress/cypress/tasks/timeline.ts @@ -369,7 +369,7 @@ export const markAsFavorite = () => { }; export const openTimelineFieldsBrowser = () => { - cy.get(TIMELINE_FIELDS_BUTTON).first().click({ force: true }); + cy.get(TIMELINE_FIELDS_BUTTON).first().click(); }; export const openTimelineInspectButton = () => { From 04ddc10f120be41f2c5e42d9f102b6d463ea6ed5 Mon Sep 17 00:00:00 2001 From: Jan Monschke Date: Wed, 10 Jan 2024 14:15:30 +0100 Subject: [PATCH 03/10] remove unnecessary calls to openTimelineFieldsBrowser The fields browser is opened in beforeEach --- .../cypress/e2e/investigations/timelines/fields_browser.cy.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/fields_browser.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/fields_browser.cy.ts index 8d7e9841050f..63dcdfac4df5 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/fields_browser.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/fields_browser.cy.ts @@ -169,14 +169,12 @@ describe('Fields Browser', { tags: ['@ess', '@serverless'] }, () => { }); it('restores focus to the Customize Columns button when `Reset Fields` is clicked', () => { - openTimelineFieldsBrowser(); resetFields(); cy.get(TIMELINE_FIELDS_BUTTON).should('have.focus'); }); it('restores focus to the Customize Columns button when Esc is pressed', () => { - openTimelineFieldsBrowser(); cy.get(FIELDS_BROWSER_FILTER_INPUT).type('{esc}'); cy.get(TIMELINE_FIELDS_BUTTON).should('have.focus'); From d5140f79e491f0a968ae520137227da284523aff Mon Sep 17 00:00:00 2001 From: Jan Monschke Date: Wed, 10 Jan 2024 14:16:04 +0100 Subject: [PATCH 04/10] Remove populateTimeline The timeline's data / its rows are not actually tested --- .../e2e/investigations/timelines/fields_browser.cy.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/fields_browser.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/fields_browser.cy.ts index 63dcdfac4df5..f25842250f3e 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/fields_browser.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/fields_browser.cy.ts @@ -34,7 +34,7 @@ import { import { login } from '../../../tasks/login'; import { visitWithTimeRange } from '../../../tasks/navigation'; import { openTimelineUsingToggle } from '../../../tasks/security_main'; -import { openTimelineFieldsBrowser, populateTimeline } from '../../../tasks/timeline'; +import { openTimelineFieldsBrowser } from '../../../tasks/timeline'; import { hostsUrl } from '../../../urls/navigation'; @@ -49,13 +49,12 @@ const defaultHeaders = [ { id: 'user.name' }, ]; - context('Fields Browser rendering', () => { describe('Fields Browser', { tags: ['@ess', '@serverless'] }, () => { + describe('Fields Browser rendering', () => { beforeEach(() => { login(); visitWithTimeRange(hostsUrl('allHosts')); openTimelineUsingToggle(); - populateTimeline(); openTimelineFieldsBrowser(); }); @@ -117,12 +116,11 @@ describe('Fields Browser', { tags: ['@ess', '@serverless'] }, () => { }); }); - context('Editing the timeline', () => { + describe('Editing the timeline', () => { beforeEach(() => { login(); visitWithTimeRange(hostsUrl('allHosts')); openTimelineUsingToggle(); - populateTimeline(); openTimelineFieldsBrowser(); }); From c8cf895c66b990c1f441750c26e39488b47ec546 Mon Sep 17 00:00:00 2001 From: Jan Monschke Date: Wed, 10 Jan 2024 14:25:55 +0100 Subject: [PATCH 05/10] prepare flaky test runner --- 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 fe8585e530f4..4817773ac0ee 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/fields_browser.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/fields_browser.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 42d1970721c949f7b6198f9032e754edcdf8c4c1 Mon Sep 17 00:00:00 2001 From: Jan Monschke Date: Wed, 10 Jan 2024 18:12:25 +0100 Subject: [PATCH 06/10] undo flaky test runner changes --- 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 4817773ac0ee..fe8585e530f4 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/fields_browser.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/fields_browser.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 57eeecc5eeb863d037127a6620305231d0752580 Mon Sep 17 00:00:00 2001 From: Jan Monschke Date: Wed, 10 Jan 2024 18:29:56 +0100 Subject: [PATCH 07/10] replace part of the acceptance test with a unit test --- .../sections/field_browser/field_browser.test.tsx | 5 +++++ .../e2e/investigations/timelines/fields_browser.cy.ts | 10 ---------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/field_browser/field_browser.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/field_browser/field_browser.test.tsx index 5c3a33d5b17c..32a6b1b85019 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/field_browser/field_browser.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/field_browser/field_browser.test.tsx @@ -42,7 +42,12 @@ describe('FieldsBrowser', () => { result.getByTestId('show-field-browser').click(); await waitFor(() => { + // the container is rendered now expect(result.getByTestId('fields-browser-container')).toBeInTheDocument(); + // by default, no categories are selected + expect(result.getByTestId('category-badges')).toHaveTextContent(''); + // the view: all button is shown by default + result.getByText('View: all'); }); }); }); diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/fields_browser.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/fields_browser.cy.ts index f25842250f3e..11d4bfbd6e39 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/fields_browser.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/fields_browser.cy.ts @@ -13,9 +13,7 @@ import { FIELDS_BROWSER_MESSAGE_HEADER, FIELDS_BROWSER_FILTER_INPUT, FIELDS_BROWSER_CATEGORIES_FILTER_CONTAINER, - FIELDS_BROWSER_SELECTED_CATEGORIES_BADGES, FIELDS_BROWSER_CATEGORY_BADGE, - FIELDS_BROWSER_VIEW_BUTTON, } from '../../../screens/fields_browser'; import { TIMELINE_FIELDS_BUTTON } from '../../../screens/timeline'; @@ -58,14 +56,6 @@ describe('Fields Browser', { tags: ['@ess', '@serverless'] }, () => { openTimelineFieldsBrowser(); }); - it('displays all categories (by default)', () => { - cy.get(FIELDS_BROWSER_SELECTED_CATEGORIES_BADGES).should('be.empty'); - }); - - it('displays "view all" option by default', () => { - cy.get(FIELDS_BROWSER_VIEW_BUTTON).should('contain.text', 'View: all'); - }); - it('displays the expected count of categories that match the filter input', () => { const filterInput = 'host.mac'; From 04390a0940532f807f43bfa78c0aaed79b0777f5 Mon Sep 17 00:00:00 2001 From: Jan Monschke Date: Thu, 11 Jan 2024 10:12:40 +0100 Subject: [PATCH 08/10] simplify tests --- .../timelines/fields_browser.cy.ts | 39 ++++++------------- 1 file changed, 11 insertions(+), 28 deletions(-) diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/fields_browser.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/fields_browser.cy.ts index 11d4bfbd6e39..f727973913af 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/fields_browser.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/fields_browser.cy.ts @@ -56,18 +56,12 @@ describe('Fields Browser', { tags: ['@ess', '@serverless'] }, () => { openTimelineFieldsBrowser(); }); - it('displays the expected count of categories that match the filter input', () => { + it('displays the expected count of categories and fields that match the filter input', () => { const filterInput = 'host.mac'; filterFieldsBrowser(filterInput); cy.get(FIELDS_BROWSER_CATEGORIES_COUNT).should('have.text', '2'); - }); - - it('displays a search results label with the expected count of fields matching the filter input', () => { - const filterInput = 'host.mac'; - filterFieldsBrowser(filterInput); - cy.get(FIELDS_BROWSER_FIELDS_COUNT).should('contain.text', '2'); }); @@ -80,28 +74,21 @@ describe('Fields Browser', { tags: ['@ess', '@serverless'] }, () => { activateViewAll(); }); - it('creates the category badge when it is selected', () => { + it('should create the category badge when it is selected', () => { const category = 'host'; + const categoryCheck = 'event'; cy.get(FIELDS_BROWSER_CATEGORY_BADGE(category)).should('not.exist'); toggleCategory(category); cy.get(FIELDS_BROWSER_CATEGORY_BADGE(category)).should('exist'); toggleCategory(category); - }); - - it('search a category should match the category in the category filter', () => { - const category = 'host'; + cy.log('the category filter should contain the filtered category'); filterFieldsBrowser(category); toggleCategoryFilter(); cy.get(FIELDS_BROWSER_CATEGORIES_FILTER_CONTAINER).should('contain.text', category); - }); - it('search a category should filter out non matching categories in the category filter', () => { - const category = 'host'; - const categoryCheck = 'event'; - filterFieldsBrowser(category); - toggleCategoryFilter(); + cy.log('non-matching categories should not be listed in the category filter'); cy.get(FIELDS_BROWSER_CATEGORIES_FILTER_CONTAINER).should('not.contain.text', categoryCheck); }); }); @@ -114,7 +101,7 @@ describe('Fields Browser', { tags: ['@ess', '@serverless'] }, () => { openTimelineFieldsBrowser(); }); - it('removes the message field from the timeline when the user un-checks the field', () => { + it('should remove the message field from the timeline when the user un-checks the field', () => { cy.get(FIELDS_BROWSER_MESSAGE_HEADER).should('exist'); removesMessageField(); @@ -123,7 +110,7 @@ describe('Fields Browser', { tags: ['@ess', '@serverless'] }, () => { cy.get(FIELDS_BROWSER_MESSAGE_HEADER).should('not.exist'); }); - it('adds a field to the timeline when the user clicks the checkbox', () => { + it('should add a field to the timeline when the user clicks the checkbox', () => { const filterInput = 'host.geo.c'; closeFieldsBrowser(); @@ -138,7 +125,7 @@ describe('Fields Browser', { tags: ['@ess', '@serverless'] }, () => { cy.get(FIELDS_BROWSER_HOST_GEO_CITY_NAME_HEADER).should('exist'); }); - it('resets all fields in the timeline when `Reset Fields` is clicked', () => { + it('should reset all fields in the timeline when `Reset Fields` is clicked', () => { const filterInput = 'host.geo.c'; filterFieldsBrowser(filterInput); @@ -154,17 +141,13 @@ describe('Fields Browser', { tags: ['@ess', '@serverless'] }, () => { resetFields(); cy.get(FIELDS_BROWSER_HEADER_HOST_GEO_CONTINENT_NAME_HEADER).should('not.exist'); - }); - - it('restores focus to the Customize Columns button when `Reset Fields` is clicked', () => { - resetFields(); + cy.log('restores focus to the Customize Columns button when `Reset Fields` is clicked'); cy.get(TIMELINE_FIELDS_BUTTON).should('have.focus'); - }); - it('restores focus to the Customize Columns button when Esc is pressed', () => { + cy.log('restores focus to the Customize Columns button when Esc is pressed'); + openTimelineFieldsBrowser(); cy.get(FIELDS_BROWSER_FILTER_INPUT).type('{esc}'); - cy.get(TIMELINE_FIELDS_BUTTON).should('have.focus'); }); }); From 2c76383c0c1aedbf1e17130a5692ba6b198e256e Mon Sep 17 00:00:00 2001 From: Jan Monschke Date: Thu, 11 Jan 2024 10:31:43 +0100 Subject: [PATCH 09/10] simplify tests --- .../timelines/fields_browser.cy.ts | 37 ++++++------------- 1 file changed, 11 insertions(+), 26 deletions(-) diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/fields_browser.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/fields_browser.cy.ts index f727973913af..d15a9f7ca92a 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/fields_browser.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/fields_browser.cy.ts @@ -27,7 +27,6 @@ import { resetFields, toggleCategory, activateViewSelected, - activateViewAll, } from '../../../tasks/fields_browser'; import { login } from '../../../tasks/login'; import { visitWithTimeRange } from '../../../tasks/navigation'; @@ -48,14 +47,14 @@ const defaultHeaders = [ ]; describe('Fields Browser', { tags: ['@ess', '@serverless'] }, () => { - describe('Fields Browser rendering', () => { - beforeEach(() => { - login(); - visitWithTimeRange(hostsUrl('allHosts')); - openTimelineUsingToggle(); - openTimelineFieldsBrowser(); - }); + beforeEach(() => { + login(); + visitWithTimeRange(hostsUrl('allHosts')); + openTimelineUsingToggle(); + openTimelineFieldsBrowser(); + }); + describe('Fields Browser rendering', () => { it('displays the expected count of categories and fields that match the filter input', () => { const filterInput = 'host.mac'; @@ -71,7 +70,6 @@ describe('Fields Browser', { tags: ['@ess', '@serverless'] }, () => { defaultHeaders.forEach((header) => { cy.get(`[data-test-subj="field-${header.id}-checkbox"]`).should('be.checked'); }); - activateViewAll(); }); it('should create the category badge when it is selected', () => { @@ -94,34 +92,21 @@ describe('Fields Browser', { tags: ['@ess', '@serverless'] }, () => { }); describe('Editing the timeline', () => { - beforeEach(() => { - login(); - visitWithTimeRange(hostsUrl('allHosts')); - openTimelineUsingToggle(); - openTimelineFieldsBrowser(); - }); + it('should add/remove columns from the alerts table when the user checks/un-checks them', () => { + const filterInput = 'host.geo.c'; - it('should remove the message field from the timeline when the user un-checks the field', () => { + cy.log('removing the message column'); cy.get(FIELDS_BROWSER_MESSAGE_HEADER).should('exist'); - removesMessageField(); closeFieldsBrowser(); - cy.get(FIELDS_BROWSER_MESSAGE_HEADER).should('not.exist'); - }); - - it('should add a field to the timeline when the user clicks the checkbox', () => { - const filterInput = 'host.geo.c'; - closeFieldsBrowser(); + cy.log('add host.geo.city_name column'); cy.get(FIELDS_BROWSER_HOST_GEO_CITY_NAME_HEADER).should('not.exist'); - openTimelineFieldsBrowser(); - filterFieldsBrowser(filterInput); addsHostGeoCityNameToTimeline(); closeFieldsBrowser(); - cy.get(FIELDS_BROWSER_HOST_GEO_CITY_NAME_HEADER).should('exist'); }); From 8e9520f9df38732f3c63966d2ae3fbb79d4112a3 Mon Sep 17 00:00:00 2001 From: PhilippeOberti Date: Thu, 11 Jan 2024 17:43:53 -0600 Subject: [PATCH 10/10] rename 2 tests to use should... convention --- .../timelines/fields_browser.cy.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/fields_browser.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/fields_browser.cy.ts index d15a9f7ca92a..efa1b50ee814 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/fields_browser.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/fields_browser.cy.ts @@ -55,7 +55,7 @@ describe('Fields Browser', { tags: ['@ess', '@serverless'] }, () => { }); describe('Fields Browser rendering', () => { - it('displays the expected count of categories and fields that match the filter input', () => { + it('should display the expected count of categories and fields that match the filter input', () => { const filterInput = 'host.mac'; filterFieldsBrowser(filterInput); @@ -64,7 +64,7 @@ describe('Fields Browser', { tags: ['@ess', '@serverless'] }, () => { cy.get(FIELDS_BROWSER_FIELDS_COUNT).should('contain.text', '2'); }); - it('displays only the selected fields when "view selected" option is enabled', () => { + it('should display only the selected fields when "view selected" option is enabled', () => { activateViewSelected(); cy.get(FIELDS_BROWSER_FIELDS_COUNT).should('contain.text', `${defaultHeaders.length}`); defaultHeaders.forEach((header) => { @@ -77,16 +77,22 @@ describe('Fields Browser', { tags: ['@ess', '@serverless'] }, () => { const categoryCheck = 'event'; cy.get(FIELDS_BROWSER_CATEGORY_BADGE(category)).should('not.exist'); + toggleCategory(category); + cy.get(FIELDS_BROWSER_CATEGORY_BADGE(category)).should('exist'); + toggleCategory(category); cy.log('the category filter should contain the filtered category'); + filterFieldsBrowser(category); toggleCategoryFilter(); + cy.get(FIELDS_BROWSER_CATEGORIES_FILTER_CONTAINER).should('contain.text', category); cy.log('non-matching categories should not be listed in the category filter'); + cy.get(FIELDS_BROWSER_CATEGORIES_FILTER_CONTAINER).should('not.contain.text', categoryCheck); }); }); @@ -96,17 +102,23 @@ describe('Fields Browser', { tags: ['@ess', '@serverless'] }, () => { const filterInput = 'host.geo.c'; cy.log('removing the message column'); + cy.get(FIELDS_BROWSER_MESSAGE_HEADER).should('exist'); + removesMessageField(); closeFieldsBrowser(); + cy.get(FIELDS_BROWSER_MESSAGE_HEADER).should('not.exist'); cy.log('add host.geo.city_name column'); + cy.get(FIELDS_BROWSER_HOST_GEO_CITY_NAME_HEADER).should('not.exist'); + openTimelineFieldsBrowser(); filterFieldsBrowser(filterInput); addsHostGeoCityNameToTimeline(); closeFieldsBrowser(); + cy.get(FIELDS_BROWSER_HOST_GEO_CITY_NAME_HEADER).should('exist'); }); @@ -128,10 +140,13 @@ describe('Fields Browser', { tags: ['@ess', '@serverless'] }, () => { cy.get(FIELDS_BROWSER_HEADER_HOST_GEO_CONTINENT_NAME_HEADER).should('not.exist'); cy.log('restores focus to the Customize Columns button when `Reset Fields` is clicked'); + cy.get(TIMELINE_FIELDS_BUTTON).should('have.focus'); cy.log('restores focus to the Customize Columns button when Esc is pressed'); + openTimelineFieldsBrowser(); + cy.get(FIELDS_BROWSER_FILTER_INPUT).type('{esc}'); cy.get(TIMELINE_FIELDS_BUTTON).should('have.focus'); });