Skip to content

Commit

Permalink
Getting rid off before hook if is not loading an archive
Browse files Browse the repository at this point in the history
  • Loading branch information
MadameSheema committed Mar 18, 2024
1 parent 300b8ee commit da3f3c6
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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'] },
Expand All @@ -51,21 +57,21 @@ describe(

before(() => {
cy.task('esArchiverLoad', { archiveName: 'exceptions' });
login();
postDataView('exceptions-*');
});

after(() => {
cy.task('esArchiverUnload', { archiveName: 'exceptions' });
});

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,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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
Expand All @@ -79,9 +85,7 @@ describe(
createExceptionList(getExceptionList1(), getExceptionList1().list_id).then((response) => {
exceptionListResponse = response;
});
});

beforeEach(() => {
login();
visit(EXCEPTIONS_URL);
waitForExceptionsTableToBeLoaded();
Expand Down Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
Expand Down

0 comments on commit da3f3c6

Please sign in to comment.