diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/query_tab_content/query_tab_unified_components.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/query_tab_content/query_tab_unified_components.test.tsx index e692e9441caa90..2436e1dd5c0298 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/query_tab_content/query_tab_unified_components.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/query_tab_content/query_tab_unified_components.test.tsx @@ -553,117 +553,149 @@ describe('query tab with unified timeline', () => { }); describe('unified fields list', () => { - it('should add the column when clicked on X sign', async () => { - const field = { - name: 'event.severity', - }; + it( + 'should add the column when clicked on X sign', + async () => { + const field = { + name: 'event.severity', + }; - renderTestComponents(); - expect(await screen.findByTestId('timeline-sidebar')).toBeVisible(); + renderTestComponents(); + expect(await screen.findByTestId('timeline-sidebar')).toBeVisible(); - await waitFor(() => { - expect(screen.getByTestId('fieldListGroupedSelectedFields-count')).toHaveTextContent('11'); - }); + await waitFor(() => { + expect(screen.getByTestId('fieldListGroupedSelectedFields-count')).toHaveTextContent( + '11' + ); + }); - // column exists in the table - expect(screen.getByTestId(`dataGridHeaderCell-${field.name}`)).toBeVisible(); + // column exists in the table + expect(screen.getByTestId(`dataGridHeaderCell-${field.name}`)).toBeVisible(); - fireEvent.click(screen.getAllByTestId(`fieldToggle-${field.name}`)[0]); + fireEvent.click(screen.getAllByTestId(`fieldToggle-${field.name}`)[0]); - // column not longer exists in the table - await waitFor(() => { - expect(screen.getByTestId('fieldListGroupedSelectedFields-count')).toHaveTextContent('10'); - }); - expect(screen.queryAllByTestId(`dataGridHeaderCell-${field.name}`)).toHaveLength(0); - }); + // column not longer exists in the table + await waitFor(() => { + expect(screen.getByTestId('fieldListGroupedSelectedFields-count')).toHaveTextContent( + '10' + ); + }); + expect(screen.queryAllByTestId(`dataGridHeaderCell-${field.name}`)).toHaveLength(0); + }, + SPECIAL_TEST_TIMEOUT + ); - it('should remove the column when clicked on ⊕ sign', async () => { - const field = { - name: 'agent.id', - }; + it( + 'should remove the column when clicked on ⊕ sign', + async () => { + const field = { + name: 'agent.id', + }; - renderTestComponents(); - expect(await screen.findByTestId('timeline-sidebar')).toBeVisible(); + renderTestComponents(); + expect(await screen.findByTestId('timeline-sidebar')).toBeVisible(); - await waitFor(() => { - expect(screen.getByTestId('fieldListGroupedSelectedFields-count')).toHaveTextContent('11'); - }); + await waitFor(() => { + expect(screen.getByTestId('fieldListGroupedSelectedFields-count')).toHaveTextContent( + '11' + ); + }); - expect(screen.queryAllByTestId(`dataGridHeaderCell-${field.name}`)).toHaveLength(0); + expect(screen.queryAllByTestId(`dataGridHeaderCell-${field.name}`)).toHaveLength(0); - // column exists in the table - const availableFields = screen.getByTestId('fieldListGroupedAvailableFields'); + // column exists in the table + const availableFields = screen.getByTestId('fieldListGroupedAvailableFields'); - fireEvent.click(within(availableFields).getByTestId(`fieldToggle-${field.name}`)); + fireEvent.click(within(availableFields).getByTestId(`fieldToggle-${field.name}`)); - await waitFor(() => { - expect(screen.getByTestId('fieldListGroupedSelectedFields-count')).toHaveTextContent('12'); - }); - expect(screen.queryAllByTestId(`dataGridHeaderCell-${field.name}`)).toHaveLength(1); - }); + await waitFor(() => { + expect(screen.getByTestId('fieldListGroupedSelectedFields-count')).toHaveTextContent( + '12' + ); + }); + expect(screen.queryAllByTestId(`dataGridHeaderCell-${field.name}`)).toHaveLength(1); + }, + SPECIAL_TEST_TIMEOUT + ); - it('should should show callout when field search does not matches any field', async () => { - renderTestComponents(); - expect(await screen.findByTestId('timeline-sidebar')).toBeVisible(); + it( + 'should should show callout when field search does not matches any field', + async () => { + renderTestComponents(); + expect(await screen.findByTestId('timeline-sidebar')).toBeVisible(); - await waitFor(() => { - expect(screen.getByTestId('fieldListGroupedAvailableFields-count')).toHaveTextContent('36'); - }); + await waitFor(() => { + expect(screen.getByTestId('fieldListGroupedAvailableFields-count')).toHaveTextContent( + '36' + ); + }); - fireEvent.change(screen.getByTestId('fieldListFiltersFieldSearch'), { - target: { value: 'fake_field' }, - }); + fireEvent.change(screen.getByTestId('fieldListFiltersFieldSearch'), { + target: { value: 'fake_field' }, + }); - await waitFor(() => { - expect( - screen.getByTestId('fieldListGroupedAvailableFieldsNoFieldsCallout-noFieldsMatch') - ).toBeVisible(); - }); - - expect(screen.getByTestId('fieldListGroupedAvailableFields-count')).toHaveTextContent('0'); - }, 10000); - - it('should toggle side bar correctly', async () => { - renderTestComponents(); - expect(await screen.findByTestId('timeline-sidebar')).toBeVisible(); - await waitFor(() => { - expect(screen.getByTestId('fieldListGroupedAvailableFields-count')).toHaveTextContent('36'); - }); - - fireEvent.click(screen.getByTitle('Hide sidebar')); - - await waitFor(() => { - expect(screen.queryAllByTestId('fieldListGroupedAvailableFields-count')).toHaveLength(0); - }); - }, 10000); - - it('should have all populated fields in Available fields section', async () => { - const listOfPopulatedFields = new Set( - flatten( - mockTimelineData.map((dataItem) => - dataItem.data.map((item) => - item.value && item.value.length > 0 ? item.field : undefined + await waitFor(() => { + expect( + screen.getByTestId('fieldListGroupedAvailableFieldsNoFieldsCallout-noFieldsMatch') + ).toBeVisible(); + }); + + expect(screen.getByTestId('fieldListGroupedAvailableFields-count')).toHaveTextContent('0'); + }, + SPECIAL_TEST_TIMEOUT + ); + + it( + 'should toggle side bar correctly', + async () => { + renderTestComponents(); + expect(await screen.findByTestId('timeline-sidebar')).toBeVisible(); + await waitFor(() => { + expect(screen.getByTestId('fieldListGroupedAvailableFields-count')).toHaveTextContent( + '36' + ); + }); + + fireEvent.click(screen.getByTitle('Hide sidebar')); + + await waitFor(() => { + expect(screen.queryAllByTestId('fieldListGroupedAvailableFields-count')).toHaveLength(0); + }); + }, + SPECIAL_TEST_TIMEOUT + ); + + it( + 'should have all populated fields in Available fields section', + async () => { + const listOfPopulatedFields = new Set( + flatten( + mockTimelineData.map((dataItem) => + dataItem.data.map((item) => + item.value && item.value.length > 0 ? item.field : undefined + ) ) - ) - ).filter((item) => typeof item !== 'undefined') - ); + ).filter((item) => typeof item !== 'undefined') + ); - renderTestComponents(); + renderTestComponents(); - expect(await screen.findByTestId('timeline-sidebar')).toBeVisible(); - expect(await screen.findByTestId('discoverDocTable')).toBeVisible(); + expect(await screen.findByTestId('timeline-sidebar')).toBeVisible(); + expect(await screen.findByTestId('discoverDocTable')).toBeVisible(); - changeItemsPerPageTo(100); + changeItemsPerPageTo(100); - const availableFields = screen.getByTestId('fieldListGroupedAvailableFields'); + const availableFields = screen.getByTestId('fieldListGroupedAvailableFields'); - for (const field of listOfPopulatedFields) { - fireEvent.change(screen.getByTestId('fieldListFiltersFieldSearch'), { - target: { value: field }, - }); + for (const field of listOfPopulatedFields) { + fireEvent.change(screen.getByTestId('fieldListFiltersFieldSearch'), { + target: { value: field }, + }); - expect(within(availableFields).getByTestId(`field-${field}`)); - } - }); + expect(within(availableFields).getByTestId(`field-${field}`)); + } + }, + SPECIAL_TEST_TIMEOUT + ); }); }); diff --git a/x-pack/test/security_solution_cypress/cypress/screens/unified_timeline.ts b/x-pack/test/security_solution_cypress/cypress/screens/unified_timeline.ts index f8504cdf798f5d..36aeb7d616128d 100644 --- a/x-pack/test/security_solution_cypress/cypress/screens/unified_timeline.ts +++ b/x-pack/test/security_solution_cypress/cypress/screens/unified_timeline.ts @@ -9,12 +9,16 @@ import { getDataTestSubjectSelector } from '../helpers/common'; export const TIMELINE_DETAILS_FLYOUT_BTN = getDataTestSubjectSelector('docTableExpandToggleColumn'); -export const HOST_DETAILS_FLYOUT = getDataTestSubjectSelector('host-details-button'); +export const HOST_DETAILS_LINK = getDataTestSubjectSelector('host-details-button'); -export const USER_DETAILS_FLYOUT = getDataTestSubjectSelector('users-link-anchor'); +export const USER_DETAILS_LINK = getDataTestSubjectSelector('users-link-anchor'); export const TIMELINE_DETAILS_FLYOUT = getDataTestSubjectSelector('timeline:details-panel:flyout'); +export const HOST_DETAILS_FLYOUT = getDataTestSubjectSelector('host-panel-header'); + +export const USER_DETAILS_FLYOUT = getDataTestSubjectSelector('user-panel-header'); + export const TIMELINE_DETAILS_FLYOUT_CLOSE_BTN = getDataTestSubjectSelector('euiFlyoutCloseButton'); export const TIMELINE_UNIFIED_DATA_GRID = `${getDataTestSubjectSelector( diff --git a/x-pack/test/security_solution_cypress/cypress/tasks/unified_timeline.ts b/x-pack/test/security_solution_cypress/cypress/tasks/unified_timeline.ts index 1004f75fa854ab..c89b8745b1c73d 100644 --- a/x-pack/test/security_solution_cypress/cypress/tasks/unified_timeline.ts +++ b/x-pack/test/security_solution_cypress/cypress/tasks/unified_timeline.ts @@ -9,10 +9,12 @@ import { GET_UNIFIED_DATA_GRID_CELL, GET_UNIFIED_DATA_GRID_CELL_HEADER, HOST_DETAILS_FLYOUT, + HOST_DETAILS_LINK, TIMELINE_DETAILS_FLYOUT, TIMELINE_DETAILS_FLYOUT_BTN, TIMELINE_DETAILS_FLYOUT_CLOSE_BTN, USER_DETAILS_FLYOUT, + USER_DETAILS_LINK, } from '../screens/unified_timeline'; export const openEventDetailsFlyout = (rowIndex: number) => { @@ -21,13 +23,13 @@ export const openEventDetailsFlyout = (rowIndex: number) => { }; export const openHostDetailsFlyout = (rowIndex: number) => { - cy.get(HOST_DETAILS_FLYOUT).eq(rowIndex).click(); - cy.get(TIMELINE_DETAILS_FLYOUT).should('be.visible'); + cy.get(HOST_DETAILS_LINK).eq(rowIndex).click(); + cy.get(HOST_DETAILS_FLYOUT).should('be.visible'); }; export const openUserDetailsFlyout = (rowIndex: number) => { - cy.get(USER_DETAILS_FLYOUT).eq(rowIndex).click(); - cy.get(TIMELINE_DETAILS_FLYOUT).should('be.visible'); + cy.get(USER_DETAILS_LINK).eq(rowIndex).click(); + cy.get(USER_DETAILS_FLYOUT).should('be.visible'); }; export const getUnifiedTableHeaderColumn = (columnName: string) => {