diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/detection_response/detection_engine/exceptions/rule_details_flow/add_edit_exception_data_view.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/detection_response/detection_engine/exceptions/rule_details_flow/add_edit_exception_data_view.cy.ts index b986fc59deb23..5cfe2165e65e4 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/detection_response/detection_engine/exceptions/rule_details_flow/add_edit_exception_data_view.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/detection_response/detection_engine/exceptions/rule_details_flow/add_edit_exception_data_view.cy.ts @@ -30,7 +30,11 @@ import { waitForTheRuleToBeExecuted, } from '../../../../../tasks/rule_details'; -import { postDataView, deleteAlertsAndRules } from '../../../../../tasks/api_calls/common'; +import { + postDataView, + deleteAlertsAndRules, + deleteDataView, +} from '../../../../../tasks/api_calls/common'; import { NO_EXCEPTIONS_EXIST_PROMPT, EXCEPTION_ITEM_VIEWER_CONTAINER, @@ -42,6 +46,8 @@ import { } from '../../../../../screens/exceptions'; import { waitForAlertsToPopulate } from '../../../../../tasks/create_new_rule'; +const DATAVIEW = 'exceptions-*'; + describe( 'Add exception using data views from rule details', { tags: ['@ess', '@serverless'] }, @@ -51,8 +57,6 @@ describe( before(() => { cy.task('esArchiverLoad', { archiveName: 'exceptions' }); - login(); - postDataView('exceptions-*'); }); after(() => { @@ -60,12 +64,14 @@ describe( }); beforeEach(() => { + deleteDataView(DATAVIEW); + postDataView(DATAVIEW); login(); deleteAlertsAndRules(); createRule( getNewRule({ query: 'agent.name:*', - data_view_id: 'exceptions-*', + data_view_id: DATAVIEW, rule_id: 'rule_testing', enabled: true, }) diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/detection_response/detection_engine/exceptions/shared_exception_lists_management/shared_exception_list_page/manage_lists.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/detection_response/detection_engine/exceptions/shared_exception_lists_management/shared_exception_list_page/manage_lists.cy.ts index 2d1dbf6ed24cf..90d6eed7a46a9 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/detection_response/detection_engine/exceptions/shared_exception_lists_management/shared_exception_list_page/manage_lists.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/detection_response/detection_engine/exceptions/shared_exception_lists_management/shared_exception_list_page/manage_lists.cy.ts @@ -33,6 +33,10 @@ import { import { createExceptionList } from '../../../../../../tasks/api_calls/exceptions'; import { TOASTER } from '../../../../../../screens/alerts_detection_rules'; +import { + deleteAlertsAndRules, + deleteExceptionLists, +} from '../../../../../../tasks/api_calls/common'; const EXCEPTION_LIST_NAME = 'My test list'; const EXCEPTION_LIST_TO_DUPLICATE_NAME = 'A test list 2'; @@ -56,7 +60,9 @@ describe( { tags: ['@ess', '@serverless'] }, () => { describe('Create/Export/Delete List', () => { - before(() => { + beforeEach(() => { + deleteAlertsAndRules(); + deleteExceptionLists(); createRule(getNewRule({ name: 'Another rule' })); // Create exception list associated with a rule @@ -79,9 +85,7 @@ describe( createExceptionList(getExceptionList1(), getExceptionList1().list_id).then((response) => { exceptionListResponse = response; }); - }); - beforeEach(() => { login(); visit(EXCEPTIONS_URL); waitForExceptionsTableToBeLoaded(); @@ -124,13 +128,13 @@ describe( it('Delete exception list without rule reference', () => { // Using cy.contains because we do not care about the exact text, // just checking number of lists shown - cy.contains(EXCEPTIONS_TABLE_SHOWING_LISTS, '4'); + cy.contains(EXCEPTIONS_TABLE_SHOWING_LISTS, '3'); deleteExceptionListWithoutRuleReferenceByListId(getExceptionList1().list_id); // Using cy.contains because we do not care about the exact text, // just checking number of lists shown - cy.contains(EXCEPTIONS_TABLE_SHOWING_LISTS, '3'); + cy.contains(EXCEPTIONS_TABLE_SHOWING_LISTS, '2'); }); it('Deletes exception list with rule reference', () => { diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/detection_response/detection_engine/sourcerer/create_runtime_field.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/detection_response/detection_engine/sourcerer/create_runtime_field.cy.ts index af6500c6e6db4..9ef5238295ed8 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/detection_response/detection_engine/sourcerer/create_runtime_field.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/detection_response/detection_engine/sourcerer/create_runtime_field.cy.ts @@ -27,13 +27,10 @@ const alertRunTimeField = 'field.name.alert.page'; const timelineRuntimeField = 'field.name.timeline'; describe('Create DataView runtime field', { tags: ['@ess', '@serverless'] }, () => { - before(() => { - deleteRuntimeField('security-solution-default', alertRunTimeField); - deleteRuntimeField('security-solution-default', timelineRuntimeField); - }); - beforeEach(() => { login(); + deleteRuntimeField('security-solution-default', alertRunTimeField); + deleteRuntimeField('security-solution-default', timelineRuntimeField); }); it('adds field to alert table', () => { diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/detection_response/detection_engine/sourcerer/sourcerer_permissions.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/detection_response/detection_engine/sourcerer/sourcerer_permissions.cy.ts index 4c7b0dd90da9f..a1692fca5b859 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/detection_response/detection_engine/sourcerer/sourcerer_permissions.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/detection_response/detection_engine/sourcerer/sourcerer_permissions.cy.ts @@ -16,7 +16,7 @@ import { login } from '../../../../tasks/login'; const dataViews = ['auditbeat-*,fakebeat-*', 'auditbeat-*,*beat*,siem-read*,.kibana*,fakebeat-*']; describe('Sourcerer permissions', { tags: ['@ess', '@brokenInServerless'] }, () => { - before(() => { + beforeEach(() => { dataViews.forEach((dataView: string) => postDataView(dataView)); }); diff --git a/x-pack/test/security_solution_cypress/cypress/tasks/api_calls/exceptions.ts b/x-pack/test/security_solution_cypress/cypress/tasks/api_calls/exceptions.ts index 4e0afa7416da0..ff128448daa23 100644 --- a/x-pack/test/security_solution_cypress/cypress/tasks/api_calls/exceptions.ts +++ b/x-pack/test/security_solution_cypress/cypress/tasks/api_calls/exceptions.ts @@ -100,7 +100,7 @@ export const updateExceptionListItem = ( failOnStatusCode: false, }); -export const deleteExceptionList = (listId: string, namespaceType: string) => +export const deleteExceptionList = (listId: string, namespaceType: string = 'default') => rootRequest({ method: 'DELETE', url: `/api/exception_lists?list_id=${listId}&namespace_type=${namespaceType}`,