Skip to content

Commit

Permalink
[Security Solution][Investigations][Cypress] Getting rid off before h…
Browse files Browse the repository at this point in the history
…ook if is not loading an archive (#178839)

## Summary

Addresses: #175019
  • Loading branch information
MadameSheema authored Mar 19, 2024
1 parent 9425de1 commit 5614bd7
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ describe('Alert details flyout', { tags: ['@ess', '@serverless'] }, () => {

describe('With unmapped fields', () => {
before(() => {
deleteAlertsAndRules();
cy.task('esArchiverLoad', { archiveName: 'unmapped_fields' });
createRule({ ...getUnmappedRule(), investigation_fields: { field_names: ['event.kind'] } });
});

beforeEach(() => {
deleteAlertsAndRules();
createRule({ ...getUnmappedRule(), investigation_fields: { field_names: ['event.kind'] } });
login();
disableExpandableFlyout();
visit(ALERTS_URL);
Expand Down Expand Up @@ -188,7 +188,6 @@ describe('Alert details flyout', { tags: ['@ess', '@serverless'] }, () => {

before(() => {
deleteAlertsAndRules();

// It just imports an alert without a rule but rule details page should work anyway
cy.task('esArchiverLoad', { archiveName: 'query_alert', useCreate: true, docsOnly: true });
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ import { waitForAlertsToPopulate } from '../../../tasks/create_new_rule';
import { login } from '../../../tasks/login';
import { visitWithTimeRange } from '../../../tasks/navigation';
import { ALERTS_URL } from '../../../urls/navigation';
import { deleteAlertsAndRules } from '../../../tasks/api_calls/common';

describe.skip('Analyze events view for alerts', { tags: ['@ess', '@serverless'] }, () => {
before(() => {
createRule(getNewRule());
});

beforeEach(() => {
deleteAlertsAndRules();
createRule(getNewRule());
login();
visitWithTimeRange(ALERTS_URL);
waitForAlertsToPopulate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ const SIEM_KIBANA_HOST_NAME = 'siem-kibana';
// FLAKY: https://github.com/elastic/kibana/issues/168772
describe.skip('Detection response view', { tags: ['@ess', '@serverless'] }, () => {
before(() => {
deleteAlertsAndRules();
cy.task('esArchiverLoad', { archiveName: 'auditbeat_multiple' });
createRule(getNewRule());
});

beforeEach(() => {
deleteAlertsAndRules();
createRule(getNewRule());
login();
visit(DETECTION_AND_RESPONSE_URL);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ import {
import { TIMELINE_TEMPLATES_URL } from '../../../urls/navigation';
import { createTimelineTemplate } from '../../../tasks/api_calls/timelines';
import { searchByTitle } from '../../../tasks/table_pagination';
import { deleteTimelines } from '../../../tasks/api_calls/common';

describe('Export timelines', { tags: ['@ess', '@serverless'] }, () => {
before(() => {
beforeEach(() => {
deleteTimelines();
createTimelineTemplate(getTimelineTemplate()).then((response) => {
cy.wrap(response).as('templateResponse');
cy.wrap(response.body.data.persistTimeline.timeline.savedObjectId).as('templateId');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { getNewRule } from '../../../objects/rule';
import { SELECTED_ALERTS } from '../../../screens/alerts';
import { SERVER_SIDE_EVENT_COUNT } from '../../../screens/timeline';
import { selectAllAlerts, selectFirstPageAlerts } from '../../../tasks/alerts';
import { deleteAlertsAndRules } from '../../../tasks/api_calls/common';
import { createRule } from '../../../tasks/api_calls/rules';
import {
bulkInvestigateSelectedEventsInTimeline,
Expand All @@ -25,19 +26,16 @@ import { ALERTS_URL, hostsUrl } from '../../../urls/navigation';
describe('Bulk Investigate in Timeline', { tags: ['@ess', '@serverless'] }, () => {
before(() => {
cy.task('esArchiverLoad', { archiveName: 'bulk_process' });
login();
});

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

context('Alerts', () => {
before(() => {
createRule(getNewRule());
});

beforeEach(() => {
deleteAlertsAndRules();
createRule(getNewRule());
login();
visitWithTimeRange(ALERTS_URL);
waitForAlertsToPopulate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,46 +21,30 @@ import { MODAL_CONFIRMATION_BTN } from '../../../screens/alerts_detection_rules'
import { createTimeline } from '../../../tasks/api_calls/timelines';

import { login } from '../../../tasks/login';
import { visit } from '../../../tasks/navigation';
import {
addNotesToTimeline,
goToNotesTab,
openTimelineById,
refreshTimelinesUntilTimeLinePresent,
} from '../../../tasks/timeline';
import { visitTimeline } from '../../../tasks/navigation';
import { addNotesToTimeline, goToNotesTab } from '../../../tasks/timeline';

import { TIMELINES_URL } from '../../../urls/navigation';
import { deleteTimelines } from '../../../tasks/api_calls/common';

const text = 'system_indices_superuser';
const link = 'https://www.elastic.co/';

describe.skip('Timeline notes tab', { tags: ['@ess', '@serverless'] }, () => {
before(() => {
login();
visit(TIMELINES_URL);
describe('Timeline notes tab', { tags: ['@ess', '@serverless'] }, () => {
beforeEach(function () {
deleteTimelines();

createTimeline(getTimelineNonValidQuery())
.then((response) => response.body.data.persistTimeline.timeline.savedObjectId)
.then((timelineId: string) =>
refreshTimelinesUntilTimeLinePresent(timelineId)
// This cy.wait is here because we cannot do a pipe on a timeline as that will introduce multiple URL
// request responses and indeterminism since on clicks to activates URL's.
.then(() => cy.wrap(timelineId).as('timelineId'))
);
});

beforeEach(function () {
login();
visit(TIMELINES_URL);
openTimelineById(this?.timelineId as string);
.then((timelineId: string) => {
login();
visitTimeline(timelineId);
});
goToNotesTab();
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(1000);
});

it('should render mockdown', () => {
addNotesToTimeline(getTimelineNonValidQuery().notes);
cy.get(NOTES_TEXT_AREA).should('exist');
cy.get(NOTES_TEXT_AREA).should('be.visible');
});

it('should contain notes', () => {
Expand All @@ -80,7 +64,7 @@ describe.skip('Timeline notes tab', { tags: ['@ess', '@serverless'] }, () => {

it('should be able to render code blocks', () => {
addNotesToTimeline(`\`code\``);
cy.get(NOTES_CODE_BLOCK).should('exist');
cy.get(NOTES_CODE_BLOCK).should('be.visible');
});

it('should render the right author', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,15 @@ import { visit } from '../../../tasks/navigation';
import { createTimeline, favoriteTimeline } from '../../../tasks/api_calls/timelines';

import { TIMELINES_URL } from '../../../urls/navigation';
import { deleteTimelines } from '../../../tasks/api_calls/common';

describe('timeline overview search', { tags: ['@ess', 'serverless'] }, () => {
before(() => {
beforeEach(() => {
deleteTimelines();
createTimeline(getFavoritedTimeline())
.then((response) => response.body.data.persistTimeline.timeline.savedObjectId)
.then((timelineId) => favoriteTimeline({ timelineId, timelineType: 'default' }));
createTimeline(getTimeline());
});

beforeEach(() => {
login();
visit(TIMELINES_URL);
cy.get(TIMELINES_OVERVIEW_SEARCH).clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,9 @@ export const addNameAndDescriptionToTimeline = (
cy.get(TIMELINE_TITLE_INPUT).should('not.exist');
};

export const goToNotesTab = (): Cypress.Chainable<JQuery<HTMLElement>> => {
export const goToNotesTab = () => {
cy.get(NOTES_TAB_BUTTON).click();
cy.get(NOTES_TEXT_AREA).should('exist');

return cy.get(NOTES_TAB_BUTTON);
cy.get(NOTES_TEXT_AREA).should('be.visible');
};

export const goToEsqlTab = () => waitForTabToBeLoaded(ESQL_TAB);
Expand Down

0 comments on commit 5614bd7

Please sign in to comment.