Skip to content

Commit

Permalink
Add cypress tests for inspect button on explore pages (elastic#151714)
Browse files Browse the repository at this point in the history
EPIC: elastic/security-team#5979
Test: `C164772 | Validate that Inspect button works correctly and
details display as per the data view selected after the build upgrade`

## Summary
* Group all inspect button tests into one file to make the test quicker.
* Add entries for missing visualizations and tables

Many cypress tests are broken because I enabled the experimental
feature. They will be fixed by this PR
elastic#150531


- [x] Unkip cypress tests listed
[here](elastic#152359)

### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
  • Loading branch information
machadoum authored and bmorelli25 committed Mar 10, 2023
1 parent f459cb6 commit 2dea7d2
Show file tree
Hide file tree
Showing 20 changed files with 414 additions and 173 deletions.
Expand Up @@ -14,7 +14,6 @@ import {
import {
HOST_GEO_CITY_NAME_HEADER,
HOST_GEO_COUNTRY_NAME_HEADER,
INSPECT_MODAL,
SERVER_SIDE_EVENT_COUNT,
} from '../../screens/hosts/events';

Expand All @@ -30,7 +29,6 @@ import {
addsHostGeoCityNameToHeader,
addsHostGeoCountryNameToHeader,
openEventsViewerFieldsBrowser,
opensInspectQueryModal,
waitsForEventsToBeLoaded,
} from '../../tasks/hosts/events';
import { clearSearchBar, kqlSearch } from '../../tasks/security_header';
Expand Down Expand Up @@ -93,12 +91,6 @@ describe('Events Viewer', () => {
visit(HOSTS_URL);
openEvents();
});

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

context('Events viewer fields behaviour', () => {
Expand Down
50 changes: 0 additions & 50 deletions x-pack/plugins/security_solution/cypress/e2e/hosts/inspect.cy.ts

This file was deleted.

@@ -0,0 +1,80 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import {
INSPECT_BUTTONS_IN_SECURITY,
INSPECT_MODAL,
INSPECT_MODAL_INDEX_PATTERN,
} from '../../screens/inspect';
import {
closesModal,
openLensVisualizationsInspectModal,
openTab,
openTableInspectModal,
} from '../../tasks/inspect';
import { login, visit } from '../../tasks/login';
import { HOSTS_URL } from '../../urls/navigation';
import { postDataView, waitForPageToBeLoaded } from '../../tasks/common';
import { esArchiverLoad, esArchiverUnload } from '../../tasks/es_archiver';
import { selectDataView } from '../../tasks/sourcerer';

const DATA_VIEW = 'auditbeat-*';

describe('Inspect Explore pages', () => {
before(() => {
esArchiverLoad('risk_users');
esArchiverLoad('risk_hosts');
login();

// Create and select data view
postDataView(DATA_VIEW);
visit(HOSTS_URL);
selectDataView(DATA_VIEW);
});

after(() => {
esArchiverUnload('risk_users');
esArchiverUnload('risk_hosts');
});

INSPECT_BUTTONS_IN_SECURITY.forEach(({ pageName, url, lensVisualizations, tables }) => {
/**
* Group all tests of a page into one "it" call to improve speed
*/
it(`inspect ${pageName} page`, () => {
visit(url);
waitForPageToBeLoaded();

lensVisualizations.forEach((lens) => {
cy.log(`inspects the ${lens.title} visualization`);
openTab(lens.tab);

openLensVisualizationsInspectModal(lens, () => {
cy.get(INSPECT_MODAL).should('be.visible');
cy.get(INSPECT_MODAL_INDEX_PATTERN).should(
'contain.text',
lens.customIndexPattern ? lens.customIndexPattern : DATA_VIEW
);
});
});

tables.forEach((table) => {
cy.log(`inspects the ${table.title}`);
openTab(table.tab);

openTableInspectModal(table);
cy.get(INSPECT_MODAL).should('be.visible');
cy.get(INSPECT_MODAL_INDEX_PATTERN).should(
'contain.text',
table.customIndexPattern ? table.customIndexPattern : DATA_VIEW
);

closesModal();
});
});
});
});
37 changes: 0 additions & 37 deletions x-pack/plugins/security_solution/cypress/e2e/network/inspect.cy.ts

This file was deleted.

40 changes: 0 additions & 40 deletions x-pack/plugins/security_solution/cypress/e2e/users/inspect.cy.ts

This file was deleted.

Expand Up @@ -7,4 +7,8 @@

export const ALL_HOSTS_TABLE = '[data-test-subj="table-allHosts-loading-false"]';

export const ALL_HOSTS_TAB = '[data-test-subj="navigation-allHosts"]';

export const HOSTS_NAMES = '[data-test-subj="cellActions-renderContent-host.name"] a.euiLink';

export const UNIQUE_IPS_VISUALIZATIONS = '[data-test-subj="stat-uniqueIps"]';
Expand Up @@ -12,6 +12,8 @@ export const LOADING_SPINNER = '[data-test-subj="loading-spinner"]';
export const HOST_BY_RISK_TABLE_CELL =
'[data-test-subj="table-hostRisk-loading-false"] .euiTableCellContent';

export const HOST_BY_RISK_TABLE = '[data-test-subj="table-hostRisk-loading-false"]';

export const HOST_BY_RISK_TABLE_FILTER = '[data-test-subj="risk-filter-button"]';

export const HOST_BY_RISK_TABLE_FILTER_CRITICAL = '[data-test-subj="risk-filter-item-Critical"]';
Expand Down
Expand Up @@ -8,3 +8,5 @@
export const PROCESS_NAME_FIELD = '[data-test-subj="cellActions-renderContent-process.name"]';

export const UNCOMMON_PROCESSES_TABLE = '[data-test-subj="table-uncommonProcesses-loading-false"]';

export const HOSTS_VISUALIZATION = '[data-test-subj="stat-hosts"]';

0 comments on commit 2dea7d2

Please sign in to comment.