-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
Changes from 34 commits
Commits
Show all changes
70 commits
Select commit
Hold shift + click to select a range
0cc92f6
add chart configs
angorayc 9c0d996
init hosts chart actions
angorayc 2a70a70
init network chart actions
angorayc 038e4c3
add to new case
angorayc 6698b73
clean up
angorayc e666488
clean up
angorayc b951e07
clean up configs
angorayc 753e0d6
rename configs
angorayc 7435652
rename histogram actions to viz actions component
angorayc 32d9c80
fix up
angorayc 0c7cbcb
add vizType
angorayc fb711a1
cypress hosts inspect
angorayc 2b1eb95
add viz actions cypress tests
angorayc 2301e5b
fix type
angorayc 4bafba5
stat_items unit test
angorayc b042b03
fix unit tests for alerts by category
angorayc 8da3ccc
fix unit tests
angorayc 3bc029f
unit tests
angorayc 11f56a8
unit tests
angorayc fc45201
rename vizType from store to inspectedVizType
angorayc b22632f
move out i18n
angorayc f5b3ff3
unit test
angorayc af5d86e
Merge branch 'main' of github.com:elastic/kibana into viz_actions
angorayc b7656f5
add index filter
angorayc 356d132
clean up configs
angorayc 6daf421
unit tests
angorayc 50481ac
Merge branch 'main' into viz_actions
kibanamachine 3eb1c78
fix typo
angorayc 271c5df
rm unused props
angorayc c172d49
Merge branch 'main' of github.com:elastic/kibana into viz_actions
angorayc 16af7f1
apply cases flyout and modal
angorayc c608513
rm unused definition
angorayc f459e16
fix typo
angorayc 13fdc19
rm vizType in reducer
angorayc ab6c4a3
onCloseInspect callback
angorayc 8688876
move viz action component out of header section
angorayc 87fae09
rm hard coded dataViewId in configs
angorayc b1e0ccc
update icon and wording
angorayc 1a852fb
fix unit tests
angorayc 95eb6b6
useRouteSpy
angorayc 0d53394
showInspectButton
angorayc 224a8ac
add aria label
angorayc 85cdc64
rm type casting
angorayc 263e511
unit test
angorayc a289c86
rm id from filters
angorayc c849a0a
use mockCasesContract
angorayc 7f9da30
add unit tests
angorayc 8eab257
Merge branch 'main' into viz_actions
kibanamachine 86ac400
styling
angorayc 98df408
update mock
angorayc 76c6033
Merge branch 'viz_actions' of github.com:angorayc/kibana into viz_act…
angorayc 1ab5b9d
rm visualization actions cypress tests
angorayc 3476ae7
clean up data-test-subj
angorayc 92f090b
disabled inspect button in matrix histogram by default
angorayc 286706b
styling
angorayc f6066bb
viz actions only available on hosts / network page
angorayc 623701a
rm kpi
angorayc d652c3f
Merge branch 'main' into viz_actions
kibanamachine 3fdc08e
unit tests
angorayc cf1ae9d
unit tests
angorayc dc46b4c
unit tests
angorayc 96ed710
unit tests
angorayc 1ed177e
kibana dependency
angorayc 08ffdf9
rename
angorayc db3ffac
Merge branch 'main' into viz_actions
kibanamachine 060484c
Merge branch 'main' into viz_actions
kibanamachine e1ae8a4
Merge branch 'main' into viz_actions
kibanamachine 5ddb9eb
add readme
angorayc 66e2490
Merge branch 'viz_actions' of github.com:angorayc/kibana into viz_act…
angorayc 6ade15f
Merge branch 'main' into viz_actions
kibanamachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
151 changes: 151 additions & 0 deletions
151
x-pack/plugins/security_solution/cypress/integration/hosts/visualization_actions.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); | ||
}); | ||
}); |
93 changes: 93 additions & 0 deletions
93
x-pack/plugins/security_solution/cypress/integration/network/visualization_actions.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', () => { | ||
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(); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
andx-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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.