Skip to content

Commit

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

## Summary

Addresses: #175020

Update:

- [Flaky test suite runner passed
successfully](https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/5521)
  • Loading branch information
MadameSheema authored Mar 19, 2024
1 parent 7975fab commit e90d7fe
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ 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'] }, () => {
context('without cases created', () => {
beforeEach(() => {
login();
deleteTimelines();
deleteAllCasesItems();
createTimeline(getTimeline()).then((response) => {
cy.wrap(response.body.data.persistTimeline.timeline).as('myTimeline');
});
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

Expand All @@ -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();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit e90d7fe

Please sign in to comment.