* refactors timeline test * tries to remove flakiness on indicator match test * fixes issues Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Gloria Hornero <snootchie.boochies@gmail.com>
This commit is contained in:
parent
5745dcab40
commit
8b32279f97
|
@ -51,12 +51,11 @@ import { TIMELINES_URL } from '../../urls/navigation';
|
|||
describe('Timeline Templates', () => {
|
||||
beforeEach(() => {
|
||||
cleanKibana();
|
||||
loginAndWaitForPageWithoutDateRange(TIMELINES_URL);
|
||||
|
||||
cy.intercept('PATCH', '/api/timeline').as('timeline');
|
||||
});
|
||||
|
||||
it('Creates a timeline template', async () => {
|
||||
loginAndWaitForPageWithoutDateRange(TIMELINES_URL);
|
||||
openTimelineUsingToggle();
|
||||
createNewTimelineTemplate();
|
||||
populateTimeline();
|
||||
|
@ -103,20 +102,15 @@ describe('Timeline Templates', () => {
|
|||
});
|
||||
|
||||
it('Create template from timeline', () => {
|
||||
createTimeline(getTimeline());
|
||||
loginAndWaitForPageWithoutDateRange(TIMELINES_URL);
|
||||
waitForTimelinesPanelToBeLoaded();
|
||||
expandEventAction();
|
||||
clickingOnCreateTemplateFromTimelineBtn();
|
||||
|
||||
createTimeline(getTimeline()).then(() => {
|
||||
expandEventAction();
|
||||
clickingOnCreateTemplateFromTimelineBtn();
|
||||
cy.wait('@timeline', { timeout: 100000 }).then(({ request }) => {
|
||||
expect(request.body.timeline).to.haveOwnProperty('templateTimelineId');
|
||||
expect(request.body.timeline).to.haveOwnProperty('description', getTimeline().description);
|
||||
expect(request.body.timeline.kqlQuery.filterQuery.kuery).to.haveOwnProperty(
|
||||
'expression',
|
||||
getTimeline().query
|
||||
);
|
||||
cy.get(TIMELINE_FLYOUT_WRAPPER).should('have.css', 'visibility', 'visible');
|
||||
});
|
||||
});
|
||||
cy.wait('@timeline', { timeout: 100000 });
|
||||
cy.get(TIMELINE_FLYOUT_WRAPPER).should('have.css', 'visibility', 'visible');
|
||||
cy.get(TIMELINE_DESCRIPTION).should('have.text', getTimeline().description);
|
||||
cy.get(TIMELINE_QUERY).should('have.text', getTimeline().query);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -23,9 +23,9 @@ import {
|
|||
import { createTimelineTemplate } from '../../tasks/api_calls/timelines';
|
||||
|
||||
import { cleanKibana } from '../../tasks/common';
|
||||
|
||||
import { loginAndWaitForPage, loginAndWaitForPageWithoutDateRange } from '../../tasks/login';
|
||||
import { openTimelineUsingToggle } from '../../tasks/security_main';
|
||||
import { selectCustomTemplates } from '../../tasks/templates';
|
||||
import {
|
||||
addEqlToTimeline,
|
||||
addFilter,
|
||||
|
@ -115,22 +115,22 @@ describe('Timelines', (): void => {
|
|||
|
||||
describe('Create a timeline from a template', () => {
|
||||
before(() => {
|
||||
cy.intercept('/api/timeline*').as('timeline');
|
||||
cleanKibana();
|
||||
createTimelineTemplate(getTimeline());
|
||||
loginAndWaitForPageWithoutDateRange(TIMELINE_TEMPLATES_URL);
|
||||
waitForTimelinesPanelToBeLoaded();
|
||||
});
|
||||
|
||||
it('Should have the same query and open the timeline modal', () => {
|
||||
createTimelineTemplate(getTimeline()).then(() => {
|
||||
expandEventAction();
|
||||
cy.intercept('/api/timeline').as('timeline');
|
||||
selectCustomTemplates();
|
||||
cy.wait('@timeline', { timeout: 100000 });
|
||||
expandEventAction();
|
||||
clickingOnCreateTimelineFormTemplateBtn();
|
||||
cy.wait('@timeline', { timeout: 100000 });
|
||||
|
||||
clickingOnCreateTimelineFormTemplateBtn();
|
||||
cy.wait('@timeline', { timeout: 100000 });
|
||||
|
||||
cy.get(TIMELINE_FLYOUT_WRAPPER).should('have.css', 'visibility', 'visible');
|
||||
cy.get(TIMELINE_DESCRIPTION).should('have.text', getTimeline().description);
|
||||
cy.get(TIMELINE_QUERY).should('have.text', getTimeline().query);
|
||||
});
|
||||
cy.get(TIMELINE_FLYOUT_WRAPPER).should('have.css', 'visibility', 'visible');
|
||||
cy.get(TIMELINE_DESCRIPTION).should('have.text', getTimeline().description);
|
||||
cy.get(TIMELINE_QUERY).should('have.text', getTimeline().query);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
export const CUSTOM_TEMPLATES = '[data-test-subj="Custom templates"]';
|
|
@ -72,15 +72,13 @@ export const duplicateFirstRule = () => {
|
|||
* flake.
|
||||
*/
|
||||
export const duplicateRuleFromMenu = () => {
|
||||
const click = ($el: Cypress.ObjectLike) => cy.wrap($el).click({ force: true });
|
||||
cy.get(LOADING_INDICATOR).should('not.exist');
|
||||
cy.root()
|
||||
.pipe(($el) => {
|
||||
$el.find(ALL_ACTIONS).trigger('click');
|
||||
return $el.find(DUPLICATE_RULE_MENU_PANEL_BTN);
|
||||
})
|
||||
.should(($el) => expect($el).to.be.visible);
|
||||
cy.get(ALL_ACTIONS).pipe(click);
|
||||
cy.get(DUPLICATE_RULE_MENU_PANEL_BTN).should('be.visible');
|
||||
|
||||
// Because of a fade effect and fast clicking this can produce more than one click
|
||||
cy.get(DUPLICATE_RULE_MENU_PANEL_BTN).pipe(($el) => $el.trigger('click'));
|
||||
cy.get(DUPLICATE_RULE_MENU_PANEL_BTN).pipe(click);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
12
x-pack/plugins/security_solution/cypress/tasks/templates.ts
Normal file
12
x-pack/plugins/security_solution/cypress/tasks/templates.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { CUSTOM_TEMPLATES } from '../screens/templates';
|
||||
|
||||
export const selectCustomTemplates = () => {
|
||||
cy.get(CUSTOM_TEMPLATES).click({ force: true });
|
||||
};
|
|
@ -390,5 +390,10 @@ export const clickingOnCreateTemplateFromTimelineBtn = () => {
|
|||
};
|
||||
|
||||
export const expandEventAction = () => {
|
||||
cy.get(TIMELINE_COLLAPSED_ITEMS_BTN).first().click();
|
||||
cy.waitUntil(() => {
|
||||
cy.get(TIMELINE_COLLAPSED_ITEMS_BTN).should('exist');
|
||||
cy.get(TIMELINE_COLLAPSED_ITEMS_BTN).should('be.visible');
|
||||
return cy.get(TIMELINE_COLLAPSED_ITEMS_BTN).then(($el) => $el.length === 1);
|
||||
});
|
||||
cy.get(TIMELINE_COLLAPSED_ITEMS_BTN).click();
|
||||
};
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { LOADING_INDICATOR } from '../screens/security_header';
|
||||
import {
|
||||
TIMELINE_CHECKBOX,
|
||||
BULK_ACTIONS,
|
||||
|
@ -24,6 +25,8 @@ export const openTimeline = (id: string) => {
|
|||
cy.get(TIMELINE(id)).should('be.visible').pipe(click);
|
||||
};
|
||||
|
||||
export const waitForTimelinesPanelToBeLoaded = (): Cypress.Chainable<JQuery<HTMLElement>> => {
|
||||
return cy.get(TIMELINES_TABLE).should('exist');
|
||||
export const waitForTimelinesPanelToBeLoaded = () => {
|
||||
cy.get(LOADING_INDICATOR).should('exist');
|
||||
cy.get(LOADING_INDICATOR).should('not.exist');
|
||||
cy.get(TIMELINES_TABLE).should('exist');
|
||||
};
|
||||
|
|
|
@ -62,6 +62,7 @@ export const SearchRow = React.memo<Props>(
|
|||
? i18n.SEARCH_PLACEHOLDER
|
||||
: i18n.SEARCH_TEMPLATE_PLACEHOLDER,
|
||||
incremental: false,
|
||||
'data-test-subj': 'search-bar',
|
||||
}),
|
||||
[timelineType]
|
||||
);
|
||||
|
@ -70,7 +71,7 @@ export const SearchRow = React.memo<Props>(
|
|||
<SearchRowContainer>
|
||||
<SearchRowFlexGroup gutterSize="s">
|
||||
<EuiFlexItem>
|
||||
<EuiSearchBar data-test-subj="search-bar" box={searchBox} onChange={onQueryChange} />
|
||||
<EuiSearchBar box={searchBox} onChange={onQueryChange} />
|
||||
</EuiFlexItem>
|
||||
|
||||
<EuiFlexItem grow={false}>
|
||||
|
|
|
@ -97,6 +97,7 @@ export const useTimelineStatus = ({
|
|||
onClick={onFilterClicked.bind(null, tab.id)}
|
||||
withNext={tab.withNext}
|
||||
isDisabled={tab.disabled}
|
||||
data-test-subj={tab.name}
|
||||
>
|
||||
{tab.name}
|
||||
</EuiFilterButton>
|
||||
|
|
Loading…
Reference in a new issue