diff --git a/x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/inspect/inspect.spec.ts b/x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/inspect/inspect.spec.ts index 7b0b10831c4a0..e7411aba11af5 100644 --- a/x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/inspect/inspect.spec.ts +++ b/x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/inspect/inspect.spec.ts @@ -9,12 +9,15 @@ import { INSPECT_MODAL, INSPECT_NETWORK_BUTTONS_IN_SIEM, INSPECT_HOSTS_BUTTONS_IN_SIEM, - TIMELINE_SETTINGS_ICON, - TIMELINE_INSPECT_BUTTON, -} from '../../lib/inspect/selectors'; -import { DEFAULT_TIMEOUT, loginAndWaitForPage } from '../../lib/util/helpers'; -import { executeKQL, hostExistsQuery, toggleTimelineVisibility } from '../../lib/timeline/helpers'; -import { closesModal, openStatsAndTables } from '../../lib/inspect/helpers'; +} from '../../../screens/inspect'; +import { + executeTimelineKQL, + openTimeline, + openTimelineSettings, + openTimelineInspectButton, +} from '../../../tasks/timeline/main'; +import { DEFAULT_TIMEOUT, loginAndWaitForPage } from '../../../tasks/login'; +import { closesModal, openStatsAndTables } from '../../../tasks/inspect'; describe('Inspect', () => { context('Hosts stats and tables', () => { @@ -51,12 +54,12 @@ describe('Inspect', () => { context('Timeline', () => { it('inspects the timeline', () => { + const hostExistsQuery = 'host.name: *'; loginAndWaitForPage(HOSTS_PAGE); - toggleTimelineVisibility(); - executeKQL(hostExistsQuery); - cy.get(TIMELINE_SETTINGS_ICON).trigger('click', { force: true }); - cy.get(TIMELINE_INSPECT_BUTTON, { timeout: DEFAULT_TIMEOUT }).should('not.be.disabled'); - cy.get(TIMELINE_INSPECT_BUTTON).trigger('click', { force: true }); + openTimeline(); + executeTimelineKQL(hostExistsQuery); + openTimelineSettings(); + openTimelineInspectButton(); cy.get(INSPECT_MODAL, { timeout: DEFAULT_TIMEOUT }).should('be.visible'); }); }); diff --git a/x-pack/legacy/plugins/siem/cypress/screens/inspect.ts b/x-pack/legacy/plugins/siem/cypress/screens/inspect.ts new file mode 100644 index 0000000000000..8f2ff4ef401e7 --- /dev/null +++ b/x-pack/legacy/plugins/siem/cypress/screens/inspect.ts @@ -0,0 +1,87 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export const INSPECT_BUTTON_ICON = '[data-test-subj="inspect-icon-button"]'; +export const INSPECT_MODAL = '[data-test-subj="modal-inspect-euiModal"]'; + +export interface InspectButtonMetadata { + altInspectId?: string; + id: string; + title: string; + tabId?: string; +} + +export const INSPECT_HOSTS_BUTTONS_IN_SIEM: InspectButtonMetadata[] = [ + { + id: '[data-test-subj="stat-hosts"]', + title: 'Hosts Stat', + }, + { + id: '[data-test-subj="stat-authentication"]', + title: 'User Authentications Stat', + }, + { + id: '[data-test-subj="stat-uniqueIps"]', + title: 'Unique IPs Stat', + }, + { + id: '[data-test-subj="table-allHosts-loading-false"]', + title: 'All Hosts Table', + tabId: '[data-test-subj="navigation-allHosts"]', + }, + { + id: '[data-test-subj="table-authentications-loading-false"]', + title: 'Authentications Table', + tabId: '[data-test-subj="navigation-authentications"]', + }, + { + id: '[data-test-subj="table-uncommonProcesses-loading-false"]', + title: 'Uncommon processes Table', + tabId: '[data-test-subj="navigation-uncommonProcesses"]', + }, + { + altInspectId: `[data-test-subj="events-viewer-panel"] ${INSPECT_BUTTON_ICON}`, + id: '[data-test-subj="events-container-loading-false"]', + title: 'Events Table', + tabId: '[data-test-subj="navigation-events"]', + }, +]; + +export const INSPECT_NETWORK_BUTTONS_IN_SIEM: InspectButtonMetadata[] = [ + { + id: '[data-test-subj="stat-networkEvents"]', + title: 'Network events Stat', + }, + { + id: '[data-test-subj="stat-dnsQueries"]', + title: 'DNS queries Stat', + }, + { + id: '[data-test-subj="stat-uniqueFlowId"]', + title: 'Unique flow IDs Stat', + }, + { + id: '[data-test-subj="stat-tlsHandshakes"]', + title: 'TLS handshakes Stat', + }, + { + id: '[data-test-subj="stat-UniqueIps"]', + title: 'Unique private IPs Stat', + }, + { + id: '[data-test-subj="table-topNFlowSource-loading-false"]', + title: 'Source IPs Table', + }, + { + id: '[data-test-subj="table-topNFlowDestination-loading-false"]', + title: 'Destination IPs Table', + }, + { + id: '[data-test-subj="table-dns-loading-false"]', + title: 'Top DNS Domains Table', + tabId: '[data-test-subj="navigation-dns"]', + }, +]; diff --git a/x-pack/legacy/plugins/siem/cypress/screens/timeline/main.ts b/x-pack/legacy/plugins/siem/cypress/screens/timeline/main.ts index cf3267d2b650e..ca11f48932263 100644 --- a/x-pack/legacy/plugins/siem/cypress/screens/timeline/main.ts +++ b/x-pack/legacy/plugins/siem/cypress/screens/timeline/main.ts @@ -16,3 +16,7 @@ export const TIMELINE_FIELDS_BUTTON = /** The total server-side count of the events matching the timeline's search criteria */ export const SERVER_SIDE_EVENT_COUNT = '[data-test-subj="server-side-event-count"]'; + +export const TIMELINE_SETTINGS_ICON = '[data-test-subj="settings-gear"]'; + +export const TIMELINE_INSPECT_BUTTON = '[data-test-subj="inspect-empty-button"]'; diff --git a/x-pack/legacy/plugins/siem/cypress/tasks/inspect.ts b/x-pack/legacy/plugins/siem/cypress/tasks/inspect.ts new file mode 100644 index 0000000000000..26b1c0f7e4e39 --- /dev/null +++ b/x-pack/legacy/plugins/siem/cypress/tasks/inspect.ts @@ -0,0 +1,29 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { INSPECT_BUTTON_ICON, InspectButtonMetadata } from '../screens/inspect'; + +import { DEFAULT_TIMEOUT } from '../tasks/login'; + +export const closesModal = () => { + cy.get('[data-test-subj="modal-inspect-close"]', { timeout: DEFAULT_TIMEOUT }).click(); +}; + +export const openStatsAndTables = (table: InspectButtonMetadata) => { + if (table.tabId) { + cy.get(table.tabId).click({ force: true }); + } + cy.get(table.id, { timeout: DEFAULT_TIMEOUT }); + if (table.altInspectId) { + cy.get(table.altInspectId, { timeout: DEFAULT_TIMEOUT }).trigger('click', { + force: true, + }); + } else { + cy.get(`${table.id} ${INSPECT_BUTTON_ICON}`, { + timeout: DEFAULT_TIMEOUT, + }).trigger('click', { force: true }); + } +}; diff --git a/x-pack/legacy/plugins/siem/cypress/tasks/timeline/main.ts b/x-pack/legacy/plugins/siem/cypress/tasks/timeline/main.ts index 51026fef757d8..ae2a863092907 100644 --- a/x-pack/legacy/plugins/siem/cypress/tasks/timeline/main.ts +++ b/x-pack/legacy/plugins/siem/cypress/tasks/timeline/main.ts @@ -11,6 +11,8 @@ import { SEARCH_OR_FILTER_CONTAINER, TIMELINE_FIELDS_BUTTON, SERVER_SIDE_EVENT_COUNT, + TIMELINE_SETTINGS_ICON, + TIMELINE_INSPECT_BUTTON, } from '../../screens/timeline/main'; export const hostExistsQuery = 'host.name: *'; @@ -29,3 +31,16 @@ export const populateTimeline = () => { export const openTimelineFieldsBrowser = () => { cy.get(TIMELINE_FIELDS_BUTTON).click({ force: true }); }; + +export const executeTimelineKQL = (query: string) => { + cy.get(`${SEARCH_OR_FILTER_CONTAINER} input`).type(`${query} {enter}`); +}; + +export const openTimelineSettings = () => { + cy.get(TIMELINE_SETTINGS_ICON).trigger('click', { force: true }); +}; + +export const openTimelineInspectButton = () => { + cy.get(TIMELINE_INSPECT_BUTTON, { timeout: DEFAULT_TIMEOUT }).should('not.be.disabled'); + cy.get(TIMELINE_INSPECT_BUTTON).trigger('click', { force: true }); +};