Skip to content

Commit

Permalink
[Security Solution] Cypress template creation (elastic#80180)
Browse files Browse the repository at this point in the history
* init tests

* fix cypress test

* remove console

* fix functional test

* update functional test

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
angorayc and kibanamachine committed Oct 15, 2020
1 parent 088cc19 commit 0819cea
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ import { openTimeline } from '../tasks/timelines';

import { OVERVIEW_URL } from '../urls/navigation';

// FLAKY: https://github.com/elastic/kibana/issues/79389
describe.skip('Timelines', () => {
describe('Timelines', () => {
before(() => {
cy.server();
cy.route('PATCH', '**/api/timeline').as('timeline');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import {
NOTES_BUTTON,
NOTES_COUNT,
NOTES_TEXT_AREA,
PIN_EVENT,
TIMELINE_DESCRIPTION,
// TIMELINE_FILTER,
TIMELINE_QUERY,
TIMELINE_TITLE,
} from '../screens/timeline';
Expand All @@ -35,7 +35,7 @@ import {
closeTimeline,
createNewTimelineTemplate,
markAsFavorite,
openTimelineFromSettings,
openTimelineTemplateFromSettings,
populateTimeline,
waitForTimelineChanges,
} from '../tasks/timeline';
Expand All @@ -55,12 +55,11 @@ describe('Timeline Templates', () => {
createNewTimelineTemplate();
populateTimeline();
addFilter(timeline.filter);
// To fix
// cy.get(PIN_EVENT).should(
// 'have.attr',
// 'aria-label',
// 'This event may not be pinned while editing a template timeline'
// );
cy.get(PIN_EVENT).should(
'have.attr',
'aria-label',
'This event may not be pinned while editing a template timeline'
);
cy.get(LOCKED_ICON).should('be.visible');

addNameToTimeline(timeline.title);
Expand All @@ -76,7 +75,7 @@ describe('Timeline Templates', () => {
waitForTimelineChanges();
createNewTimelineTemplate();
closeTimeline();
openTimelineFromSettings();
openTimelineTemplateFromSettings(timelineId);

cy.contains(timeline.title).should('exist');
cy.get(TIMELINES_DESCRIPTION).first().should('have.text', timeline.description);
Expand Down
5 changes: 5 additions & 0 deletions x-pack/plugins/security_solution/cypress/screens/timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ export const NOTES_COUNT = '[data-test-subj="timeline-notes-count"]';

export const OPEN_TIMELINE_ICON = '[data-test-subj="open-timeline-button"]';

export const OPEN_TIMELINE_TEMPLATE_ICON =
'[data-test-subj="open-timeline-modal-body-filter-template"]';

export const PIN_EVENT = '[data-test-subj="pin"]';

export const PROVIDER_BADGE = '[data-test-subj="providerBadge"]';
Expand Down Expand Up @@ -98,6 +101,8 @@ export const TIMELINE_FILTER = (filter: TimelineFilter) => {

export const TIMELINE_FILTER_FIELD = '[data-test-subj="filterFieldSuggestionList"]';

export const TIMELINE_TITLE_BY_ID = (id: string) => `[data-test-subj="title-${id}"]`;

export const TIMELINE_FILTER_OPERATOR = '[data-test-subj="filterOperatorList"]';

export const TIMELINE_FILTER_VALUE =
Expand Down
11 changes: 9 additions & 2 deletions x-pack/plugins/security_solution/cypress/tasks/timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ import {
TIMELINE_INSPECT_BUTTON,
TIMELINE_SETTINGS_ICON,
TIMELINE_TITLE,
TIMELINE_TITLE_BY_ID,
TIMESTAMP_TOGGLE_FIELD,
TOGGLE_TIMELINE_EXPAND_EVENT,
CREATE_NEW_TIMELINE_TEMPLATE,
OPEN_TIMELINE_TEMPLATE_ICON,
} from '../screens/timeline';
import { TIMELINES_TABLE } from '../screens/timelines';

Expand All @@ -69,8 +71,7 @@ export const addNotesToTimeline = (notes: string) => {

export const addFilter = (filter: TimelineFilter) => {
cy.get(ADD_FILTER).click();
cy.get(TIMELINE_FILTER_FIELD).type(filter.field);
cy.get(COMBO_BOX).contains(filter.field).click();
cy.get(TIMELINE_FILTER_FIELD).type(`${filter.field}{downarrow}{enter}`);
cy.get(TIMELINE_FILTER_OPERATOR).type(filter.operator);
cy.get(COMBO_BOX).contains(filter.operator).click();
if (filter.operator !== 'exists') {
Expand Down Expand Up @@ -146,6 +147,12 @@ export const openTimelineFromSettings = () => {
cy.get(OPEN_TIMELINE_ICON).click({ force: true });
};

export const openTimelineTemplateFromSettings = (id: string) => {
openTimelineFromSettings();
cy.get(OPEN_TIMELINE_TEMPLATE_ICON).click({ force: true });
cy.get(TIMELINE_TITLE_BY_ID(id)).click({ force: true });
};

export const openTimelineSettings = () => {
cy.get(TIMELINE_SETTINGS_ICON).trigger('click', { force: true });
};
Expand Down

0 comments on commit 0819cea

Please sign in to comment.