Skip to content

Commit

Permalink
update functional test
Browse files Browse the repository at this point in the history
  • Loading branch information
angorayc committed Oct 15, 2020
1 parent b65119b commit fbb4634
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ import {
addNameToTimeline,
addNotesToTimeline,
closeNotes,
closeTimeline,
createNewTimelineTemplate,
markAsFavorite,
openTimelineTemplateFromSettings,
populateTimeline,
waitForTimelineChanges,
} from '../tasks/timeline';
Expand Down Expand Up @@ -71,6 +73,9 @@ describe('Timeline Templates', () => {
closeNotes();
markAsFavorite();
waitForTimelineChanges();
createNewTimelineTemplate();
closeTimeline();
openTimelineTemplateFromSettings(timelineId);

cy.contains(timeline.title).should('exist');
cy.get(TIMELINES_DESCRIPTION).first().should('have.text', timeline.description);
Expand All @@ -84,6 +89,8 @@ describe('Timeline Templates', () => {
cy.get(TIMELINE_TITLE).should('have.attr', 'value', timeline.title);
cy.get(TIMELINE_DESCRIPTION).should('have.attr', 'value', timeline.description);
cy.get(TIMELINE_QUERY).should('have.text', timeline.query);
// Comments this assertion until we agreed what to do with the filters.
// cy.get(TIMELINE_FILTER(timeline.filter)).should('exist');
cy.get(NOTES_COUNT).should('have.text', '1');
cy.get(NOTES_BUTTON).click();
cy.get(NOTES_TEXT_AREA).should('have.attr', 'placeholder', 'Add a Note');
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 fbb4634

Please sign in to comment.