From 5649d300af84b973e384cd35a035f339b1018eee Mon Sep 17 00:00:00 2001 From: Gloria Hornero Date: Mon, 24 Aug 2020 18:09:08 +0200 Subject: [PATCH] asserts the content of the exported timeline --- .../cypress/integration/timelines_export.spec.ts | 11 +++++++---- .../test_files/expected_timelines_export.ndjson | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 x-pack/plugins/security_solution/cypress/test_files/expected_timelines_export.ndjson diff --git a/x-pack/plugins/security_solution/cypress/integration/timelines_export.spec.ts b/x-pack/plugins/security_solution/cypress/integration/timelines_export.spec.ts index 3b51c1692c8df..0fa206342f276 100644 --- a/x-pack/plugins/security_solution/cypress/integration/timelines_export.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/timelines_export.spec.ts @@ -10,6 +10,8 @@ import { loginAndWaitForPageWithoutDateRange } from '../tasks/login'; import { TIMELINES_URL } from '../urls/navigation'; +const EXPECTED_EXPORTED_TIMELINE_PATH = 'cypress/test_files/expected_timelines_export.ndjson'; + describe('Export timelines', () => { before(() => { esArchiverLoad('timeline'); @@ -23,13 +25,14 @@ describe('Export timelines', () => { it('Exports a custom timeline', () => { loginAndWaitForPageWithoutDateRange(TIMELINES_URL); - waitForTimelinesPanelToBeLoaded(); - exportFirstTimeline(); - cy.wait('@export').then((xhr) => { - cy.wrap(xhr.status).should('eql', 200); + cy.wait('@export').then((response) => { + cy.wrap(response.status).should('eql', 200); + cy.readFile(EXPECTED_EXPORTED_TIMELINE_PATH).then(($expectedExportedJson) => { + cy.wrap(response.xhr.responseText).should('eql', $expectedExportedJson); + }); }); }); }); diff --git a/x-pack/plugins/security_solution/cypress/test_files/expected_timelines_export.ndjson b/x-pack/plugins/security_solution/cypress/test_files/expected_timelines_export.ndjson new file mode 100644 index 0000000000000..9cca356a8b052 --- /dev/null +++ b/x-pack/plugins/security_solution/cypress/test_files/expected_timelines_export.ndjson @@ -0,0 +1 @@ +{"savedObjectId":"0162c130-78be-11ea-9718-118a926974a4","version":"WzcsMV0=","columns":[{"columnHeaderType":"not-filtered","id":"@timestamp"},{"columnHeaderType":"not-filtered","id":"message"},{"columnHeaderType":"not-filtered","id":"event.category"},{"columnHeaderType":"not-filtered","id":"event.action"},{"columnHeaderType":"not-filtered","id":"host.name"},{"columnHeaderType":"not-filtered","id":"source.ip"},{"columnHeaderType":"not-filtered","id":"destination.ip"},{"columnHeaderType":"not-filtered","id":"user.name"}],"created":1586256805054,"createdBy":"elastic","dataProviders":[],"dateRange":{"end":1586256837669,"start":1546343624710},"description":"description","eventType":"all","filters":[],"kqlMode":"filter","kqlQuery":{"filterQuery":{"kuery":{"expression":"host.name:*","kind":"kuery"},"serializedQuery":"{\"bool\":{\"should\":[{\"exists\":{\"field\":\"host.name\"}}],\"minimum_should_match\":1}}"}},"savedQueryId":null,"sort":{"columnId":"@timestamp","sortDirection":"desc"},"title":"SIEM test","updated":1586256839298,"updatedBy":"elastic","timelineType":"default","eventNotes":[],"globalNotes":[],"pinnedEventIds":[]}