From 0c37f5958906f9a0ed2f8714e99f8326dd979e54 Mon Sep 17 00:00:00 2001 From: Gloria Hornero Date: Fri, 10 Jan 2020 16:12:36 +0100 Subject: [PATCH 1/2] refactor --- .../siem/cypress/integration/lib/timeline/helpers.ts | 11 +++++++++++ .../cypress/integration/lib/timeline/selectors.ts | 4 ++++ .../smoke_tests/timeline/flyout_button.spec.ts | 8 ++++++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/x-pack/legacy/plugins/siem/cypress/integration/lib/timeline/helpers.ts b/x-pack/legacy/plugins/siem/cypress/integration/lib/timeline/helpers.ts index 8fa1a03840e3ba..583b67d23d620e 100644 --- a/x-pack/legacy/plugins/siem/cypress/integration/lib/timeline/helpers.ts +++ b/x-pack/legacy/plugins/siem/cypress/integration/lib/timeline/helpers.ts @@ -7,6 +7,8 @@ import { drag, drop } from '../drag_n_drop/helpers'; import { ALL_HOSTS_WIDGET_DRAGGABLE_HOSTS } from '../hosts/selectors'; import { + CLOSE_PROVIDER_BADGE_BTN, + CLOSE_TIMELINE_BTN, SEARCH_OR_FILTER_CONTAINER, SERVER_SIDE_EVENT_COUNT, TIMELINE_DATA_PROVIDERS, @@ -19,6 +21,15 @@ import { DEFAULT_TIMEOUT } from '../util/helpers'; export const toggleTimelineVisibility = () => cy.get(TIMELINE_TOGGLE_BUTTON, { timeout: DEFAULT_TIMEOUT }).click(); +export const clearTimeline = () => { + cy.get(TIMELINE_DATA_PROVIDERS).then($provider => { + if ($provider.find(CLOSE_PROVIDER_BADGE_BTN).length === 1) { + cy.get(CLOSE_PROVIDER_BADGE_BTN).click(); + } + }); + cy.get(CLOSE_TIMELINE_BTN).click({ force: true }); +}; + /** Drags and drops a host from the `All Hosts` widget on the `Hosts` page to the timeline */ export const dragFromAllHostsToTimeline = () => { cy.get(ALL_HOSTS_WIDGET_DRAGGABLE_HOSTS) diff --git a/x-pack/legacy/plugins/siem/cypress/integration/lib/timeline/selectors.ts b/x-pack/legacy/plugins/siem/cypress/integration/lib/timeline/selectors.ts index 7dc98072b52f83..d6829431142bcc 100644 --- a/x-pack/legacy/plugins/siem/cypress/integration/lib/timeline/selectors.ts +++ b/x-pack/legacy/plugins/siem/cypress/integration/lib/timeline/selectors.ts @@ -36,3 +36,7 @@ export const TOGGLE_TIMELINE_EXPAND_EVENT = '[data-test-subj="expand-event"]'; /** The body of the timeline flyout */ export const TIMELINE_FLYOUT_BODY = '[data-test-subj="eui-flyout-body"]'; + +export const CLOSE_TIMELINE_BTN = '[data-test-subj="close-timeline"]'; + +export const CLOSE_PROVIDER_BADGE_BTN = '[data-test-subj="closeProviderBadge"]'; diff --git a/x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/timeline/flyout_button.spec.ts b/x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/timeline/flyout_button.spec.ts index 5b0ac03ae87dc0..170765ea9f249b 100644 --- a/x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/timeline/flyout_button.spec.ts +++ b/x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/timeline/flyout_button.spec.ts @@ -13,13 +13,17 @@ import { HOSTS_PAGE } from '../../lib/urls'; import { waitForAllHostsWidget } from '../../lib/hosts/helpers'; import { loginAndWaitForPage } from '../../lib/util/helpers'; import { drag } from '../../lib/drag_n_drop/helpers'; -import { toggleTimelineVisibility } from '../../lib/timeline/helpers'; +import { clearTimeline, toggleTimelineVisibility } from '../../lib/timeline/helpers'; describe('timeline flyout button', () => { - beforeEach(() => { + before(() => { loginAndWaitForPage(HOSTS_PAGE); }); + afterEach(() => { + clearTimeline(); + }); + it('toggles open the timeline', () => { toggleTimelineVisibility(); From b128c644c99c9986546819c317b0fa067be2bb39 Mon Sep 17 00:00:00 2001 From: Gloria Hornero Date: Sun, 12 Jan 2020 17:59:20 +0100 Subject: [PATCH 2/2] replaces 'clearTimeline' for 'createNewTimeline' --- .../cypress/integration/lib/timeline/helpers.ts | 13 +++++-------- .../cypress/integration/lib/timeline/selectors.ts | 4 +++- .../smoke_tests/timeline/flyout_button.spec.ts | 10 ++++++++-- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/x-pack/legacy/plugins/siem/cypress/integration/lib/timeline/helpers.ts b/x-pack/legacy/plugins/siem/cypress/integration/lib/timeline/helpers.ts index 583b67d23d620e..ef2c19bd7e7378 100644 --- a/x-pack/legacy/plugins/siem/cypress/integration/lib/timeline/helpers.ts +++ b/x-pack/legacy/plugins/siem/cypress/integration/lib/timeline/helpers.ts @@ -7,11 +7,12 @@ import { drag, drop } from '../drag_n_drop/helpers'; import { ALL_HOSTS_WIDGET_DRAGGABLE_HOSTS } from '../hosts/selectors'; import { - CLOSE_PROVIDER_BADGE_BTN, CLOSE_TIMELINE_BTN, + CREATE_NEW_TIMELINE, SEARCH_OR_FILTER_CONTAINER, SERVER_SIDE_EVENT_COUNT, TIMELINE_DATA_PROVIDERS, + TIMELINE_SETTINGS, TIMELINE_TOGGLE_BUTTON, TOGGLE_TIMELINE_EXPAND_EVENT, } from './selectors'; @@ -21,12 +22,9 @@ import { DEFAULT_TIMEOUT } from '../util/helpers'; export const toggleTimelineVisibility = () => cy.get(TIMELINE_TOGGLE_BUTTON, { timeout: DEFAULT_TIMEOUT }).click(); -export const clearTimeline = () => { - cy.get(TIMELINE_DATA_PROVIDERS).then($provider => { - if ($provider.find(CLOSE_PROVIDER_BADGE_BTN).length === 1) { - cy.get(CLOSE_PROVIDER_BADGE_BTN).click(); - } - }); +export const createNewTimeline = () => { + cy.get(TIMELINE_SETTINGS).click(); + cy.get(CREATE_NEW_TIMELINE).click(); cy.get(CLOSE_TIMELINE_BTN).click({ force: true }); }; @@ -35,7 +33,6 @@ export const dragFromAllHostsToTimeline = () => { cy.get(ALL_HOSTS_WIDGET_DRAGGABLE_HOSTS) .first() .then(host => drag(host)); - cy.get(TIMELINE_DATA_PROVIDERS).then(dataProvidersDropArea => drop(dataProvidersDropArea)); }; diff --git a/x-pack/legacy/plugins/siem/cypress/integration/lib/timeline/selectors.ts b/x-pack/legacy/plugins/siem/cypress/integration/lib/timeline/selectors.ts index d6829431142bcc..0ec0c506cbb1ad 100644 --- a/x-pack/legacy/plugins/siem/cypress/integration/lib/timeline/selectors.ts +++ b/x-pack/legacy/plugins/siem/cypress/integration/lib/timeline/selectors.ts @@ -39,4 +39,6 @@ export const TIMELINE_FLYOUT_BODY = '[data-test-subj="eui-flyout-body"]'; export const CLOSE_TIMELINE_BTN = '[data-test-subj="close-timeline"]'; -export const CLOSE_PROVIDER_BADGE_BTN = '[data-test-subj="closeProviderBadge"]'; +export const TIMELINE_SETTINGS = '[data-test-subj="settings-gear"]'; + +export const CREATE_NEW_TIMELINE = '[data-test-subj="timeline-new"]'; diff --git a/x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/timeline/flyout_button.spec.ts b/x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/timeline/flyout_button.spec.ts index 170765ea9f249b..63fe56371a4cd8 100644 --- a/x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/timeline/flyout_button.spec.ts +++ b/x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/timeline/flyout_button.spec.ts @@ -13,7 +13,7 @@ import { HOSTS_PAGE } from '../../lib/urls'; import { waitForAllHostsWidget } from '../../lib/hosts/helpers'; import { loginAndWaitForPage } from '../../lib/util/helpers'; import { drag } from '../../lib/drag_n_drop/helpers'; -import { clearTimeline, toggleTimelineVisibility } from '../../lib/timeline/helpers'; +import { createNewTimeline, toggleTimelineVisibility } from '../../lib/timeline/helpers'; describe('timeline flyout button', () => { before(() => { @@ -21,7 +21,13 @@ describe('timeline flyout button', () => { }); afterEach(() => { - clearTimeline(); + cy.get('[data-test-subj="kibanaChrome"]').then($page => { + if ($page.find('[data-test-subj="flyoutOverlay"]').length === 1) { + toggleTimelineVisibility(); + } + }); + + createNewTimeline(); }); it('toggles open the timeline', () => {