Skip to content

Commit

Permalink
fixes typecheck issue
Browse files Browse the repository at this point in the history
  • Loading branch information
MadameSheema committed Dec 19, 2020
1 parent af163ac commit b6a10d2
Show file tree
Hide file tree
Showing 19 changed files with 28 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@ import {
goToInProgressAlerts,
waitForAlertsIndexToBeCreated,
} from '../tasks/alerts';
import {
createCustomRuleActivated,
deleteCustomRule,
removeSignalsIndex,
} from '../tasks/api_calls/rules';
import { createCustomRuleActivated } from '../tasks/api_calls/rules';
import { cleanKibana } from '../tasks/common';
import { waitForAlertsToPopulate } from '../tasks/create_new_rule';
import { loginAndWaitForPage } from '../tasks/login';
Expand All @@ -43,7 +39,6 @@ describe('Alerts', () => {
context('Closing alerts', () => {
beforeEach(() => {
cleanKibana();
removeSignalsIndex();
loginAndWaitForPage(DETECTIONS_URL);
waitForAlertsPanelToBeLoaded();
waitForAlertsIndexToBeCreated();
Expand Down Expand Up @@ -157,7 +152,6 @@ describe('Alerts', () => {
context('Opening alerts', () => {
beforeEach(() => {
cleanKibana();
removeSignalsIndex();
loginAndWaitForPage(DETECTIONS_URL);
waitForAlertsPanelToBeLoaded();
waitForAlertsIndexToBeCreated();
Expand All @@ -173,11 +167,6 @@ describe('Alerts', () => {
refreshPage();
});

afterEach(() => {
deleteCustomRule();
removeSignalsIndex();
});

it('Open one alert when more than one closed alerts are selected', () => {
waitForAlertsToPopulate();

Expand Down Expand Up @@ -230,7 +219,6 @@ describe('Alerts', () => {
context('Marking alerts as in-progress', () => {
beforeEach(() => {
cleanKibana();
removeSignalsIndex();
loginAndWaitForPage(DETECTIONS_URL);
waitForAlertsPanelToBeLoaded();
waitForAlertsIndexToBeCreated();
Expand All @@ -239,11 +227,6 @@ describe('Alerts', () => {
waitForAlertsToPopulate();
});

afterEach(() => {
deleteCustomRule();
removeSignalsIndex();
});

it('Mark one alert in progress when more than one open alerts are selected', () => {
cy.get(ALERTS_COUNT)
.invoke('text')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import { cleanKibana } from '../tasks/common';
import { existingRule, newOverrideRule, newRule, newThresholdRule } from '../objects/rule';

describe('Alerts detection rules', () => {
before(() => {
beforeEach(() => {
cleanKibana();
removeSignalsIndex();
loginAndWaitForPageWithoutDateRange(DETECTIONS_URL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ import {
waitForLoadElasticPrebuiltDetectionRulesTableToBeLoaded,
waitForRulesToBeLoaded,
} from '../tasks/alerts_detection_rules';
import { createCustomRuleActivated, removeSignalsIndex } from '../tasks/api_calls/rules';
import { createCustomRuleActivated } from '../tasks/api_calls/rules';
import { createTimeline } from '../tasks/api_calls/timelines';
import { cleanKibana } from '../tasks/common';
import {
Expand Down Expand Up @@ -114,7 +114,7 @@ describe('Custom detection rules creation', () => {

const rule = { ...newRule };

before(() => {
beforeEach(() => {
cleanKibana();
createTimeline(newRule.timeline).then((response) => {
rule.timeline.id = response.body.data.persistTimeline.timeline.savedObjectId;
Expand Down Expand Up @@ -216,7 +216,6 @@ describe('Custom detection rules deletion and edition', () => {
context('Deletion', () => {
beforeEach(() => {
cleanKibana();
removeSignalsIndex();
loginAndWaitForPageWithoutDateRange(DETECTIONS_URL);
goToManageAlertsDetectionRules();
waitForAlertsIndexToBeCreated();
Expand Down Expand Up @@ -294,7 +293,6 @@ describe('Custom detection rules deletion and edition', () => {

before(() => {
cleanKibana();
removeSignalsIndex();
loginAndWaitForPageWithoutDateRange(DETECTIONS_URL);
goToManageAlertsDetectionRules();
waitForAlertsIndexToBeCreated();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ describe.skip('Detection rules, EQL', () => {

const rule = { ...eqlRule };

before(() => {
beforeEach(() => {
cleanKibana();
createTimeline(eqlRule.timeline).then((response) => {
rule.timeline.id = response.body.data.persistTimeline.timeline.savedObjectId;
Expand Down Expand Up @@ -178,7 +178,7 @@ describe.skip('Detection rules, sequence EQL', () => {
const expectedNumberOfSequenceAlerts = 1;
const rule = { ...eqlSequenceRule };

before(() => {
beforeEach(() => {
cleanKibana();
createTimeline(eqlSequenceRule.timeline).then((response) => {
rule.timeline.id = response.body.data.persistTimeline.timeline.savedObjectId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { DETECTIONS_URL } from '../urls/navigation';

describe('Export rules', () => {
let ruleResponse: Cypress.Response;
before(() => {
beforeEach(() => {
cleanKibana();
cy.intercept(
'POST',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describe('Detection rules, machine learning', () => {
const expectedMitre = formatMitreAttackDescription(machineLearningRule.mitre);
const expectedNumberOfRules = 1;

before(() => {
beforeEach(() => {
cleanKibana();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import { totalNumberOfPrebuiltRules } from '../objects/rule';
import { cleanKibana } from '../tasks/common';

describe('Alerts rules, prebuilt rules', () => {
before(() => {
beforeEach(() => {
cleanKibana();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
waitForAlertsIndexToBeCreated,
waitForAlertsPanelToBeLoaded,
} from '../tasks/alerts';
import { createCustomRuleActivated, removeSignalsIndex } from '../tasks/api_calls/rules';
import { createCustomRuleActivated } from '../tasks/api_calls/rules';
import { cleanKibana } from '../tasks/common';
import { waitForAlertsToPopulate } from '../tasks/create_new_rule';
import { loginAndWaitForPage } from '../tasks/login';
Expand All @@ -23,7 +23,6 @@ import { DETECTIONS_URL } from '../urls/navigation';
describe('Alerts timeline', () => {
beforeEach(() => {
cleanKibana();
removeSignalsIndex();
loginAndWaitForPage(DETECTIONS_URL);
waitForAlertsPanelToBeLoaded();
waitForAlertsIndexToBeCreated();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ import { CASES_URL } from '../urls/navigation';
describe('Cases', () => {
const mycase = { ...case1 };

before(() => {
beforeEach(() => {
cleanKibana();
createTimeline(case1.timeline).then((response) => {
mycase.timeline.id = response.body.data.persistTimeline.timeline.savedObjectId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { CONNECTOR_CARD_DETAILS, CONNECTOR_TITLE } from '../screens/case_details
import { cleanKibana } from '../tasks/common';

describe('Cases connector incident fields', () => {
before(() => {
beforeEach(() => {
cleanKibana();
cy.intercept('GET', '/api/cases/configure/connectors/_find', mockConnectorsResponse);
cy.intercept('POST', `/api/actions/action/${connectorIds.jira}/_execute`, (req) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('Cases connectors', () => {
],
version: 'WzEwNCwxXQ==',
};
before(() => {
beforeEach(() => {
cleanKibana();
cy.intercept('POST', '/api/actions/action').as('createConnector');
cy.intercept('POST', '/api/cases/configure', (req) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,21 @@ import {
import { DESCRIPTION_INPUT, ADD_COMMENT_INPUT } from '../screens/create_new_case';
import { case1 } from '../objects/case';
import { timeline } from '../objects/timeline';
import { createTimeline, deleteTimeline } from '../tasks/api_calls/timelines';
import { createTimeline } from '../tasks/api_calls/timelines';
import { cleanKibana } from '../tasks/common';
import { createCase } from '../tasks/api_calls/cases';

describe('attach timeline to case', () => {
const myTimeline = { ...timeline };

context('without cases created', () => {
before(() => {
beforeEach(() => {
cleanKibana();
createTimeline(timeline).then((response) => {
myTimeline.id = response.body.data.persistTimeline.timeline.savedObjectId;
});
});

after(() => {
deleteTimeline(myTimeline.id!);
});

it('attach timeline to a new case', () => {
loginAndWaitForTimeline(myTimeline.id!);
attachTimelineToNewCase();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,10 @@ import { openTimeline } from '../tasks/timelines';

import { OVERVIEW_URL } from '../urls/navigation';

// FLAKY: https://github.com/elastic/kibana/issues/79389
describe('Timelines', () => {
let timelineId: string;

before(() => {
beforeEach(() => {
cleanKibana();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { removeColumn } from '../tasks/timeline';

// Failing: See https://github.com/elastic/kibana/issues/75794
describe.skip('persistent timeline', () => {
before(() => {
beforeEach(() => {
cleanKibana();
loginAndWaitForPage(HOSTS_URL);
openEvents();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import { openTimeline } from '../tasks/timelines';
import { OVERVIEW_URL } from '../urls/navigation';

describe('Timeline Templates', () => {
before(() => {
beforeEach(() => {
cleanKibana();
cy.intercept('PATCH', '/api/timeline').as('timeline');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('Export timelines', () => {
let templateResponse: Cypress.Response;
let templateId: string;

before(() => {
beforeEach(() => {
cleanKibana();
cy.intercept('POST', 'api/timeline/_export?file_name=timelines_export.ndjson').as('export');
createTimelineTemplate(timelineTemplate).then((response) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { timeline } from '../objects/timeline';
import {
ID_HEADER_FIELD,
ID_TOGGLE_FIELD,
TIMESTAMP_HEADER_FIELD,
TIMESTAMP_TOGGLE_FIELD,
} from '../screens/timeline';
import { createTimeline, deleteTimeline } from '../tasks/api_calls/timelines';
import { cleanKibana } from '../tasks/common';

import { loginAndWaitForPage } from '../tasks/login';
Expand All @@ -29,14 +27,10 @@ import {
import { HOSTS_URL } from '../urls/navigation';

describe('toggle column in timeline', () => {
let timelineId: string;
before(() => {
cleanKibana();
cy.intercept('POST', '/api/timeline/_export?file_name=timelines_export.ndjson').as('export');
createTimeline(timeline).then((response) => {
timelineId = response.body.data.persistTimeline.timeline.savedObjectId;
loginAndWaitForPage(HOSTS_URL);
});
loginAndWaitForPage(HOSTS_URL);
});

beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { cleanKibana } from '../tasks/common';
describe('Export timelines', () => {
let timelineResponse: Cypress.Response;
let timelineId: string;
before(() => {
beforeEach(() => {
cleanKibana();
cy.intercept('POST', '/api/timeline/_export?file_name=timelines_export.ndjson').as('export');
createTimeline(timeline).then((response) => {
Expand Down
13 changes: 7 additions & 6 deletions x-pack/plugins/security_solution/cypress/tasks/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,14 @@ export const reload = (afterReload: () => void) => {
};

export const cleanKibana = () => {
removeSignalsIndex();
cy.exec(`curl -XDELETE "${Cypress.env('ELASTICSEARCH_URL')}/.kibana\*" -k`);
cy.wait(1000);
cy.request(`${Cypress.env('ELASTICSEARCH_URL')}/.kibana\*`).then((response) => {
if (response.body !== '{}') {
cy.wait(2000);
}
});
esArchiverLoadEmptyKibana();
cy.waitUntil(() => {
cy.wait(500);
return cy
.request(`${Cypress.env('ELASTICSEARCH_URL')}/.kibana\*`)
.then((response) => response.body !== '{}');
});
removeSignalsIndex();
};

0 comments on commit b6a10d2

Please sign in to comment.