diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/explore/cases/attach_alert_to_case.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/explore/cases/attach_alert_to_case.cy.ts index 6b40e1d336186..a4370e9073509 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/explore/cases/attach_alert_to_case.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/explore/cases/attach_alert_to_case.cy.ts @@ -17,6 +17,7 @@ import { visit } from '../../../tasks/navigation'; import { ALERTS_URL } from '../../../urls/navigation'; import { ATTACH_ALERT_TO_CASE_BUTTON, TIMELINE_CONTEXT_MENU_BTN } from '../../../screens/alerts'; import { LOADING_INDICATOR } from '../../../screens/security_header'; +import { deleteAlertsAndRules } from '../../../tasks/api_calls/common'; const loadDetectionsPage = (role: SecurityRoleName) => { login(role); @@ -25,10 +26,11 @@ const loadDetectionsPage = (role: SecurityRoleName) => { }; describe('Alerts timeline', { tags: ['@ess'] }, () => { - before(() => { + beforeEach(() => { // First we login as a privileged user to create alerts. - login(); + deleteAlertsAndRules(); createRule(getNewRule()); + login(); visit(ALERTS_URL); waitForAlertsToPopulate(); }); diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/explore/cases/attach_timeline.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/explore/cases/attach_timeline.cy.ts index a6e82d8e6aa97..04f50c5b7afb9 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/explore/cases/attach_timeline.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/explore/cases/attach_timeline.cy.ts @@ -17,7 +17,7 @@ import { DESCRIPTION_INPUT, ADD_COMMENT_INPUT } from '../../../screens/create_ne import { getCase1 } from '../../../objects/case'; import { getTimeline } from '../../../objects/timeline'; import { createTimeline } from '../../../tasks/api_calls/timelines'; -import { deleteTimelines } from '../../../tasks/api_calls/common'; +import { deleteAllCasesItems, deleteTimelines } from '../../../tasks/api_calls/common'; import { createCase } from '../../../tasks/api_calls/cases'; describe('attach timeline to case', { tags: ['@ess', '@serverless'] }, () => { @@ -25,6 +25,7 @@ describe('attach timeline to case', { tags: ['@ess', '@serverless'] }, () => { beforeEach(() => { login(); deleteTimelines(); + deleteAllCasesItems(); createTimeline(getTimeline()).then((response) => { cy.wrap(response.body.data.persistTimeline.timeline).as('myTimeline'); }); @@ -57,19 +58,16 @@ describe('attach timeline to case', { tags: ['@ess', '@serverless'] }, () => { }); context('with cases created', () => { - before(() => { + beforeEach(() => { login(); deleteTimelines(); + deleteAllCasesItems(); createTimeline(getTimeline()).then((response) => cy.wrap(response.body.data.persistTimeline.timeline.savedObjectId).as('timelineId') ); createCase(getCase1()).then((response) => cy.wrap(response.body.id).as('caseId')); }); - beforeEach(() => { - login(); - }); - it('attach timeline to an existing case', function () { visitTimeline(this.timelineId); attachTimelineToExistingCase(); diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/explore/cases/creation.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/explore/cases/creation.cy.ts index 698a97df6b5d6..780ce1168fa3a 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/explore/cases/creation.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/explore/cases/creation.cy.ts @@ -53,10 +53,13 @@ import { visit, visitWithTimeRange } from '../../../tasks/navigation'; import { CASES_URL, OVERVIEW_URL } from '../../../urls/navigation'; import { ELASTICSEARCH_USERNAME } from '../../../env_var_names_constants'; +import { deleteAllCasesItems, deleteTimelines } from '../../../tasks/api_calls/common'; // Tracked by https://github.com/elastic/security-team/issues/7696 describe('Cases', { tags: ['@ess', '@serverless'] }, () => { - before(() => { + beforeEach(() => { + deleteTimelines(); + deleteAllCasesItems(); createTimeline(getCase1().timeline).then((response) => cy .wrap({ diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/explore/cases/privileges.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/explore/cases/privileges.cy.ts index 7768a892d5d09..cd1781ddd5885 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/explore/cases/privileges.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/explore/cases/privileges.cy.ts @@ -50,15 +50,9 @@ const testCase: TestCaseWithoutTimeline = { }; describe('Cases privileges', { tags: ['@ess'] }, () => { - before(() => { - createUsersAndRoles(usersToCreate, rolesToCreate); - }); - - after(() => { - deleteUsersAndRoles(usersToCreate, rolesToCreate); - }); - beforeEach(() => { + deleteUsersAndRoles(usersToCreate, rolesToCreate); + createUsersAndRoles(usersToCreate, rolesToCreate); login(); deleteAllCasesItems(); }); diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/explore/filters/pinned_filters.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/explore/filters/pinned_filters.cy.ts index 516b776a86e3d..635f476bf4967 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/explore/filters/pinned_filters.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/explore/filters/pinned_filters.cy.ts @@ -21,15 +21,15 @@ import { openKibanaNavigation, } from '../../../tasks/kibana_navigation'; import { ALERTS_PAGE } from '../../../screens/kibana_navigation'; -import { postDataView } from '../../../tasks/api_calls/common'; +import { deleteDataView, postDataView } from '../../../tasks/api_calls/common'; import { navigateToAlertsPageInServerless } from '../../../tasks/serverless/navigation'; -describe('ESS - pinned filters', { tags: ['@ess'] }, () => { - before(() => { - postDataView('audit*'); - }); +const DATAVIEW = 'audit*'; +describe('ESS - pinned filters', { tags: ['@ess'] }, () => { beforeEach(() => { + deleteDataView(DATAVIEW); + postDataView(DATAVIEW); login(); }); @@ -55,11 +55,9 @@ describe('ESS - pinned filters', { tags: ['@ess'] }, () => { }); describe('SERVERLESS - pinned filters', { tags: ['@serverless'] }, () => { - before(() => { - postDataView('audit*'); - }); - beforeEach(() => { + deleteDataView(DATAVIEW); + postDataView(DATAVIEW); login(); }); diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/explore/guided_onboarding/tour.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/explore/guided_onboarding/tour.cy.ts index 93ce4f5861889..cebc67a78d2ef 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/explore/guided_onboarding/tour.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/explore/guided_onboarding/tour.cy.ts @@ -28,13 +28,12 @@ import { waitForAlertsToPopulate } from '../../../tasks/create_new_rule'; import { login } from '../../../tasks/login'; import { visit } from '../../../tasks/navigation'; import { startAlertsCasesTour } from '../../../tasks/api_calls/tour'; +import { deleteAlertsAndRules } from '../../../tasks/api_calls/common'; describe('Guided onboarding tour', { tags: ['@ess'] }, () => { - before(() => { - login(); - createRule(getNewRule({ query: 'user.name:*' })); - }); beforeEach(() => { + deleteAlertsAndRules(); + createRule(getNewRule({ query: 'user.name:*' })); login(); disableExpandableFlyout(); startAlertsCasesTour();