From e85e1d35be7c4bb1721489ad407e22eccaf0c46a Mon Sep 17 00:00:00 2001 From: Angela Chuang <6295984+angorayc@users.noreply.github.com> Date: Fri, 8 Jan 2021 06:59:05 +0000 Subject: [PATCH] [Security Solution] Unskip cypress tests (#86653) * unskip data provider cypress test * remove extra whitespace for filter classes * remove cy.wait * update functional test * fix cypress and add tabType to dataTestSubj * fix cypress test * revert createNewTimeline task * fix dependency * fix line error Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- .../data/public/ui/filter_bar/filter_item.tsx | 9 +++++++- test/functional/services/filter_bar.ts | 10 ++++++++- .../timeline_data_providers.spec.ts | 4 +--- .../cypress/screens/timeline.ts | 22 ++++++++++++++----- .../cypress/tasks/timeline.ts | 1 - .../components/timeline/body/index.tsx | 2 +- .../pinned_tab_content/index.test.tsx | 6 +++-- .../timeline/pinned_tab_content/index.tsx | 9 +++++--- .../timeline/query_tab_content/index.test.tsx | 16 ++++++++++---- .../timeline/query_tab_content/index.tsx | 12 +++++++--- 10 files changed, 66 insertions(+), 25 deletions(-) diff --git a/src/plugins/data/public/ui/filter_bar/filter_item.tsx b/src/plugins/data/public/ui/filter_bar/filter_item.tsx index 5e6fd5323c0b7..6b4cf1d24f7ac 100644 --- a/src/plugins/data/public/ui/filter_bar/filter_item.tsx +++ b/src/plugins/data/public/ui/filter_bar/filter_item.tsx @@ -145,7 +145,14 @@ export function FilterItem(props: Props) { const dataTestSubjNegated = filter.meta.negate ? 'filter-negated' : ''; const dataTestSubjDisabled = `filter-${isDisabled(labelConfig) ? 'disabled' : 'enabled'}`; const dataTestSubjPinned = `filter-${isFilterPinned(filter) ? 'pinned' : 'unpinned'}`; - return `filter ${dataTestSubjDisabled} ${dataTestSubjKey} ${dataTestSubjValue} ${dataTestSubjPinned} ${dataTestSubjNegated}`; + return classNames( + 'filter', + dataTestSubjDisabled, + dataTestSubjKey, + dataTestSubjValue, + dataTestSubjPinned, + dataTestSubjNegated + ); } function getPanels() { diff --git a/test/functional/services/filter_bar.ts b/test/functional/services/filter_bar.ts index de895918efbba..546f83e5b710a 100644 --- a/test/functional/services/filter_bar.ts +++ b/test/functional/services/filter_bar.ts @@ -17,6 +17,7 @@ * under the License. */ +import classNames from 'classnames'; import { FtrProviderContext } from '../ftr_provider_context'; export function FilterBarProvider({ getService, getPageObjects }: FtrProviderContext) { @@ -45,7 +46,14 @@ export function FilterBarProvider({ getService, getPageObjects }: FtrProviderCon const filterPinnedState = pinned ? 'pinned' : 'unpinned'; const filterNegatedState = negated ? 'filter-negated' : ''; return testSubjects.exists( - `filter filter-${filterActivationState} filter-key-${key} filter-value-${value} filter-${filterPinnedState} ${filterNegatedState}`, + classNames( + 'filter', + `filter-${filterActivationState}`, + key !== '' && `filter-key-${key}`, + value !== '' && `filter-value-${value}`, + `filter-${filterPinnedState}`, + filterNegatedState + ), { allowHidden: true, } diff --git a/x-pack/plugins/security_solution/cypress/integration/timeline_data_providers.spec.ts b/x-pack/plugins/security_solution/cypress/integration/timeline_data_providers.spec.ts index d2a20fe1ecdbc..2a1eab44b80f4 100644 --- a/x-pack/plugins/security_solution/cypress/integration/timeline_data_providers.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/timeline_data_providers.spec.ts @@ -25,9 +25,7 @@ import { closeTimeline, createNewTimeline } from '../tasks/timeline'; import { HOSTS_URL } from '../urls/navigation'; import { cleanKibana } from '../tasks/common'; -// FLAKY: https://github.com/elastic/kibana/issues/85098 -// FLAKY: https://github.com/elastic/kibana/issues/62060 -describe.skip('timeline data providers', () => { +describe('timeline data providers', () => { before(() => { cleanKibana(); loginAndWaitForPage(HOSTS_URL); diff --git a/x-pack/plugins/security_solution/cypress/screens/timeline.ts b/x-pack/plugins/security_solution/cypress/screens/timeline.ts index c0299f5ab0c1c..627469e16218e 100644 --- a/x-pack/plugins/security_solution/cypress/screens/timeline.ts +++ b/x-pack/plugins/security_solution/cypress/screens/timeline.ts @@ -86,6 +86,18 @@ export const SAVE_FILTER_BTN = '[data-test-subj="saveFilter"]'; export const SEARCH_OR_FILTER_CONTAINER = '[data-test-subj="timeline-search-or-filter-search-container"]'; +export const QUERY_TAB_EVENTS_TABLE = '[data-test-subj="query-events-table"]'; + +export const QUERY_TAB_EVENTS_BODY = '[data-test-subj="query-tab-flyout-body"]'; + +export const QUERY_TAB_EVENTS_FOOTER = '[data-test-subj="query-tab-flyout-footer"]'; + +export const PINNED_TAB_EVENTS_TABLE = '[data-test-subj="pinned-events-table"]'; + +export const PINNED_TAB_EVENTS_BODY = '[data-test-subj="pinned-tab-flyout-body"]'; + +export const PINNED_TAB_EVENTS_FOOTER = '[data-test-subj="pinned-tab-flyout-footer"]'; + export const SERVER_SIDE_EVENT_COUNT = '[data-test-subj="server-side-event-count"]'; export const STAR_ICON = '[data-test-subj="timeline-favorite-empty-star"]'; @@ -108,10 +120,8 @@ export const TIMELINE_DROPPED_DATA_PROVIDERS = '[data-test-subj="providerContain export const TIMELINE_FIELDS_BUTTON = '[data-test-subj="timeline"] [data-test-subj="show-field-browser"]'; -export const TIMELINE_FILTER = (filter: TimelineFilter) => { - // The space at the end of the line is required. We want to keep it until it is updated. - return `[data-test-subj="filter filter-enabled filter-key-${filter.field} filter-value-${filter.value} filter-unpinned "]`; -}; +export const TIMELINE_FILTER = (filter: TimelineFilter) => + `[data-test-subj="filter filter-enabled filter-key-${filter.field} filter-value-${filter.value} filter-unpinned"]`; export const TIMELINE_FILTER_FIELD = '[data-test-subj="filterFieldSuggestionList"]'; @@ -124,9 +134,9 @@ export const TIMELINE_FILTER_VALUE = export const TIMELINE_FLYOUT = '[data-test-subj="eui-flyout"]'; -export const TIMELINE_FLYOUT_HEADER = '[data-test-subj="eui-flyout-header"]'; +export const TIMELINE_FLYOUT_HEADER = '[data-test-subj="query-tab-flyout-header"]'; -export const TIMELINE_FLYOUT_BODY = '[data-test-subj="eui-flyout-body"]'; +export const TIMELINE_FLYOUT_BODY = '[data-test-subj="query-tab-flyout-body"]'; export const TIMELINE_INSPECT_BUTTON = `${TIMELINE_FLYOUT} [data-test-subj="inspect-icon-button"]`; diff --git a/x-pack/plugins/security_solution/cypress/tasks/timeline.ts b/x-pack/plugins/security_solution/cypress/tasks/timeline.ts index 3196181f2a776..8eb9a989a9125 100644 --- a/x-pack/plugins/security_solution/cypress/tasks/timeline.ts +++ b/x-pack/plugins/security_solution/cypress/tasks/timeline.ts @@ -118,7 +118,6 @@ export const closeTimeline = () => { export const createNewTimeline = () => { cy.get(TIMELINE_SETTINGS_ICON).filter(':visible').click({ force: true }); - cy.wait(1000); cy.get(CREATE_NEW_TIMELINE).should('be.visible'); cy.get(CREATE_NEW_TIMELINE).click(); }; diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/index.tsx index a03f4c07645ad..8f306ef19e036 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/index.tsx @@ -179,7 +179,7 @@ export const BodyComponent = React.memo( { ); - expect(wrapper.find('[data-test-subj="events-table"]').exists()).toEqual(true); + expect( + wrapper.find(`[data-test-subj="${TimelineTabs.pinned}-events-table"]`).exists() + ).toEqual(true); }); it('it shows the timeline footer', () => { diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/pinned_tab_content/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/pinned_tab_content/index.tsx index 1054b5405d9d9..e204578db610c 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/pinned_tab_content/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/pinned_tab_content/index.tsx @@ -173,10 +173,13 @@ export const PinnedTabContentComponent: React.FC = ({ return ( <> - + - + = ({ />