Skip to content

Commit

Permalink
[SIEM] Improves flyout button Cypress tests time execution (elastic#5…
Browse files Browse the repository at this point in the history
…4463)

* refactor

* replaces 'clearTimeline' for 'createNewTimeline'

Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
MadameSheema and elasticmachine committed Jan 16, 2020
1 parent c344a2e commit e3392b0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@
import { drag, drop } from '../drag_n_drop/helpers';
import { ALL_HOSTS_WIDGET_DRAGGABLE_HOSTS } from '../hosts/selectors';
import {
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';
Expand All @@ -19,12 +22,17 @@ import { DEFAULT_TIMEOUT } from '../util/helpers';
export const toggleTimelineVisibility = () =>
cy.get(TIMELINE_TOGGLE_BUTTON, { timeout: DEFAULT_TIMEOUT }).click();

export const createNewTimeline = () => {
cy.get(TIMELINE_SETTINGS).click();
cy.get(CREATE_NEW_TIMELINE).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)
.first()
.then(host => drag(host));

cy.get(TIMELINE_DATA_PROVIDERS).then(dataProvidersDropArea => drop(dataProvidersDropArea));
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,9 @@ 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 TIMELINE_SETTINGS = '[data-test-subj="settings-gear"]';

export const CREATE_NEW_TIMELINE = '[data-test-subj="timeline-new"]';
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,23 @@ 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 { createNewTimeline, toggleTimelineVisibility } from '../../lib/timeline/helpers';

describe('timeline flyout button', () => {
beforeEach(() => {
before(() => {
loginAndWaitForPage(HOSTS_PAGE);
});

afterEach(() => {
cy.get('[data-test-subj="kibanaChrome"]').then($page => {
if ($page.find('[data-test-subj="flyoutOverlay"]').length === 1) {
toggleTimelineVisibility();
}
});

createNewTimeline();
});

it('toggles open the timeline', () => {
toggleTimelineVisibility();

Expand Down

0 comments on commit e3392b0

Please sign in to comment.