Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Security Solution] Add visualization actions #126507

Merged
merged 70 commits into from
Mar 15, 2022
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
0cc92f6
add chart configs
angorayc Feb 28, 2022
9c0d996
init hosts chart actions
angorayc Feb 26, 2022
2a70a70
init network chart actions
angorayc Feb 26, 2022
038e4c3
add to new case
angorayc Feb 27, 2022
6698b73
clean up
angorayc Feb 28, 2022
e666488
clean up
angorayc Feb 28, 2022
b951e07
clean up configs
angorayc Feb 28, 2022
753e0d6
rename configs
angorayc Mar 1, 2022
7435652
rename histogram actions to viz actions component
angorayc Mar 1, 2022
32d9c80
fix up
angorayc Mar 1, 2022
0c7cbcb
add vizType
angorayc Mar 1, 2022
fb711a1
cypress hosts inspect
angorayc Mar 2, 2022
2b1eb95
add viz actions cypress tests
angorayc Mar 2, 2022
2301e5b
fix type
angorayc Mar 2, 2022
4bafba5
stat_items unit test
angorayc Mar 2, 2022
b042b03
fix unit tests for alerts by category
angorayc Mar 3, 2022
8da3ccc
fix unit tests
angorayc Mar 3, 2022
3bc029f
unit tests
angorayc Mar 3, 2022
11f56a8
unit tests
angorayc Mar 3, 2022
fc45201
rename vizType from store to inspectedVizType
angorayc Mar 3, 2022
b22632f
move out i18n
angorayc Mar 3, 2022
f5b3ff3
unit test
angorayc Mar 4, 2022
af5d86e
Merge branch 'main' of github.com:elastic/kibana into viz_actions
angorayc Mar 4, 2022
b7656f5
add index filter
angorayc Mar 4, 2022
356d132
clean up configs
angorayc Mar 4, 2022
6daf421
unit tests
angorayc Mar 4, 2022
50481ac
Merge branch 'main' into viz_actions
kibanamachine Mar 7, 2022
3eb1c78
fix typo
angorayc Mar 8, 2022
271c5df
rm unused props
angorayc Mar 8, 2022
c172d49
Merge branch 'main' of github.com:elastic/kibana into viz_actions
angorayc Mar 8, 2022
16af7f1
apply cases flyout and modal
angorayc Mar 8, 2022
c608513
rm unused definition
angorayc Mar 8, 2022
f459e16
fix typo
angorayc Mar 8, 2022
13fdc19
rm vizType in reducer
angorayc Mar 8, 2022
ab6c4a3
onCloseInspect callback
angorayc Mar 8, 2022
8688876
move viz action component out of header section
angorayc Mar 8, 2022
87fae09
rm hard coded dataViewId in configs
angorayc Mar 8, 2022
b1e0ccc
update icon and wording
angorayc Mar 8, 2022
1a852fb
fix unit tests
angorayc Mar 8, 2022
95eb6b6
useRouteSpy
angorayc Mar 8, 2022
0d53394
showInspectButton
angorayc Mar 8, 2022
224a8ac
add aria label
angorayc Mar 8, 2022
85cdc64
rm type casting
angorayc Mar 8, 2022
263e511
unit test
angorayc Mar 8, 2022
a289c86
rm id from filters
angorayc Mar 9, 2022
c849a0a
use mockCasesContract
angorayc Mar 9, 2022
7f9da30
add unit tests
angorayc Mar 9, 2022
8eab257
Merge branch 'main' into viz_actions
kibanamachine Mar 9, 2022
86ac400
styling
angorayc Mar 9, 2022
98df408
update mock
angorayc Mar 9, 2022
76c6033
Merge branch 'viz_actions' of github.com:angorayc/kibana into viz_act…
angorayc Mar 9, 2022
1ab5b9d
rm visualization actions cypress tests
angorayc Mar 10, 2022
3476ae7
clean up data-test-subj
angorayc Mar 10, 2022
92f090b
disabled inspect button in matrix histogram by default
angorayc Mar 10, 2022
286706b
styling
angorayc Mar 10, 2022
f6066bb
viz actions only available on hosts / network page
angorayc Mar 14, 2022
623701a
rm kpi
angorayc Mar 14, 2022
d652c3f
Merge branch 'main' into viz_actions
kibanamachine Mar 14, 2022
3fdc08e
unit tests
angorayc Mar 14, 2022
cf1ae9d
unit tests
angorayc Mar 14, 2022
dc46b4c
unit tests
angorayc Mar 14, 2022
96ed710
unit tests
angorayc Mar 15, 2022
1ed177e
kibana dependency
angorayc Mar 15, 2022
08ffdf9
rename
angorayc Mar 15, 2022
db3ffac
Merge branch 'main' into viz_actions
kibanamachine Mar 15, 2022
060484c
Merge branch 'main' into viz_actions
kibanamachine Mar 15, 2022
e1ae8a4
Merge branch 'main' into viz_actions
kibanamachine Mar 15, 2022
5ddb9eb
add readme
angorayc Mar 15, 2022
66e2490
Merge branch 'viz_actions' of github.com:angorayc/kibana into viz_act…
angorayc Mar 15, 2022
6ade15f
Merge branch 'main' into viz_actions
kibanamachine Mar 15, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
/*
* 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_MODAL } from '../../screens/inspect';
import { cleanKibana } from '../../tasks/common';

import { closesModal } from '../../tasks/inspect';
import { loginAndWaitForHostDetailsPage, loginAndWaitForPage } from '../../tasks/login';

import { HOSTS_URL } from '../../urls/navigation';
import {
clickVizActionsAddToExistingCase,
clickVizActionsAddToNewCase,
clickVizActionsButton,
clickVizActionsInspect,
clickVizActionsOpenInLens,
clickVizActionsSave,
closeAllCasesModal,
closeCreateCaseFlyout,
closeSaveObjectModal,
vizActionsMenuShouldBeClosed,
} from '../../tasks/visualization_actions';
import {
CREATE_CASE_FLYOUT,
SAVE_LENS_MODAL,
SELECT_CASE_MODAL,
VIZ_ACTIONS_HOSTS_BUTTONS_IN_SECURITY,
VIZ_ACTIONS_HOSTS_DETAILS_BUTTONS_IN_SECURITY,
} from '../../screens/visualization_actions';

describe('Visualization actions', () => {
before(() => {
cleanKibana();
});
context('Hosts', () => {
before(() => {
loginAndWaitForPage(HOSTS_URL);
});

VIZ_ACTIONS_HOSTS_BUTTONS_IN_SECURITY.forEach((button) => {
it(`inspects the ${button.title}`, () => {
clickVizActionsButton(button.id, button.tabId);
clickVizActionsInspect();
vizActionsMenuShouldBeClosed();
cy.get(INSPECT_MODAL).should('be.visible');
closesModal();
});

it(`save the ${button.title}`, () => {
clickVizActionsButton(button.id, button.tabId);
clickVizActionsSave();
vizActionsMenuShouldBeClosed();
cy.get(SAVE_LENS_MODAL).should('be.visible');

closeSaveObjectModal();
});

it(`open the ${button.title} chart in Lens`, () => {
clickVizActionsButton(button.id, button.tabId);

cy.window().then((win) => {
cy.stub(win, 'open').as('openInLens');
});
clickVizActionsOpenInLens();
vizActionsMenuShouldBeClosed();

cy.get('@openInLens').should('be.called');
});

it(`add the ${button.title} chart to a new case`, () => {
clickVizActionsButton(button.id, button.tabId);

clickVizActionsAddToNewCase();
vizActionsMenuShouldBeClosed();
cy.get(CREATE_CASE_FLYOUT).should('exist');
closeCreateCaseFlyout();
});

it(`add the ${button.title} chart to an existing case`, () => {
clickVizActionsButton(button.id, button.tabId);

clickVizActionsAddToExistingCase();
vizActionsMenuShouldBeClosed();
cy.get(SELECT_CASE_MODAL).should('exist');
closeAllCasesModal();
});
});
});

context('Host details', () => {
before(() => {
loginAndWaitForHostDetailsPage();
});

VIZ_ACTIONS_HOSTS_DETAILS_BUTTONS_IN_SECURITY.forEach((button) => {
it(`inspects the ${button.title}`, () => {
clickVizActionsButton(button.id, button.tabId);
clickVizActionsInspect();
vizActionsMenuShouldBeClosed();
cy.get(INSPECT_MODAL).should('be.visible');
closesModal();
});

it(`save the ${button.title}`, () => {
clickVizActionsButton(button.id, button.tabId);
clickVizActionsSave();
vizActionsMenuShouldBeClosed();
cy.get(SAVE_LENS_MODAL).should('be.visible');

closeSaveObjectModal();
});

it(`open the ${button.title} chart in Lens`, () => {
clickVizActionsButton(button.id, button.tabId);

cy.window().then((win) => {
cy.stub(win, 'open').as('openInLens');
});
clickVizActionsOpenInLens();
vizActionsMenuShouldBeClosed();

cy.get('@openInLens').should('be.called');
});

it(`add the ${button.title} chart to a new case`, () => {
clickVizActionsButton(button.id, button.tabId);

clickVizActionsAddToNewCase();
vizActionsMenuShouldBeClosed();
cy.get(CREATE_CASE_FLYOUT).should('exist');
closeCreateCaseFlyout();
});

it(`add the ${button.title} chart to a new case`, () => {
if (button.tabId) {
cy.get(button.tabId).click();
}
cy.get(button.id).click({ force: true });

clickVizActionsAddToExistingCase();
vizActionsMenuShouldBeClosed();
cy.get(SELECT_CASE_MODAL).should('exist');
closeAllCasesModal();
});
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
* 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_MODAL } from '../../screens/inspect';
import {
CREATE_CASE_FLYOUT,
SAVE_LENS_MODAL,
SELECT_CASE_MODAL,
VIZ_ACTIONS_BUTTONS_IN_SECURITY,
} from '../../screens/visualization_actions';
import { cleanKibana } from '../../tasks/common';

import { closesModal } from '../../tasks/inspect';
import { loginAndWaitForPage } from '../../tasks/login';
import {
clickVizActionsAddToExistingCase,
clickVizActionsAddToNewCase,
clickVizActionsButton,
clickVizActionsInspect,
clickVizActionsOpenInLens,
clickVizActionsSave,
closeAllCasesModal,
closeCreateCaseFlyout,
closeSaveObjectModal,
vizActionsMenuShouldBeClosed,
} from '../../tasks/visualization_actions';

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

describe('Visualization actions', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pr seems to have 0 new jest tests and only cypress tests added. Cypress tests are much slower, and so should be only used for integration level tests, not inspecting the properties of a rendered component like these tests. Testing that a handler is called after a click etc can and should be done in component unit tests

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that make sense, adding the Cypress tests for these cases because we have been testing inspect button:
x-pack/plugins/security_solution/cypress/integration/network/inspect.spec.ts and x-pack/plugins/security_solution/cypress/integration/hosts/inspect.spec.ts.

I removed some of the cases from there and think adding visualization actions' test could explain the removed scenarios.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to elaborate, it's awesome you added tests, it's just until the cypress tests are run for every change in every plugin that securitySolution makes use of, they'll get inadvertently broken all the time, and block security solution prs until skipped or fixed. The plugins we make use of would likely be less against running cypress tests all the time if they ran much faster, by tweaking the config, running them in parallel, etc, but mostly just by running less of them by testing all logic possible in the faster/already run in parallel jest tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, I'll make sure these are covered by unit tests, and talk to @MadameSheema about this, if everything is fine, I'll remove the new cypress in here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @kqualters-elastic, we should use cypress for those scenarios we cannot cover with unit or API tests and use it more for more user flow/E2E/integration testing.

Happy to remove scenarios that are automated in a different layer.

context('inspect', () => {
before(() => {
cleanKibana();
loginAndWaitForPage(NETWORK_URL);
});

VIZ_ACTIONS_BUTTONS_IN_SECURITY.forEach((button) => {
it(`inspects the ${button.title}`, () => {
clickVizActionsButton(button.id, button.tabId);
clickVizActionsInspect();
vizActionsMenuShouldBeClosed();
cy.get(INSPECT_MODAL).should('be.visible');
closesModal();
});

it(`save the ${button.title}`, () => {
clickVizActionsButton(button.id, button.tabId);
clickVizActionsSave();
vizActionsMenuShouldBeClosed();
cy.get(SAVE_LENS_MODAL).should('be.visible');

closeSaveObjectModal();
});

it(`open the ${button.title} chart in Lens`, () => {
clickVizActionsButton(button.id, button.tabId);

cy.window().then((win) => {
cy.stub(win, 'open').as('openInLens');
});
clickVizActionsOpenInLens();
vizActionsMenuShouldBeClosed();

cy.get('@openInLens').should('be.called');
});

it(`add the ${button.title} chart to a new case`, () => {
clickVizActionsButton(button.id, button.tabId);

clickVizActionsAddToNewCase();
vizActionsMenuShouldBeClosed();
cy.get(CREATE_CASE_FLYOUT).should('exist');
closeCreateCaseFlyout();
});

it(`add the ${button.title} chart to a new case`, () => {
if (button.tabId) {
cy.get(button.tabId).click();
}
cy.get(button.id).click({ force: true });

clickVizActionsAddToExistingCase();
vizActionsMenuShouldBeClosed();
cy.get(SELECT_CASE_MODAL).should('exist');
closeAllCasesModal();
});
});
});
});
28 changes: 0 additions & 28 deletions x-pack/plugins/security_solution/cypress/screens/inspect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@ export interface InspectButtonMetadata {
}

export const INSPECT_HOSTS_BUTTONS_IN_SECURITY: InspectButtonMetadata[] = [
{
id: '[data-test-subj="stat-hosts"]',
title: 'Hosts Stat',
},
{
id: '[data-test-subj="stat-uniqueIps"]',
title: 'Unique IPs Stat',
},
{
id: '[data-test-subj="table-allHosts-loading-false"]',
title: 'All Hosts Table',
Expand All @@ -48,26 +40,6 @@ export const INSPECT_HOSTS_BUTTONS_IN_SECURITY: InspectButtonMetadata[] = [
];

export const INSPECT_NETWORK_BUTTONS_IN_SECURITY: 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',
Expand Down
Loading