diff --git a/package.json b/package.json index 85b1c927f6ef..f7c8c6adb3d8 100644 --- a/package.json +++ b/package.json @@ -606,7 +606,7 @@ "cpy": "^8.1.1", "cronstrue": "^1.51.0", "css-loader": "^3.4.2", - "cypress": "^6.0.1", + "cypress": "^6.1.0", "cypress-cucumber-preprocessor": "^2.5.2", "cypress-multi-reporters": "^1.4.0", "d3": "3.5.17", diff --git a/vars/tasks.groovy b/vars/tasks.groovy index a01e63e21814..221e93fd7b83 100644 --- a/vars/tasks.groovy +++ b/vars/tasks.groovy @@ -115,15 +115,14 @@ def functionalXpack(Map params = [:]) { task(kibanaPipeline.functionalTestProcess('xpack-savedObjectsFieldMetrics', './test/scripts/jenkins_xpack_saved_objects_field_metrics.sh')) } - // FLAKY: https://github.com/elastic/kibana/issues/86080 - // whenChanged([ - // 'x-pack/plugins/security_solution/', - // 'x-pack/test/security_solution_cypress/', - // 'x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/', - // 'x-pack/plugins/triggers_actions_ui/public/application/context/actions_connectors_context.tsx', - // ]) { - // task(kibanaPipeline.functionalTestProcess('xpack-securitySolutionCypress', './test/scripts/jenkins_security_solution_cypress.sh')) - // } + whenChanged([ + 'x-pack/plugins/security_solution/', + 'x-pack/test/security_solution_cypress/', + 'x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/', + 'x-pack/plugins/triggers_actions_ui/public/application/context/actions_connectors_context.tsx', + ]) { + task(kibanaPipeline.functionalTestProcess('xpack-securitySolutionCypress', './test/scripts/jenkins_security_solution_cypress.sh')) + } } } diff --git a/x-pack/plugins/security_solution/cypress/integration/alerts.spec.ts b/x-pack/plugins/security_solution/cypress/integration/alerts.spec.ts index a40c79acd8fd..a15aad1bd8cc 100644 --- a/x-pack/plugins/security_solution/cypress/integration/alerts.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/alerts.spec.ts @@ -26,6 +26,7 @@ import { goToInProgressAlerts, } from '../tasks/alerts'; import { removeSignalsIndex } from '../tasks/api_calls/rules'; +import { cleanKibana } from '../tasks/common'; import { esArchiverLoad, esArchiverUnload } from '../tasks/es_archiver'; import { loginAndWaitForPage } from '../tasks/login'; @@ -34,16 +35,17 @@ import { DETECTIONS_URL } from '../urls/navigation'; describe('Alerts', () => { context('Closing alerts', () => { beforeEach(() => { + cleanKibana(); + removeSignalsIndex(); esArchiverLoad('alerts'); loginAndWaitForPage(DETECTIONS_URL); }); afterEach(() => { esArchiverUnload('alerts'); - removeSignalsIndex(); }); - it.skip('Closes and opens alerts', () => { + it('Closes and opens alerts', () => { waitForAlertsPanelToBeLoaded(); waitForAlertsToBeLoaded(); @@ -117,13 +119,11 @@ describe('Alerts', () => { `Showing ${expectedNumberOfOpenedAlerts.toString()} alerts` ); - cy.get( - '[data-test-subj="events-viewer-panel"] [data-test-subj="server-side-event-count"]' - ).should('have.text', expectedNumberOfOpenedAlerts.toString()); + cy.get(ALERTS_COUNT).should('have.text', expectedNumberOfOpenedAlerts.toString()); }); }); - it.skip('Closes one alert when more than one opened alerts are selected', () => { + it('Closes one alert when more than one opened alerts are selected', () => { waitForAlertsToBeLoaded(); cy.get(ALERTS_COUNT) @@ -163,16 +163,17 @@ describe('Alerts', () => { context('Opening alerts', () => { beforeEach(() => { + cleanKibana(); + removeSignalsIndex(); esArchiverLoad('closed_alerts'); loginAndWaitForPage(DETECTIONS_URL); }); afterEach(() => { esArchiverUnload('closed_alerts'); - removeSignalsIndex(); }); - it.skip('Open one alert when more than one closed alerts are selected', () => { + it('Open one alert when more than one closed alerts are selected', () => { waitForAlerts(); goToClosedAlerts(); waitForAlertsToBeLoaded(); @@ -215,6 +216,8 @@ describe('Alerts', () => { context('Marking alerts as in-progress', () => { beforeEach(() => { + cleanKibana(); + removeSignalsIndex(); esArchiverLoad('alerts'); loginAndWaitForPage(DETECTIONS_URL); }); @@ -224,7 +227,7 @@ describe('Alerts', () => { removeSignalsIndex(); }); - it.skip('Mark one alert in progress when more than one open alerts are selected', () => { + it('Mark one alert in progress when more than one open alerts are selected', () => { waitForAlerts(); waitForAlertsToBeLoaded(); diff --git a/x-pack/plugins/security_solution/cypress/integration/alerts_detection_callouts_readonly.spec.ts b/x-pack/plugins/security_solution/cypress/integration/alerts_detection_callouts_readonly.spec.ts index 23798fb38a79..fa48c0bc1abc 100644 --- a/x-pack/plugins/security_solution/cypress/integration/alerts_detection_callouts_readonly.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/alerts_detection_callouts_readonly.spec.ts @@ -13,12 +13,12 @@ import { login, loginAndWaitForPageWithoutDateRange, waitForPageWithoutDateRange, - deleteRoleAndUser, } from '../tasks/login'; import { waitForAlertsIndexToBeCreated } from '../tasks/alerts'; import { goToRuleDetails } from '../tasks/alerts_detection_rules'; import { createCustomRule, deleteCustomRule, removeSignalsIndex } from '../tasks/api_calls/rules'; import { getCallOut, waitForCallOutToBeShown, dismissCallOut } from '../tasks/common/callouts'; +import { cleanKibana } from '../tasks/common'; const loadPageAsReadOnlyUser = (url: string) => { waitForPageWithoutDateRange(url, ROLES.reader); @@ -41,6 +41,8 @@ describe('Detections > Callouts indicating read-only access to resources', () => before(() => { // First, we have to open the app on behalf of a priviledged user in order to initialize it. // Otherwise the app will be disabled and show a "welcome"-like page. + cleanKibana(); + removeSignalsIndex(); loginAndWaitForPageWithoutDateRange(DETECTIONS_URL, ROLES.platform_engineer); waitForAlertsIndexToBeCreated(); @@ -48,12 +50,6 @@ describe('Detections > Callouts indicating read-only access to resources', () => login(ROLES.reader); }); - after(() => { - deleteRoleAndUser(ROLES.reader); - deleteRoleAndUser(ROLES.platform_engineer); - removeSignalsIndex(); - }); - context('On Detections home page', () => { beforeEach(() => { loadPageAsReadOnlyUser(DETECTIONS_URL); @@ -95,7 +91,6 @@ describe('Detections > Callouts indicating read-only access to resources', () => context('On Rule Details page', () => { beforeEach(() => { createCustomRule(newRule); - loadPageAsReadOnlyUser(DETECTIONS_RULE_MANAGEMENT_URL); waitForPageTitleToBeShown(); goToRuleDetails(); diff --git a/x-pack/plugins/security_solution/cypress/integration/alerts_detection_exceptions.spec.ts b/x-pack/plugins/security_solution/cypress/integration/alerts_detection_exceptions.spec.ts index 9137d6383a15..265f4d43c71c 100644 --- a/x-pack/plugins/security_solution/cypress/integration/alerts_detection_exceptions.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/alerts_detection_exceptions.spec.ts @@ -16,7 +16,7 @@ import { goToOpenedAlerts, waitForAlertsIndexToBeCreated, } from '../tasks/alerts'; -import { createCustomRule, deleteCustomRule, removeSignalsIndex } from '../tasks/api_calls/rules'; +import { createCustomRule, removeSignalsIndex } from '../tasks/api_calls/rules'; import { goToRuleDetails } from '../tasks/alerts_detection_rules'; import { waitForAlertsToPopulate } from '../tasks/create_new_rule'; import { esArchiverLoad, esArchiverUnload } from '../tasks/es_archiver'; @@ -33,10 +33,13 @@ import { import { refreshPage } from '../tasks/security_header'; import { DETECTIONS_URL } from '../urls/navigation'; +import { cleanKibana } from '../tasks/common'; describe.skip('Exceptions', () => { const NUMBER_OF_AUDITBEAT_EXCEPTIONS_ALERTS = '1'; beforeEach(() => { + cleanKibana(); + removeSignalsIndex(); loginAndWaitForPageWithoutDateRange(DETECTIONS_URL); waitForAlertsIndexToBeCreated(); createCustomRule(newRule); @@ -58,9 +61,8 @@ describe.skip('Exceptions', () => { afterEach(() => { esArchiverUnload('auditbeat_for_exceptions'); esArchiverUnload('auditbeat_for_exceptions2'); - deleteCustomRule(); - removeSignalsIndex(); }); + context('From rule', () => { it('Creates an exception and deletes it', () => { goToExceptionsTab(); diff --git a/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules.spec.ts b/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules.spec.ts index 2d21e3d333c0..4284b05205c6 100644 --- a/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules.spec.ts @@ -33,15 +33,18 @@ import { loginAndWaitForPageWithoutDateRange } from '../tasks/login'; import { DEFAULT_RULE_REFRESH_INTERVAL_VALUE } from '../../common/constants'; import { DETECTIONS_URL } from '../urls/navigation'; +import { removeSignalsIndex } from '../tasks/api_calls/rules'; +import { cleanKibana } from '../tasks/common'; describe('Alerts detection rules', () => { before(() => { + cleanKibana(); + removeSignalsIndex(); esArchiverLoad('prebuilt_rules_loaded'); }); after(() => { esArchiverUnload('prebuilt_rules_loaded'); - cy.clock().invoke('restore'); }); it('Sorts by activated rules', () => { diff --git a/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_custom.spec.ts b/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_custom.spec.ts index a044b7aa6c84..770f1b3f9f69 100644 --- a/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_custom.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_custom.spec.ts @@ -75,7 +75,6 @@ import { import { changeToThreeHundredRowsPerPage, deleteFirstRule, - deleteRule, deleteSelectedRules, editFirstRule, filterByCustomRules, @@ -86,7 +85,8 @@ import { waitForRulesToBeLoaded, } from '../tasks/alerts_detection_rules'; import { removeSignalsIndex } from '../tasks/api_calls/rules'; -import { createTimeline, deleteTimeline } from '../tasks/api_calls/timelines'; +import { createTimeline } from '../tasks/api_calls/timelines'; +import { cleanKibana } from '../tasks/common'; import { createAndActivateRule, fillAboutRule, @@ -115,17 +115,13 @@ describe('Custom detection rules creation', () => { const rule = { ...newRule }; before(() => { + cleanKibana(); + removeSignalsIndex(); createTimeline(newRule.timeline).then((response) => { rule.timeline.id = response.body.data.persistTimeline.timeline.savedObjectId; }); }); - after(() => { - deleteRule(); - deleteTimeline(rule.timeline.id!); - removeSignalsIndex(); - }); - it('Creates and activates a new rule', () => { loginAndWaitForPageWithoutDateRange(DETECTIONS_URL); waitForAlertsPanelToBeLoaded(); @@ -219,6 +215,8 @@ describe('Custom detection rules creation', () => { describe.skip('Custom detection rules deletion and edition', () => { beforeEach(() => { + cleanKibana(); + removeSignalsIndex(); esArchiverLoad('custom_rules'); loginAndWaitForPageWithoutDateRange(DETECTIONS_URL); waitForAlertsPanelToBeLoaded(); diff --git a/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_eql.spec.ts b/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_eql.spec.ts index 82f4ba9b1972..d02c015a5f1f 100644 --- a/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_eql.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_eql.spec.ts @@ -56,14 +56,15 @@ import { } from '../tasks/alerts'; import { changeToThreeHundredRowsPerPage, - deleteRule, filterByCustomRules, goToCreateNewRule, goToRuleDetails, waitForLoadElasticPrebuiltDetectionRulesTableToBeLoaded, waitForRulesToBeLoaded, } from '../tasks/alerts_detection_rules'; -import { createTimeline, deleteTimeline } from '../tasks/api_calls/timelines'; +import { removeSignalsIndex } from '../tasks/api_calls/rules'; +import { createTimeline } from '../tasks/api_calls/timelines'; +import { cleanKibana } from '../tasks/common'; import { createAndActivateRule, fillAboutRuleAndContinue, @@ -77,7 +78,7 @@ import { loginAndWaitForPageWithoutDateRange } from '../tasks/login'; import { DETECTIONS_URL } from '../urls/navigation'; -describe('Detection rules, EQL', () => { +describe.skip('Detection rules, EQL', () => { const expectedUrls = eqlRule.referenceUrls.join(''); const expectedFalsePositives = eqlRule.falsePositivesExamples.join(''); const expectedTags = eqlRule.tags.join(''); @@ -88,16 +89,13 @@ describe('Detection rules, EQL', () => { const rule = { ...eqlRule }; before(() => { + cleanKibana(); + removeSignalsIndex(); createTimeline(eqlRule.timeline).then((response) => { rule.timeline.id = response.body.data.persistTimeline.timeline.savedObjectId; }); }); - after(() => { - deleteTimeline(rule.timeline.id!); - deleteRule(); - }); - it('Creates and activates a new EQL rule', () => { loginAndWaitForPageWithoutDateRange(DETECTIONS_URL); waitForAlertsPanelToBeLoaded(); @@ -183,16 +181,13 @@ describe.skip('Detection rules, sequence EQL', () => { const rule = { ...eqlSequenceRule }; before(() => { + cleanKibana(); + removeSignalsIndex(); createTimeline(eqlSequenceRule.timeline).then((response) => { rule.timeline.id = response.body.data.persistTimeline.timeline.savedObjectId; }); }); - afterEach(() => { - deleteTimeline(eqlSequenceRule.timeline.id!); - deleteRule(); - }); - it('Creates and activates a new EQL rule with a sequence', () => { loginAndWaitForPageWithoutDateRange(DETECTIONS_URL); waitForAlertsPanelToBeLoaded(); diff --git a/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_export.spec.ts b/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_export.spec.ts index ef1a9951812f..a9c1f7c331d0 100644 --- a/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_export.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_export.spec.ts @@ -11,7 +11,8 @@ import { waitForAlertsPanelToBeLoaded, } from '../tasks/alerts'; import { exportFirstRule } from '../tasks/alerts_detection_rules'; -import { createCustomRule, deleteCustomRule } from '../tasks/api_calls/rules'; +import { createCustomRule, removeSignalsIndex } from '../tasks/api_calls/rules'; +import { cleanKibana } from '../tasks/common'; import { loginAndWaitForPageWithoutDateRange } from '../tasks/login'; import { DETECTIONS_URL } from '../urls/navigation'; @@ -19,6 +20,8 @@ import { DETECTIONS_URL } from '../urls/navigation'; describe.skip('Export rules', () => { let ruleResponse: Cypress.Response; before(() => { + cleanKibana(); + removeSignalsIndex(); cy.intercept( 'POST', '/api/detection_engine/rules/_export?exclude_export_details=false&file_name=rules_export.ndjson' @@ -31,10 +34,6 @@ describe.skip('Export rules', () => { }); }); - after(() => { - deleteCustomRule(); - }); - it('Exports a custom rule', () => { goToManageAlertsDetectionRules(); exportFirstRule(); diff --git a/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_indicator_match.spec.ts b/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_indicator_match.spec.ts index cbc4f2157786..4e97b619fc27 100644 --- a/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_indicator_match.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_indicator_match.spec.ts @@ -59,7 +59,6 @@ import { } from '../tasks/alerts'; import { changeToThreeHundredRowsPerPage, - deleteRule, filterByCustomRules, goToCreateNewRule, goToRuleDetails, @@ -67,6 +66,7 @@ import { waitForRulesToBeLoaded, } from '../tasks/alerts_detection_rules'; import { removeSignalsIndex } from '../tasks/api_calls/rules'; +import { cleanKibana } from '../tasks/common'; import { createAndActivateRule, fillAboutRuleAndContinue, @@ -90,6 +90,8 @@ describe('Detection rules, Indicator Match', () => { const expectedNumberOfAlerts = 1; beforeEach(() => { + cleanKibana(); + removeSignalsIndex(); esArchiverLoad('threat_indicator'); esArchiverLoad('threat_data'); }); @@ -97,11 +99,9 @@ describe('Detection rules, Indicator Match', () => { afterEach(() => { esArchiverUnload('threat_indicator'); esArchiverUnload('threat_data'); - deleteRule(); - removeSignalsIndex(); }); - it.skip('Creates and activates a new Indicator Match rule', () => { + it('Creates and activates a new Indicator Match rule', () => { loginAndWaitForPageWithoutDateRange(DETECTIONS_URL); waitForAlertsPanelToBeLoaded(); waitForAlertsIndexToBeCreated(); diff --git a/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_ml.spec.ts b/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_ml.spec.ts index aee2121c0660..c651139248e0 100644 --- a/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_ml.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_ml.spec.ts @@ -46,13 +46,14 @@ import { } from '../tasks/alerts'; import { changeToThreeHundredRowsPerPage, - deleteRule, filterByCustomRules, goToCreateNewRule, goToRuleDetails, waitForLoadElasticPrebuiltDetectionRulesTableToBeLoaded, waitForRulesToBeLoaded, } from '../tasks/alerts_detection_rules'; +import { removeSignalsIndex } from '../tasks/api_calls/rules'; +import { cleanKibana } from '../tasks/common'; import { createAndActivateRule, fillAboutRuleAndContinue, @@ -71,8 +72,9 @@ describe.skip('Detection rules, machine learning', () => { const expectedMitre = formatMitreAttackDescription(machineLearningRule.mitre); const expectedNumberOfRules = 1; - after(() => { - deleteRule(); + before(() => { + cleanKibana(); + removeSignalsIndex(); }); it('Creates and activates a new ml rule', () => { diff --git a/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_override.spec.ts b/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_override.spec.ts index 4d013ee7d723..a543dca00b01 100644 --- a/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_override.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_override.spec.ts @@ -63,14 +63,15 @@ import { } from '../tasks/alerts'; import { changeToThreeHundredRowsPerPage, - deleteRule, filterByCustomRules, goToCreateNewRule, goToRuleDetails, waitForLoadElasticPrebuiltDetectionRulesTableToBeLoaded, waitForRulesToBeLoaded, } from '../tasks/alerts_detection_rules'; -import { createTimeline, deleteTimeline } from '../tasks/api_calls/timelines'; +import { removeSignalsIndex } from '../tasks/api_calls/rules'; +import { createTimeline } from '../tasks/api_calls/timelines'; +import { cleanKibana } from '../tasks/common'; import { createAndActivateRule, fillAboutRuleWithOverrideAndContinue, @@ -94,16 +95,13 @@ describe.skip('Detection rules, override', () => { const rule = { ...newOverrideRule }; beforeEach(() => { + cleanKibana(); + removeSignalsIndex(); createTimeline(newOverrideRule.timeline).then((response) => { rule.timeline.id = response.body.data.persistTimeline.timeline.savedObjectId; }); }); - afterEach(() => { - deleteTimeline(rule.timeline.id!); - deleteRule(); - }); - it('Creates and activates a new custom rule with override option', () => { loginAndWaitForPageWithoutDateRange(DETECTIONS_URL); waitForAlertsPanelToBeLoaded(); diff --git a/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_prebuilt.spec.ts b/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_prebuilt.spec.ts index 08a20e03b6ec..a4e41631ea24 100644 --- a/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_prebuilt.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_prebuilt.spec.ts @@ -30,23 +30,23 @@ import { waitForPrebuiltDetectionRulesToBeLoaded, waitForRulesToBeLoaded, } from '../tasks/alerts_detection_rules'; -import { esArchiverLoadEmptyKibana, esArchiverUnloadEmptyKibana } from '../tasks/es_archiver'; +import { esArchiverLoadEmptyKibana } from '../tasks/es_archiver'; import { loginAndWaitForPageWithoutDateRange } from '../tasks/login'; import { DETECTIONS_URL } from '../urls/navigation'; import { totalNumberOfPrebuiltRules } from '../objects/rule'; +import { removeSignalsIndex } from '../tasks/api_calls/rules'; +import { cleanKibana } from '../tasks/common'; describe.skip('Alerts rules, prebuilt rules', () => { before(() => { + cleanKibana(); + removeSignalsIndex(); esArchiverLoadEmptyKibana(); }); - after(() => { - esArchiverUnloadEmptyKibana(); - }); - - it.skip('Loads prebuilt rules', () => { + it('Loads prebuilt rules', () => { const expectedNumberOfRules = totalNumberOfPrebuiltRules; const expectedElasticRulesBtnText = `Elastic rules (${expectedNumberOfRules})`; @@ -78,11 +78,12 @@ describe.skip('Alerts rules, prebuilt rules', () => { }); }); -describe.skip('Deleting prebuilt rules', () => { +describe('Deleting prebuilt rules', () => { beforeEach(() => { const expectedNumberOfRules = totalNumberOfPrebuiltRules; const expectedElasticRulesBtnText = `Elastic rules (${expectedNumberOfRules})`; + cleanKibana(); esArchiverLoadEmptyKibana(); loginAndWaitForPageWithoutDateRange(DETECTIONS_URL); waitForAlertsPanelToBeLoaded(); @@ -98,10 +99,6 @@ describe.skip('Deleting prebuilt rules', () => { waitForRulesToBeLoaded(); }); - afterEach(() => { - esArchiverUnloadEmptyKibana(); - }); - it('Does not allow to delete one rule when more than one is selected', () => { const numberOfRulesToBeSelected = 2; selectNumberOfRules(numberOfRulesToBeSelected); diff --git a/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_threshold.spec.ts b/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_threshold.spec.ts index cc6f1b3a8a0e..812d0fa29f9b 100644 --- a/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_threshold.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_threshold.spec.ts @@ -58,14 +58,15 @@ import { } from '../tasks/alerts'; import { changeToThreeHundredRowsPerPage, - deleteRule, filterByCustomRules, goToCreateNewRule, goToRuleDetails, waitForLoadElasticPrebuiltDetectionRulesTableToBeLoaded, waitForRulesToBeLoaded, } from '../tasks/alerts_detection_rules'; -import { createTimeline, deleteTimeline } from '../tasks/api_calls/timelines'; +import { removeSignalsIndex } from '../tasks/api_calls/rules'; +import { createTimeline } from '../tasks/api_calls/timelines'; +import { cleanKibana } from '../tasks/common'; import { createAndActivateRule, fillAboutRuleAndContinue, @@ -79,7 +80,7 @@ import { loginAndWaitForPageWithoutDateRange } from '../tasks/login'; import { DETECTIONS_URL } from '../urls/navigation'; -describe('Detection rules, threshold', () => { +describe.skip('Detection rules, threshold', () => { const expectedUrls = newThresholdRule.referenceUrls.join(''); const expectedFalsePositives = newThresholdRule.falsePositivesExamples.join(''); const expectedTags = newThresholdRule.tags.join(''); @@ -88,16 +89,13 @@ describe('Detection rules, threshold', () => { const rule = { ...newThresholdRule }; beforeEach(() => { + cleanKibana(); + removeSignalsIndex(); createTimeline(newThresholdRule.timeline).then((response) => { rule.timeline.id = response.body.data.persistTimeline.timeline.savedObjectId; }); }); - afterEach(() => { - deleteTimeline(rule.timeline.id!); - deleteRule(); - }); - it('Creates and activates a new threshold rule', () => { loginAndWaitForPageWithoutDateRange(DETECTIONS_URL); waitForAlertsPanelToBeLoaded(); diff --git a/x-pack/plugins/security_solution/cypress/integration/alerts_timeline.spec.ts b/x-pack/plugins/security_solution/cypress/integration/alerts_timeline.spec.ts index 2bfe72033135..d5fba65a7014 100644 --- a/x-pack/plugins/security_solution/cypress/integration/alerts_timeline.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/alerts_timeline.spec.ts @@ -7,6 +7,8 @@ import { PROVIDER_BADGE } from '../screens/timeline'; import { investigateFirstAlertInTimeline, waitForAlertsPanelToBeLoaded } from '../tasks/alerts'; +import { removeSignalsIndex } from '../tasks/api_calls/rules'; +import { cleanKibana } from '../tasks/common'; import { esArchiverLoad, esArchiverUnload } from '../tasks/es_archiver'; import { loginAndWaitForPage } from '../tasks/login'; @@ -14,6 +16,8 @@ import { DETECTIONS_URL } from '../urls/navigation'; describe('Alerts timeline', () => { beforeEach(() => { + cleanKibana(); + removeSignalsIndex(); esArchiverLoad('timeline_alerts'); loginAndWaitForPage(DETECTIONS_URL); }); diff --git a/x-pack/plugins/security_solution/cypress/integration/cases.spec.ts b/x-pack/plugins/security_solution/cypress/integration/cases.spec.ts index b755de8efe75..d53b98b6c103 100644 --- a/x-pack/plugins/security_solution/cypress/integration/cases.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/cases.spec.ts @@ -38,8 +38,9 @@ import { import { TIMELINE_DESCRIPTION, TIMELINE_QUERY, TIMELINE_TITLE } from '../screens/timeline'; import { goToCaseDetails, goToCreateNewCase } from '../tasks/all_cases'; -import { createTimeline, deleteTimeline } from '../tasks/api_calls/timelines'; -import { deleteCase, openCaseTimeline } from '../tasks/case_details'; +import { createTimeline } from '../tasks/api_calls/timelines'; +import { openCaseTimeline } from '../tasks/case_details'; +import { cleanKibana } from '../tasks/common'; import { attachTimeline, backToCases, @@ -47,7 +48,6 @@ import { fillCasesMandatoryfields, } from '../tasks/create_new_case'; import { loginAndWaitForPageWithoutDateRange } from '../tasks/login'; -import { closeTimeline } from '../tasks/timeline'; import { CASES_URL } from '../urls/navigation'; @@ -55,17 +55,12 @@ describe.skip('Cases', () => { const mycase = { ...case1 }; before(() => { + cleanKibana(); createTimeline(case1.timeline).then((response) => { mycase.timeline.id = response.body.data.persistTimeline.timeline.savedObjectId; }); }); - after(() => { - closeTimeline(); - deleteTimeline(mycase.timeline.id!); - deleteCase(); - }); - it('Creates a new case with timeline and opens the timeline', () => { loginAndWaitForPageWithoutDateRange(CASES_URL); goToCreateNewCase(); diff --git a/x-pack/plugins/security_solution/cypress/integration/cases_connector_options.spec.ts b/x-pack/plugins/security_solution/cypress/integration/cases_connector_options.spec.ts index 1d580b93af23..c41b79ef3365 100644 --- a/x-pack/plugins/security_solution/cypress/integration/cases_connector_options.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/cases_connector_options.spec.ts @@ -22,12 +22,13 @@ import { fillServiceNowConnectorOptions, } from '../tasks/create_new_case'; import { goToCreateNewCase } from '../tasks/all_cases'; -import { deleteCase } from '../tasks/case_details'; import { CASES_URL } from '../urls/navigation'; import { CONNECTOR_CARD_DETAILS, CONNECTOR_TITLE } from '../screens/case_details'; +import { cleanKibana } from '../tasks/common'; describe('Cases connector incident fields', () => { before(() => { + cleanKibana(); cy.intercept('GET', '/api/cases/configure/connectors/_find', mockConnectorsResponse); cy.intercept('POST', `/api/actions/action/${connectorIds.jira}/_execute`, (req) => { const response = @@ -45,10 +46,6 @@ describe('Cases connector incident fields', () => { }); }); - after(() => { - deleteCase(); - }); - it('Correct incident fields show when connector is changed', () => { loginAndWaitForPageWithoutDateRange(CASES_URL); goToCreateNewCase(); diff --git a/x-pack/plugins/security_solution/cypress/integration/cases_connectors.spec.ts b/x-pack/plugins/security_solution/cypress/integration/cases_connectors.spec.ts index acb56d1f2466..8bd9f5b09f2c 100644 --- a/x-pack/plugins/security_solution/cypress/integration/cases_connectors.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/cases_connectors.spec.ts @@ -8,6 +8,7 @@ import { serviceNowConnector } from '../objects/case'; import { SERVICE_NOW_MAPPING, TOASTER } from '../screens/configure_cases'; import { goToEditExternalConnection } from '../tasks/all_cases'; +import { cleanKibana } from '../tasks/common'; import { addServiceNowConnector, openAddNewConnectorOption, @@ -38,6 +39,7 @@ describe('Cases connectors', () => { version: 'WzEwNCwxXQ==', }; before(() => { + cleanKibana(); cy.intercept('POST', '/api/actions/action').as('createConnector'); cy.intercept('POST', '/api/cases/configure', (req) => { const connector = req.body.connector; diff --git a/x-pack/plugins/security_solution/cypress/integration/events_viewer.spec.ts b/x-pack/plugins/security_solution/cypress/integration/events_viewer.spec.ts index 664de967b9af..f7a19fa281be 100644 --- a/x-pack/plugins/security_solution/cypress/integration/events_viewer.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/events_viewer.spec.ts @@ -33,6 +33,7 @@ import { clearSearchBar, kqlSearch } from '../tasks/security_header'; import { HOSTS_URL } from '../urls/navigation'; import { resetFields } from '../tasks/timeline'; +import { cleanKibana } from '../tasks/common'; const defaultHeadersInDefaultEcsCategory = [ { id: '@timestamp' }, @@ -44,9 +45,10 @@ const defaultHeadersInDefaultEcsCategory = [ { id: 'destination.ip' }, ]; -describe('Events Viewer', () => { +describe.skip('Events Viewer', () => { context('Fields rendering', () => { before(() => { + cleanKibana(); loginAndWaitForPage(HOSTS_URL); openEvents(); }); @@ -73,6 +75,7 @@ describe('Events Viewer', () => { context('Events viewer query modal', () => { before(() => { + cleanKibana(); loginAndWaitForPage(HOSTS_URL); openEvents(); }); @@ -91,6 +94,7 @@ describe('Events Viewer', () => { context('Events viewer fields behaviour', () => { before(() => { + cleanKibana(); loginAndWaitForPage(HOSTS_URL); openEvents(); }); @@ -122,6 +126,7 @@ describe('Events Viewer', () => { context('Events behaviour', () => { before(() => { + cleanKibana(); loginAndWaitForPage(HOSTS_URL); openEvents(); waitsForEventsToBeLoaded(); @@ -144,6 +149,7 @@ describe('Events Viewer', () => { context('Events columns', () => { before(() => { + cleanKibana(); loginAndWaitForPage(HOSTS_URL); openEvents(); cy.scrollTo('bottom'); diff --git a/x-pack/plugins/security_solution/cypress/integration/fields_browser.spec.ts b/x-pack/plugins/security_solution/cypress/integration/fields_browser.spec.ts index cb8949402b98..d99981b42d04 100644 --- a/x-pack/plugins/security_solution/cypress/integration/fields_browser.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/fields_browser.spec.ts @@ -16,6 +16,7 @@ import { FIELDS_BROWSER_SELECTED_CATEGORY_COUNT, FIELDS_BROWSER_SYSTEM_CATEGORIES_COUNT, } from '../screens/fields_browser'; +import { cleanKibana } from '../tasks/common'; import { addsHostGeoCityNameToTimeline, @@ -47,6 +48,7 @@ const defaultHeaders = [ describe('Fields Browser', () => { context.skip('Fields Browser rendering', () => { before(() => { + cleanKibana(); loginAndWaitForPage(HOSTS_URL); openTimelineUsingToggle(); populateTimeline(); @@ -110,6 +112,7 @@ describe('Fields Browser', () => { context.skip('Editing the timeline', () => { before(() => { + cleanKibana(); loginAndWaitForPage(HOSTS_URL); openTimelineUsingToggle(); populateTimeline(); diff --git a/x-pack/plugins/security_solution/cypress/integration/inspect.spec.ts b/x-pack/plugins/security_solution/cypress/integration/inspect.spec.ts index b84b668a2850..6321be1e2615 100644 --- a/x-pack/plugins/security_solution/cypress/integration/inspect.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/inspect.spec.ts @@ -9,6 +9,7 @@ import { INSPECT_MODAL, INSPECT_NETWORK_BUTTONS_IN_SECURITY, } from '../screens/inspect'; +import { cleanKibana } from '../tasks/common'; import { closesModal, openStatsAndTables } from '../tasks/inspect'; import { loginAndWaitForPage } from '../tasks/login'; @@ -20,6 +21,7 @@ import { HOSTS_URL, NETWORK_URL } from '../urls/navigation'; describe('Inspect', () => { context('Hosts stats and tables', () => { before(() => { + cleanKibana(); loginAndWaitForPage(HOSTS_URL); }); afterEach(() => { @@ -36,6 +38,7 @@ describe('Inspect', () => { context('Network stats and tables', () => { before(() => { + cleanKibana(); loginAndWaitForPage(NETWORK_URL); }); afterEach(() => { diff --git a/x-pack/plugins/security_solution/cypress/integration/ml_conditional_links.spec.ts b/x-pack/plugins/security_solution/cypress/integration/ml_conditional_links.spec.ts index f8765129512c..64e75c6b0338 100644 --- a/x-pack/plugins/security_solution/cypress/integration/ml_conditional_links.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/ml_conditional_links.spec.ts @@ -5,6 +5,7 @@ */ import { KQL_INPUT } from '../screens/security_header'; +import { cleanKibana } from '../tasks/common'; import { loginAndWaitForPageWithoutDateRange } from '../tasks/login'; @@ -25,6 +26,10 @@ import { } from '../urls/ml_conditional_links'; describe('ml conditional links', () => { + before(() => { + cleanKibana(); + }); + it('sets the KQL from a single IP with a value for the query', () => { loginAndWaitForPageWithoutDateRange(mlNetworkSingleIpKqlQuery); cy.get(KQL_INPUT) diff --git a/x-pack/plugins/security_solution/cypress/integration/navigation.spec.ts b/x-pack/plugins/security_solution/cypress/integration/navigation.spec.ts index 792eee366042..c8e9af98fe6f 100644 --- a/x-pack/plugins/security_solution/cypress/integration/navigation.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/navigation.spec.ts @@ -36,9 +36,11 @@ import { OVERVIEW_PAGE, TIMELINES_PAGE, } from '../screens/kibana_navigation'; +import { cleanKibana } from '../tasks/common'; describe('top-level navigation common to all pages in the Security app', () => { before(() => { + cleanKibana(); loginAndWaitForPage(TIMELINES_URL); }); diff --git a/x-pack/plugins/security_solution/cypress/integration/overview.spec.ts b/x-pack/plugins/security_solution/cypress/integration/overview.spec.ts index 0d12019adbc9..f72559b9f21e 100644 --- a/x-pack/plugins/security_solution/cypress/integration/overview.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/overview.spec.ts @@ -13,8 +13,13 @@ import { OVERVIEW_URL } from '../urls/navigation'; import overviewFixture from '../fixtures/overview_search_strategy.json'; import emptyInstance from '../fixtures/empty_instance.json'; +import { cleanKibana } from '../tasks/common'; describe('Overview Page', () => { + before(() => { + cleanKibana(); + }); + it('Host stats render with correct values', () => { cy.stubSearchStrategyApi(overviewFixture, 'overviewHost'); loginAndWaitForPage(OVERVIEW_URL); diff --git a/x-pack/plugins/security_solution/cypress/integration/pagination.spec.ts b/x-pack/plugins/security_solution/cypress/integration/pagination.spec.ts index d75573598251..2896b2dbc36c 100644 --- a/x-pack/plugins/security_solution/cypress/integration/pagination.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/pagination.spec.ts @@ -6,6 +6,7 @@ import { PROCESS_NAME_FIELD, UNCOMMON_PROCESSES_TABLE } from '../screens/hosts/uncommon_processes'; import { FIRST_PAGE_SELECTOR, THIRD_PAGE_SELECTOR } from '../screens/pagination'; +import { cleanKibana } from '../tasks/common'; import { waitForAuthenticationsToBeLoaded } from '../tasks/hosts/authentications'; import { openAuthentications, openUncommonProcesses } from '../tasks/hosts/main'; @@ -18,6 +19,7 @@ import { HOSTS_PAGE_TAB_URLS } from '../urls/navigation'; describe('Pagination', () => { before(() => { + cleanKibana(); loginAndWaitForPage(HOSTS_PAGE_TAB_URLS.uncommonProcesses); waitForUncommonProcessesToBeLoaded(); }); diff --git a/x-pack/plugins/security_solution/cypress/integration/search_bar.spec.ts b/x-pack/plugins/security_solution/cypress/integration/search_bar.spec.ts index 15ca92714d4a..7fcbc10f88b4 100644 --- a/x-pack/plugins/security_solution/cypress/integration/search_bar.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/search_bar.spec.ts @@ -11,9 +11,11 @@ import { hostIpFilter } from '../objects/filter'; import { HOSTS_URL } from '../urls/navigation'; import { waitForAllHostsToBeLoaded } from '../tasks/hosts/all_hosts'; +import { cleanKibana } from '../tasks/common'; describe('SearchBar', () => { before(() => { + cleanKibana(); loginAndWaitForPage(HOSTS_URL); waitForAllHostsToBeLoaded(); }); diff --git a/x-pack/plugins/security_solution/cypress/integration/sourcerer.spec.ts b/x-pack/plugins/security_solution/cypress/integration/sourcerer.spec.ts index ead3fa617510..b441d33d34ba 100644 --- a/x-pack/plugins/security_solution/cypress/integration/sourcerer.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/sourcerer.spec.ts @@ -26,8 +26,13 @@ import { import { openTimelineUsingToggle } from '../tasks/security_main'; import { populateTimeline } from '../tasks/timeline'; import { SERVER_SIDE_EVENT_COUNT } from '../screens/timeline'; +import { cleanKibana } from '../tasks/common'; describe('Sourcerer', () => { + before(() => { + cleanKibana(); + }); + beforeEach(() => { loginAndWaitForPage(HOSTS_URL); }); diff --git a/x-pack/plugins/security_solution/cypress/integration/timeline_attach_to_case.spec.ts b/x-pack/plugins/security_solution/cypress/integration/timeline_attach_to_case.spec.ts index 936151d13f92..74bf4f03b0b1 100644 --- a/x-pack/plugins/security_solution/cypress/integration/timeline_attach_to_case.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/timeline_attach_to_case.spec.ts @@ -16,12 +16,14 @@ import { esArchiverLoad, esArchiverUnload } from '../tasks/es_archiver'; import { TIMELINE_CASE_ID } from '../objects/case'; import { caseTimeline, timeline } from '../objects/timeline'; import { createTimeline, deleteTimeline } from '../tasks/api_calls/timelines'; +import { cleanKibana } from '../tasks/common'; describe('attach timeline to case', () => { const myTimeline = { ...timeline }; context('without cases created', () => { before(() => { + cleanKibana(); createTimeline(timeline).then((response) => { myTimeline.id = response.body.data.persistTimeline.timeline.savedObjectId; }); @@ -61,13 +63,10 @@ describe('attach timeline to case', () => { context('with cases created', () => { before(() => { + cleanKibana(); esArchiverLoad('case_and_timeline'); }); - after(() => { - esArchiverUnload('case_and_timeline'); - }); - it('attach timeline to an existing case', () => { loginAndWaitForTimeline(caseTimeline.id!); attachTimelineToExistingCase(); @@ -81,6 +80,7 @@ describe('attach timeline to case', () => { }](${origin}/app/security/timelines?timeline=(id:%27${caseTimeline.id!}%27,isOpen:!t))` ); }); + esArchiverUnload('case_and_timeline'); }); }); }); 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 1fb751f344fd..5d44c057c738 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 @@ -25,7 +25,8 @@ import { TIMELINES_NOTES_COUNT, TIMELINES_FAVORITE, } from '../screens/timelines'; -import { deleteTimeline, getTimelineById } from '../tasks/api_calls/timelines'; +import { getTimelineById } from '../tasks/api_calls/timelines'; +import { cleanKibana } from '../tasks/common'; import { loginAndWaitForPage } from '../tasks/login'; import { openTimelineUsingToggle } from '../tasks/security_main'; @@ -50,8 +51,8 @@ import { OVERVIEW_URL } from '../urls/navigation'; describe.skip('Timelines', () => { let timelineId: string; - after(() => { - if (timelineId) deleteTimeline(timelineId); + before(() => { + cleanKibana(); }); it('Creates a timeline', () => { diff --git a/x-pack/plugins/security_solution/cypress/integration/timeline_data_providers.spec.ts b/x-pack/plugins/security_solution/cypress/integration/timeline_data_providers.spec.ts index 1210ae6e1a57..d2a20fe1ecdb 100644 --- a/x-pack/plugins/security_solution/cypress/integration/timeline_data_providers.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/timeline_data_providers.spec.ts @@ -23,11 +23,13 @@ import { openTimelineUsingToggle } from '../tasks/security_main'; import { closeTimeline, createNewTimeline } from '../tasks/timeline'; import { HOSTS_URL } from '../urls/navigation'; +import { cleanKibana } from '../tasks/common'; // FLAKY: https://github.com/elastic/kibana/issues/85098 // FLAKY: https://github.com/elastic/kibana/issues/62060 describe.skip('timeline data providers', () => { before(() => { + cleanKibana(); loginAndWaitForPage(HOSTS_URL); waitForAllHostsToBeLoaded(); }); diff --git a/x-pack/plugins/security_solution/cypress/integration/timeline_flyout_button.spec.ts b/x-pack/plugins/security_solution/cypress/integration/timeline_flyout_button.spec.ts index 33e8cc40b123..acf245251d7e 100644 --- a/x-pack/plugins/security_solution/cypress/integration/timeline_flyout_button.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/timeline_flyout_button.spec.ts @@ -5,6 +5,7 @@ */ import { TIMELINE_FLYOUT_HEADER, TIMELINE_DATA_PROVIDERS } from '../screens/timeline'; +import { cleanKibana } from '../tasks/common'; import { dragFirstHostToTimeline, waitForAllHostsToBeLoaded } from '../tasks/hosts/all_hosts'; import { loginAndWaitForPage } from '../tasks/login'; @@ -14,6 +15,7 @@ import { HOSTS_URL } from '../urls/navigation'; describe('timeline flyout button', () => { before(() => { + cleanKibana(); loginAndWaitForPage(HOSTS_URL); waitForAllHostsToBeLoaded(); }); diff --git a/x-pack/plugins/security_solution/cypress/integration/timeline_local_storage.spec.ts b/x-pack/plugins/security_solution/cypress/integration/timeline_local_storage.spec.ts index d518f9e42f21..8b84ae781545 100644 --- a/x-pack/plugins/security_solution/cypress/integration/timeline_local_storage.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/timeline_local_storage.spec.ts @@ -4,28 +4,24 @@ * you may not use this file except in compliance with the Elastic License. */ -import { reload } from '../tasks/common'; +import { cleanKibana, reload } from '../tasks/common'; import { loginAndWaitForPage } from '../tasks/login'; import { HOSTS_URL } from '../urls/navigation'; import { openEvents } from '../tasks/hosts/main'; import { DRAGGABLE_HEADER } from '../screens/timeline'; import { TABLE_COLUMN_EVENTS_MESSAGE } from '../screens/hosts/external_events'; -import { waitsForEventsToBeLoaded, openEventsViewerFieldsBrowser } from '../tasks/hosts/events'; -import { removeColumn, resetFields } from '../tasks/timeline'; +import { waitsForEventsToBeLoaded } from '../tasks/hosts/events'; +import { removeColumn } from '../tasks/timeline'; // Failing: See https://github.com/elastic/kibana/issues/75794 describe.skip('persistent timeline', () => { before(() => { + cleanKibana(); loginAndWaitForPage(HOSTS_URL); openEvents(); waitsForEventsToBeLoaded(); }); - afterEach(() => { - openEventsViewerFieldsBrowser(); - resetFields(); - }); - it('persist the deletion of a column', () => { cy.get(DRAGGABLE_HEADER).then((header) => { const currentNumberOfTimelineColumns = header.length; diff --git a/x-pack/plugins/security_solution/cypress/integration/timeline_search_or_filter.spec.ts b/x-pack/plugins/security_solution/cypress/integration/timeline_search_or_filter.spec.ts index 814fcee2b0c5..52274329034b 100644 --- a/x-pack/plugins/security_solution/cypress/integration/timeline_search_or_filter.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/timeline_search_or_filter.spec.ts @@ -5,6 +5,7 @@ */ import { SERVER_SIDE_EVENT_COUNT } from '../screens/timeline'; +import { cleanKibana } from '../tasks/common'; import { loginAndWaitForPage } from '../tasks/login'; import { openTimelineUsingToggle } from '../tasks/security_main'; @@ -12,8 +13,9 @@ import { executeTimelineKQL } from '../tasks/timeline'; import { HOSTS_URL } from '../urls/navigation'; -describe('timeline search or filter KQL bar', () => { +describe.skip('timeline search or filter KQL bar', () => { beforeEach(() => { + cleanKibana(); loginAndWaitForPage(HOSTS_URL); }); diff --git a/x-pack/plugins/security_solution/cypress/integration/timeline_template_creation.spec.ts b/x-pack/plugins/security_solution/cypress/integration/timeline_template_creation.spec.ts index fc7125288b74..f1aaa4ab8b98 100644 --- a/x-pack/plugins/security_solution/cypress/integration/timeline_template_creation.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/timeline_template_creation.spec.ts @@ -23,6 +23,7 @@ import { TIMELINES_NOTES_COUNT, TIMELINES_FAVORITE, } from '../screens/timelines'; +import { cleanKibana } from '../tasks/common'; import { loginAndWaitForPage } from '../tasks/login'; import { openTimelineUsingToggle } from '../tasks/security_main'; @@ -44,6 +45,7 @@ import { OVERVIEW_URL } from '../urls/navigation'; describe('Timeline Templates', () => { before(() => { + cleanKibana(); cy.intercept('PATCH', '/api/timeline').as('timeline'); }); diff --git a/x-pack/plugins/security_solution/cypress/integration/timeline_templates_export.spec.ts b/x-pack/plugins/security_solution/cypress/integration/timeline_templates_export.spec.ts index 8e1dc0f8aa1e..015c0fc80e29 100644 --- a/x-pack/plugins/security_solution/cypress/integration/timeline_templates_export.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/timeline_templates_export.spec.ts @@ -12,16 +12,15 @@ import { } from '../objects/timeline'; import { TIMELINE_TEMPLATES_URL } from '../urls/navigation'; -import { - createTimelineTemplate, - deleteTimeline as deleteTimelineTemplate, -} from '../tasks/api_calls/timelines'; +import { createTimelineTemplate } from '../tasks/api_calls/timelines'; +import { cleanKibana } from '../tasks/common'; describe('Export timelines', () => { let templateResponse: Cypress.Response; let templateId: string; before(() => { + cleanKibana(); cy.intercept('POST', 'api/timeline/_export?file_name=timelines_export.ndjson').as('export'); createTimelineTemplate(timelineTemplate).then((response) => { templateResponse = response; @@ -29,10 +28,6 @@ describe('Export timelines', () => { }); }); - after(() => { - deleteTimelineTemplate(templateId); - }); - it('Exports a custom timeline template', () => { loginAndWaitForPageWithoutDateRange(TIMELINE_TEMPLATES_URL); exportTimeline(templateId!); diff --git a/x-pack/plugins/security_solution/cypress/integration/timeline_toggle_column.spec.ts b/x-pack/plugins/security_solution/cypress/integration/timeline_toggle_column.spec.ts index 80693f3dd807..9a03936c3683 100644 --- a/x-pack/plugins/security_solution/cypress/integration/timeline_toggle_column.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/timeline_toggle_column.spec.ts @@ -11,7 +11,8 @@ import { TIMESTAMP_HEADER_FIELD, TIMESTAMP_TOGGLE_FIELD, } from '../screens/timeline'; -import { createTimeline, deleteTimeline } from '../tasks/api_calls/timelines'; +import { createTimeline } from '../tasks/api_calls/timelines'; +import { cleanKibana } from '../tasks/common'; import { loginAndWaitForPage } from '../tasks/login'; import { openTimelineUsingToggle } from '../tasks/security_main'; @@ -28,19 +29,14 @@ import { import { HOSTS_URL } from '../urls/navigation'; describe('toggle column in timeline', () => { - let timelineId: string; before(() => { + cleanKibana(); cy.intercept('POST', '/api/timeline/_export?file_name=timelines_export.ndjson').as('export'); createTimeline(timeline).then((response) => { - timelineId = response.body.data.persistTimeline.timeline.savedObjectId; loginAndWaitForPage(HOSTS_URL); }); }); - after(() => { - deleteTimeline(timelineId); - }); - beforeEach(() => { openTimelineUsingToggle(); populateTimeline(); 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 8e3cd3dfbde7..064d98bf01b2 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 @@ -8,13 +8,15 @@ import { exportTimeline, waitForTimelinesPanelToBeLoaded } from '../tasks/timeli import { loginAndWaitForPageWithoutDateRange } from '../tasks/login'; import { TIMELINES_URL } from '../urls/navigation'; -import { createTimeline, deleteTimeline } from '../tasks/api_calls/timelines'; +import { createTimeline } from '../tasks/api_calls/timelines'; import { expectedExportedTimeline, timeline } from '../objects/timeline'; +import { cleanKibana } from '../tasks/common'; describe('Export timelines', () => { let timelineResponse: Cypress.Response; let timelineId: string; before(() => { + cleanKibana(); cy.intercept('POST', '/api/timeline/_export?file_name=timelines_export.ndjson').as('export'); createTimeline(timeline).then((response) => { timelineResponse = response; @@ -22,10 +24,6 @@ describe('Export timelines', () => { }); }); - after(() => { - deleteTimeline(timelineId); - }); - it('Exports a custom timeline', () => { loginAndWaitForPageWithoutDateRange(TIMELINES_URL); waitForTimelinesPanelToBeLoaded(); diff --git a/x-pack/plugins/security_solution/cypress/integration/url_compatibility.spec.ts b/x-pack/plugins/security_solution/cypress/integration/url_compatibility.spec.ts index 5b42897b065e..58ef4cd2d96b 100644 --- a/x-pack/plugins/security_solution/cypress/integration/url_compatibility.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/url_compatibility.spec.ts @@ -12,6 +12,7 @@ import { DATE_PICKER_START_DATE_POPOVER_BUTTON, DATE_PICKER_END_DATE_POPOVER_BUTTON, } from '../screens/date_picker'; +import { cleanKibana } from '../tasks/common'; const ABSOLUTE_DATE = { endTime: '2019-08-01T20:33:29.186Z', @@ -19,6 +20,10 @@ const ABSOLUTE_DATE = { }; describe('URL compatibility', () => { + before(() => { + cleanKibana(); + }); + it('Redirects to Detection alerts from old Detections URL', () => { loginAndWaitForPage(DETECTIONS); diff --git a/x-pack/plugins/security_solution/cypress/integration/url_state.spec.ts b/x-pack/plugins/security_solution/cypress/integration/url_state.spec.ts index b911fc5b81f9..a13ae62eb7f8 100644 --- a/x-pack/plugins/security_solution/cypress/integration/url_state.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/url_state.spec.ts @@ -38,6 +38,7 @@ import { ABSOLUTE_DATE_RANGE } from '../urls/state'; import { timeline } from '../objects/timeline'; import { TIMELINE } from '../screens/create_new_case'; +import { cleanKibana } from '../tasks/common'; const ABSOLUTE_DATE = { endTime: '2019-08-01T20:33:29.186Z', @@ -50,6 +51,10 @@ const ABSOLUTE_DATE = { // FLAKY: https://github.com/elastic/kibana/issues/61612 describe.skip('url state', () => { + before(() => { + cleanKibana(); + }); + it('sets the global start and end dates from the url', () => { loginAndWaitForPageWithoutDateRange(ABSOLUTE_DATE_RANGE.url); cy.get(DATE_PICKER_START_DATE_POPOVER_BUTTON).should( diff --git a/x-pack/plugins/security_solution/cypress/integration/value_lists.spec.ts b/x-pack/plugins/security_solution/cypress/integration/value_lists.spec.ts index 341ca3171535..0b1ab12f37c9 100644 --- a/x-pack/plugins/security_solution/cypress/integration/value_lists.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/value_lists.spec.ts @@ -26,10 +26,17 @@ import { exportValueList, } from '../tasks/lists'; import { VALUE_LISTS_TABLE, VALUE_LISTS_ROW, VALUE_LISTS_MODAL_ACTIVATOR } from '../screens/lists'; +import { removeSignalsIndex } from '../tasks/api_calls/rules'; +import { cleanKibana } from '../tasks/common'; describe('value lists', () => { describe('management modal', () => { + before(() => { + cleanKibana(); + }); + beforeEach(() => { + removeSignalsIndex(); loginAndWaitForPageWithoutDateRange(DETECTIONS_URL); waitForAlertsPanelToBeLoaded(); waitForAlertsIndexToBeCreated(); @@ -39,6 +46,7 @@ describe('value lists', () => { }); afterEach(() => { + removeSignalsIndex(); deleteAllValueListsFromUI(); }); diff --git a/x-pack/plugins/security_solution/cypress/support/index.js b/x-pack/plugins/security_solution/cypress/support/index.js index d6abecad74b9..0d5538758413 100644 --- a/x-pack/plugins/security_solution/cypress/support/index.js +++ b/x-pack/plugins/security_solution/cypress/support/index.js @@ -21,16 +21,13 @@ // Import commands.js using ES2015 syntax: import './commands'; -import 'cypress-promise/register'; Cypress.Cookies.defaults({ preserve: 'sid', }); -Cypress.on('uncaught:exception', (err) => { - if (err.message.includes('ResizeObserver loop limit exceeded')) { - return false; - } +Cypress.on('uncaught:exception', () => { + return false; }); // Alternatively you can use CommonJS syntax: diff --git a/x-pack/plugins/security_solution/cypress/tasks/api_calls/rules.ts b/x-pack/plugins/security_solution/cypress/tasks/api_calls/rules.ts index edf493d82c84..34fc00428d2c 100644 --- a/x-pack/plugins/security_solution/cypress/tasks/api_calls/rules.ts +++ b/x-pack/plugins/security_solution/cypress/tasks/api_calls/rules.ts @@ -36,9 +36,13 @@ export const deleteCustomRule = () => { }; export const removeSignalsIndex = () => { - cy.request({ - method: 'DELETE', - url: `api/detection_engine/index`, - headers: { 'kbn-xsrf': 'delete-signals' }, + cy.request({ url: '/api/detection_engine/index', failOnStatusCode: false }).then((response) => { + if (response.status === 200) { + cy.request({ + method: 'DELETE', + url: `api/detection_engine/index`, + headers: { 'kbn-xsrf': 'delete-signals' }, + }); + } }); }; diff --git a/x-pack/plugins/security_solution/cypress/tasks/common.ts b/x-pack/plugins/security_solution/cypress/tasks/common.ts index bb009f34b02d..fbd4c4145e8f 100644 --- a/x-pack/plugins/security_solution/cypress/tasks/common.ts +++ b/x-pack/plugins/security_solution/cypress/tasks/common.ts @@ -4,6 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ +import { esArchiverLoadEmptyKibana } from './es_archiver'; + const primaryButton = 0; /** @@ -60,3 +62,8 @@ export const reload = (afterReload: () => void) => { cy.contains('a', 'Security'); afterReload(); }; + +export const cleanKibana = () => { + cy.exec(`curl -XDELETE "${Cypress.env('ELASTICSEARCH_URL')}/.kibana\*" -k`); + esArchiverLoadEmptyKibana(); +}; diff --git a/x-pack/test/security_solution_cypress/runner.ts b/x-pack/test/security_solution_cypress/runner.ts index a1a1a3916ef7..1cd32c55509e 100644 --- a/x-pack/test/security_solution_cypress/runner.ts +++ b/x-pack/test/security_solution_cypress/runner.ts @@ -16,7 +16,6 @@ export async function SecuritySolutionCypressCliTestRunner({ getService }: FtrPr const config = getService('config'); const esArchiver = getService('esArchiver'); - await esArchiver.load('empty_kibana'); await esArchiver.load('auditbeat'); await withProcRunner(log, async (procs) => { diff --git a/yarn.lock b/yarn.lock index 7cd0c3201328..f0148234d3d0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10904,10 +10904,10 @@ cypress-promise@^1.1.0: resolved "https://registry.yarnpkg.com/cypress-promise/-/cypress-promise-1.1.0.tgz#f2d66965945fe198431aaf692d5157cea9d47b25" integrity sha512-DhIf5PJ/a0iY+Yii6n7Rbwq+9TJxU4pupXYzf9mZd8nPG0AzQrj9i+pqINv4xbI2EV1p+PKW3maCkR7oPG4GrA== -cypress@^6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/cypress/-/cypress-6.0.1.tgz#86857ca2f527c3723575737deab42fd8f2a209df" - integrity sha512-3xtQZ0YM65soLgKQUgn2wg2IbWsM6A2yBg6L4RF31mZHr5LNKdO2/9sgiwxEVMKu2C2m6+IQ75zHP41kZP5rPg== +cypress@^6.1.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/cypress/-/cypress-6.1.0.tgz#af2596cb110aa98eaf75fef3d8ab379ca0ff2413" + integrity sha512-uQnSxRcZ6hkf9R5cr8KpRBTzN88QZwLIImbf5DWa5RIxH6o5Gpff58EcjiYhAR8/8p9SGv7O6SRygq4H+k0Qpw== dependencies: "@cypress/listr-verbose-renderer" "^0.4.1" "@cypress/request" "^2.88.5"