Skip to content

Commit

Permalink
[SIEM] Cleans Cypress tests code (#58134) (#58197)
Browse files Browse the repository at this point in the history
* deletes 'events viewer' lib

* deletes 'fields browser' lib

* deletes 'inspect' lib

* deletes 'ml conditional links' lib

* deletes 'navigate' lib

* delete 'overview' lib

* deletes 'pagination' lib

* deletes 'timeline' lib

* deletes 'url state' lib

* deletes the rest of lib folders

* reorders tasks and screens

* reorders 'integration' folder

* orders integration files

* extracts defeault timeout to cypress configuration

* orders screens files

* cleans tasks files

* fixes type check
  • Loading branch information
MadameSheema authored Feb 21, 2020
1 parent f3137a2 commit 16bb9d0
Show file tree
Hide file tree
Showing 61 changed files with 562 additions and 1,491 deletions.
1 change: 1 addition & 0 deletions x-pack/legacy/plugins/siem/cypress.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"baseUrl": "http://localhost:5601",
"defaultCommandTimeout": 30000,
"screenshotsFolder": "../../../../target/kibana-siem/cypress/screenshots",
"trashAssetsBeforeRuns": false,
"video": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,36 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { filterFieldsBrowser } from '../../lib/fields_browser/helpers';
import {
FIELDS_BROWSER_CHECKBOX,
FIELDS_BROWSER_CONTAINER,
FIELDS_BROWSER_SELECTED_CATEGORY_TITLE,
FIELDS_BROWSER_TITLE,
FIELDS_BROWSER_CHECKBOX,
} from '../../../screens/hosts/fields_browser';
import { HOSTS_PAGE } from '../../lib/urls';
import { loginAndWaitForPage } from '../../../tasks/login';
import { openEventsViewerFieldsBrowser, filterSearchBar } from '../../lib/events_viewer/helpers';
import { closeFieldsBrowser } from '../../../tasks/hosts/fields_browsers';
import { openEvents } from '../../../tasks/hosts/main';
import {
closeModal,
opensInspectQueryModal,
waitsForEventsToBeLoaded,
addsHostGeoCityNameToHeader,
addsHostGeoCountryNameToHeader,
resetFields,
} from '../../../tasks/hosts/events';

} from '../screens/fields_browser';
import {
HEADER_SUBTITLE,
HOST_GEO_CITY_NAME_HEADER,
HOST_GEO_COUNTRY_NAME_HEADER,
INSPECT_MODAL,
LOAD_MORE,
LOCAL_EVENTS_COUNT,
HOST_GEO_CITY_NAME_HEADER,
HOST_GEO_COUNTRY_NAME_HEADER,
} from '../../../screens/hosts/events';
import { DEFAULT_TIMEOUT } from '../../lib/util/helpers';
} from '../screens/hosts/events';

import { closeFieldsBrowser, filterFieldsBrowser } from '../tasks/fields_browser';
import { loginAndWaitForPage } from '../tasks/login';
import { openEvents } from '../tasks/hosts/main';
import {
addsHostGeoCityNameToHeader,
addsHostGeoCountryNameToHeader,
closeModal,
openEventsViewerFieldsBrowser,
opensInspectQueryModal,
resetFields,
waitsForEventsToBeLoaded,
} from '../tasks/hosts/events';
import { clearSearchBar, kqlSearch } from '../tasks/siem_header';

import { clearSearchBar } from '../../../tasks/header';
import { HOSTS_PAGE } from '../urls/navigation';

const defaultHeadersInDefaultEcsCategory = [
{ id: '@timestamp' },
Expand Down Expand Up @@ -90,13 +88,13 @@ describe('Events Viewer', () => {

after(() => {
closeModal();
cy.get(INSPECT_MODAL, { timeout: DEFAULT_TIMEOUT }).should('not.exist');
cy.get(INSPECT_MODAL).should('not.exist');
});

it('launches the inspect query modal when the inspect button is clicked', () => {
waitsForEventsToBeLoaded();
opensInspectQueryModal();
cy.get(INSPECT_MODAL, { timeout: DEFAULT_TIMEOUT }).should('exist');
cy.get(INSPECT_MODAL).should('exist');
});
});

Expand Down Expand Up @@ -147,7 +145,7 @@ describe('Events Viewer', () => {
cy.get(HEADER_SUBTITLE)
.invoke('text')
.then(initialNumberOfEvents => {
filterSearchBar(filterInput);
kqlSearch(`${filterInput}{enter}`);
cy.get(HEADER_SUBTITLE)
.invoke('text')
.should('not.equal', initialNumberOfEvents);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,35 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { HOSTS_PAGE } from '../../lib/urls';

import { loginAndWaitForPage, DEFAULT_TIMEOUT } from '../../../tasks/login';

import {
FIELDS_BROWSER_TITLE,
FIELDS_BROWSER_SELECTED_CATEGORY_TITLE,
FIELDS_BROWSER_SELECTED_CATEGORY_COUNT,
FIELDS_BROWSER_CATEGORIES_COUNT,
FIELDS_BROWSER_HOST_CATEGORIES_COUNT,
FIELDS_BROWSER_SYSTEM_CATEGORIES_COUNT,
FIELDS_BROWSER_FIELDS_COUNT,
FIELDS_BROWSER_MESSAGE_HEADER,
FIELDS_BROWSER_HOST_CATEGORIES_COUNT,
FIELDS_BROWSER_HOST_GEO_CITY_NAME_HEADER,
FIELDS_BROWSER_HOST_GEO_COUNTRY_NAME_HEADER,
FIELDS_BROWSER_HEADER_HOST_GEO_CONTINENT_NAME_HEADER,
} from '../../../screens/timeline/fields_browser';

import { populateTimeline, openTimelineFieldsBrowser } from '../../../tasks/timeline/main';

import { openTimeline } from '../../../tasks/siem_main';
FIELDS_BROWSER_MESSAGE_HEADER,
FIELDS_BROWSER_SELECTED_CATEGORY_TITLE,
FIELDS_BROWSER_SELECTED_CATEGORY_COUNT,
FIELDS_BROWSER_SYSTEM_CATEGORIES_COUNT,
FIELDS_BROWSER_TITLE,
} from '../screens/fields_browser';

import {
addsHostGeoCityNameToTimeline,
addsHostGeoContinentNameToTimeline,
addsHostGeoCountryNameToTimelineDraggingIt,
clearFieldsBrowser,
filterFieldsBrowser,
closeFieldsBrowser,
filterFieldsBrowser,
removesMessageField,
addsHostGeoCityNameToTimeline,
addsHostGeoCountryNameToTimelineDraggingIt,
addsHostGeoContinentNameToTimeline,
resetFields,
} from '../../../tasks/timeline/fields_browser';
} from '../tasks/fields_browser';
import { loginAndWaitForPage } from '../tasks/login';
import { openTimeline } from '../tasks/siem_main';
import { openTimelineFieldsBrowser, populateTimeline } from '../tasks/timeline';

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

const defaultHeaders = [
{ id: '@timestamp' },
Expand Down Expand Up @@ -90,7 +87,7 @@ describe('Fields Browser', () => {

filterFieldsBrowser(filterInput);

cy.get(FIELDS_BROWSER_CATEGORIES_COUNT, { timeout: DEFAULT_TIMEOUT })
cy.get(FIELDS_BROWSER_CATEGORIES_COUNT)
.invoke('text')
.should('eq', '2 categories');
});
Expand All @@ -106,7 +103,7 @@ describe('Fields Browser', () => {
cy.get(FIELDS_BROWSER_SYSTEM_CATEGORIES_COUNT)
.invoke('text')
.then(systemCategoriesCount => {
cy.get(FIELDS_BROWSER_FIELDS_COUNT, { timeout: DEFAULT_TIMEOUT })
cy.get(FIELDS_BROWSER_FIELDS_COUNT)
.invoke('text')
.should('eq', `${+hostCategoriesCount + +systemCategoriesCount} fields`);
});
Expand Down Expand Up @@ -163,9 +160,7 @@ describe('Fields Browser', () => {
addsHostGeoCityNameToTimeline();
closeFieldsBrowser();

cy.get(FIELDS_BROWSER_HOST_GEO_CITY_NAME_HEADER, {
timeout: DEFAULT_TIMEOUT,
}).should('exist');
cy.get(FIELDS_BROWSER_HOST_GEO_CITY_NAME_HEADER).should('exist');
});

it('adds a field to the timeline when the user drags and drops a field', () => {
Expand All @@ -177,9 +172,7 @@ describe('Fields Browser', () => {

addsHostGeoCountryNameToTimelineDraggingIt();

cy.get(FIELDS_BROWSER_HOST_GEO_COUNTRY_NAME_HEADER, {
timeout: DEFAULT_TIMEOUT,
}).should('exist');
cy.get(FIELDS_BROWSER_HOST_GEO_COUNTRY_NAME_HEADER).should('exist');
});

it('resets all fields in the timeline when `Reset Fields` is clicked', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { HOSTS_PAGE, NETWORK_PAGE } from '../../lib/urls';
import {
INSPECT_HOSTS_BUTTONS_IN_SIEM,
INSPECT_MODAL,
INSPECT_NETWORK_BUTTONS_IN_SIEM,
INSPECT_HOSTS_BUTTONS_IN_SIEM,
} from '../../../screens/inspect';
} from '../screens/inspect';

import { closesModal, openStatsAndTables } from '../tasks/inspect';
import { loginAndWaitForPage } from '../tasks/login';
import { openTimeline } from '../tasks/siem_main';
import {
executeTimelineKQL,
openTimelineSettings,
openTimelineInspectButton,
} from '../../../tasks/timeline/main';
import { openTimeline } from '../../../tasks/siem_main';
import { DEFAULT_TIMEOUT, loginAndWaitForPage } from '../../../tasks/login';
import { closesModal, openStatsAndTables } from '../../../tasks/inspect';
openTimelineSettings,
} from '../tasks/timeline';

import { HOSTS_PAGE, NETWORK_PAGE } from '../urls/navigation';

describe('Inspect', () => {
context('Hosts stats and tables', () => {
Expand All @@ -31,7 +33,7 @@ describe('Inspect', () => {
INSPECT_HOSTS_BUTTONS_IN_SIEM.forEach(table =>
it(`inspects the ${table.title}`, () => {
openStatsAndTables(table);
cy.get(INSPECT_MODAL, { timeout: DEFAULT_TIMEOUT }).should('be.visible');
cy.get(INSPECT_MODAL).should('be.visible');
})
);
});
Expand All @@ -47,7 +49,7 @@ describe('Inspect', () => {
INSPECT_NETWORK_BUTTONS_IN_SIEM.forEach(table =>
it(`inspects the ${table.title}`, () => {
openStatsAndTables(table);
cy.get(INSPECT_MODAL, { timeout: DEFAULT_TIMEOUT }).should('be.visible');
cy.get(INSPECT_MODAL).should('be.visible');
})
);
});
Expand All @@ -60,7 +62,7 @@ describe('Inspect', () => {
executeTimelineKQL(hostExistsQuery);
openTimelineSettings();
openTimelineInspectButton();
cy.get(INSPECT_MODAL, { timeout: DEFAULT_TIMEOUT }).should('be.visible');
cy.get(INSPECT_MODAL).should('be.visible');
});
});
});

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 16bb9d0

Please sign in to comment.