Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SIEM] Improves flyout button Cypress tests time execution #54463

Merged
merged 4 commits into from
Jan 16, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"]';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To verify the clearTimeline() helper is working, I added an invocation of clearTimeline() to the end of the it('renders the data provider of a host dragged from the All Hosts widget on the hosts page) test in x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/timeline/data_providers.spec.ts. I observed that the data provider was not being cleared by clearTimeline(), and traced the issue to this selector, which doesn't appear to match anything.

Changing the selector to the following fixed it:

export const CLOSE_PROVIDER_BADGE_BTN = 'button[title="Remove Data Provider"]';

Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down