From df99216baee1ddae6c6f8a472c0c3dabb885139c Mon Sep 17 00:00:00 2001 From: MadameSheema Date: Tue, 19 Jan 2021 10:07:29 +0100 Subject: [PATCH] improves timeline creation cypress test (#88628) --- .../integration/timeline_creation.spec.ts | 24 +++++++++---------- .../cypress/tasks/timeline.ts | 12 +++++++++- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/x-pack/plugins/security_solution/cypress/integration/timeline_creation.spec.ts b/x-pack/plugins/security_solution/cypress/integration/timeline_creation.spec.ts index 0025516c7571..2cdbfef4f658 100644 --- a/x-pack/plugins/security_solution/cypress/integration/timeline_creation.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/timeline_creation.spec.ts @@ -32,9 +32,8 @@ import { cleanKibana } from '../tasks/common'; import { loginAndWaitForPage } from '../tasks/login'; import { openTimelineUsingToggle } from '../tasks/security_main'; import { - addDescriptionToTimeline, addFilter, - addNameToTimeline, + addNameAndDescriptionToTimeline, addNotesToTimeline, closeTimeline, createNewTimeline, @@ -58,21 +57,20 @@ describe('Timelines', () => { loginAndWaitForPage(OVERVIEW_URL); openTimelineUsingToggle(); - populateTimeline(); - addFilter(timeline.filter); - pinFirstEvent(); - - cy.get(PIN_EVENT) - .should('have.attr', 'aria-label') - .and('match', /Unpin the event in row 2/); - cy.get(LOCKED_ICON).should('be.visible'); - - addNameToTimeline(timeline.title); + addNameAndDescriptionToTimeline(timeline); cy.wait('@timeline').then(({ response }) => { const timelineId = response!.body.data.persistTimeline.timeline.savedObjectId; - addDescriptionToTimeline(timeline.description); + populateTimeline(); + addFilter(timeline.filter); + pinFirstEvent(); + + cy.get(PIN_EVENT) + .should('have.attr', 'aria-label') + .and('match', /Unpin the event in row 2/); + cy.get(LOCKED_ICON).should('be.visible'); + addNotesToTimeline(timeline.notes); markAsFavorite(); waitForTimelineChanges(); diff --git a/x-pack/plugins/security_solution/cypress/tasks/timeline.ts b/x-pack/plugins/security_solution/cypress/tasks/timeline.ts index ee876abd8e8d..204c9aa0fab6 100644 --- a/x-pack/plugins/security_solution/cypress/tasks/timeline.ts +++ b/x-pack/plugins/security_solution/cypress/tasks/timeline.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { TimelineFilter } from '../objects/timeline'; +import { Timeline, TimelineFilter } from '../objects/timeline'; import { ALL_CASES_CREATE_NEW_CASE_TABLE_BTN } from '../screens/all_cases'; @@ -72,6 +72,16 @@ export const addNameToTimeline = (name: string) => { cy.get(TIMELINE_TITLE_INPUT).should('not.exist'); }; +export const addNameAndDescriptionToTimeline = (timeline: Timeline) => { + cy.get(TIMELINE_EDIT_MODAL_OPEN_BUTTON).first().click(); + cy.get(TIMELINE_TITLE_INPUT).type(`${timeline.title}{enter}`); + cy.get(TIMELINE_TITLE_INPUT).should('have.attr', 'value', timeline.title); + cy.get(TIMELINE_DESCRIPTION_INPUT).type(timeline.description); + cy.get(TIMELINE_DESCRIPTION_INPUT).invoke('val').should('equal', timeline.description); + cy.get(TIMELINE_EDIT_MODAL_SAVE_BUTTON).click(); + cy.get(TIMELINE_TITLE_INPUT).should('not.exist'); +}; + export const addNotesToTimeline = (notes: string) => { cy.get(NOTES_TAB_BUTTON).click(); cy.get(NOTES_TEXT_AREA).type(notes);