-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Security Solution] add session view component to expandable flyout (#…
- Loading branch information
1 parent
dbb8e2e
commit ec6bc2d
Showing
11 changed files
with
243 additions
and
9 deletions.
There are no files selected for viewing
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
45 changes: 45 additions & 0 deletions
45
...ss/e2e/detection_alerts/expandable_flyout/alert_details_left_panel_session_view_tab.cy.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,45 @@ | ||
/* | ||
* 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 { DOCUMENT_DETAILS_FLYOUT_VISUALIZE_TAB_SESSION_VIEW_NO_DATA } from '../../../screens/document_expandable_flyout'; | ||
import { | ||
expandFirstAlertExpandableFlyout, | ||
expandDocumentDetailsExpandableFlyoutLeftSection, | ||
} from '../../../tasks/document_expandable_flyout'; | ||
import { cleanKibana } from '../../../tasks/common'; | ||
import { login, visit } from '../../../tasks/login'; | ||
import { createRule } from '../../../tasks/api_calls/rules'; | ||
import { getNewRule } from '../../../objects/rule'; | ||
import { ALERTS_URL } from '../../../urls/navigation'; | ||
import { waitForAlertsToPopulate } from '../../../tasks/create_new_rule'; | ||
|
||
// Skipping these for now as the feature is protected behind a feature flag set to false by default | ||
// To run the tests locally, add 'securityFlyoutEnabled' in the Cypress config.ts here https://github.com/elastic/kibana/blob/main/x-pack/test/security_solution_cypress/config.ts#L50 | ||
describe.skip( | ||
'Alert details expandable flyout left panel session view', | ||
{ testIsolation: false }, | ||
() => { | ||
before(() => { | ||
cleanKibana(); | ||
login(); | ||
createRule(getNewRule()); | ||
visit(ALERTS_URL); | ||
waitForAlertsToPopulate(); | ||
expandFirstAlertExpandableFlyout(); | ||
expandDocumentDetailsExpandableFlyoutLeftSection(); | ||
}); | ||
|
||
it('should display session view no data message', () => { | ||
cy.get(DOCUMENT_DETAILS_FLYOUT_VISUALIZE_TAB_SESSION_VIEW_NO_DATA) | ||
.should('be.visible') | ||
.and('contain.text', 'No data to render') | ||
.and('contain.text', 'No process events found for this query'); | ||
}); | ||
|
||
it('should display session view component', () => {}); | ||
} | ||
); |
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
File renamed without changes.
44 changes: 44 additions & 0 deletions
44
x-pack/plugins/security_solution/public/flyout/left/components/session_view.stories.tsx
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,44 @@ | ||
/* | ||
* 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 React from 'react'; | ||
import type { Story } from '@storybook/react'; | ||
import { SessionView } from './session_view'; | ||
import type { LeftPanelContext } from '../context'; | ||
import { LeftFlyoutContext } from '../context'; | ||
|
||
export default { | ||
component: SessionView, | ||
title: 'Flyout/SessionView', | ||
}; | ||
|
||
// TODO to get this working, we need to spent some time getting all the foundation items for storybook | ||
// (ReduxStoreProvider, CellActionsProvider...) similarly to how it was done for the TestProvidersComponent | ||
// see ticket https://github.com/elastic/security-team/issues/6223 | ||
// export const Default: Story<void> = () => { | ||
// const contextValue = { | ||
// getFieldsData: () => {}, | ||
// } as unknown as LeftPanelContext; | ||
// | ||
// return ( | ||
// <LeftFlyoutContext.Provider value={contextValue}> | ||
// <SessionView /> | ||
// </LeftFlyoutContext.Provider> | ||
// ); | ||
// }; | ||
|
||
export const Error: Story<void> = () => { | ||
const contextValue = { | ||
getFieldsData: () => {}, | ||
} as unknown as LeftPanelContext; | ||
|
||
return ( | ||
<LeftFlyoutContext.Provider value={contextValue}> | ||
<SessionView /> | ||
</LeftFlyoutContext.Provider> | ||
); | ||
}; |
63 changes: 63 additions & 0 deletions
63
x-pack/plugins/security_solution/public/flyout/left/components/session_view.test.tsx
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,63 @@ | ||
/* | ||
* 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 React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import '@testing-library/jest-dom'; | ||
import type { LeftPanelContext } from '../context'; | ||
import { LeftFlyoutContext } from '../context'; | ||
import { TestProviders } from '../../../common/mock'; | ||
import { SESSION_VIEW_ERROR_TEST_ID, SESSION_VIEW_TEST_ID } from './test_ids'; | ||
import { SessionView } from './session_view'; | ||
|
||
jest.mock('../../../common/lib/kibana', () => { | ||
const originalModule = jest.requireActual('../../../common/lib/kibana'); | ||
return { | ||
...originalModule, | ||
useKibana: jest.fn().mockReturnValue({ | ||
services: { | ||
sessionView: { | ||
getSessionView: jest.fn().mockReturnValue(<div />), | ||
}, | ||
}, | ||
}), | ||
}; | ||
}); | ||
|
||
describe('<SessionView />', () => { | ||
it('renders session view correctly', () => { | ||
const contextValue = { | ||
getFieldsData: () => 'id', | ||
} as unknown as LeftPanelContext; | ||
|
||
const wrapper = render( | ||
<TestProviders> | ||
<LeftFlyoutContext.Provider value={contextValue}> | ||
<SessionView /> | ||
</LeftFlyoutContext.Provider> | ||
</TestProviders> | ||
); | ||
expect(wrapper.getByTestId(SESSION_VIEW_TEST_ID)).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render error message on null eventId', () => { | ||
const contextValue = { | ||
getFieldsData: () => {}, | ||
} as unknown as LeftPanelContext; | ||
|
||
const wrapper = render( | ||
<TestProviders> | ||
<LeftFlyoutContext.Provider value={contextValue}> | ||
<SessionView /> | ||
</LeftFlyoutContext.Provider> | ||
</TestProviders> | ||
); | ||
expect(wrapper.getByTestId(SESSION_VIEW_ERROR_TEST_ID)).toBeInTheDocument(); | ||
expect(wrapper.getByText('Unable to display session view')).toBeInTheDocument(); | ||
expect(wrapper.getByText('There was an error displaying session view')).toBeInTheDocument(); | ||
}); | ||
}); |
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
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
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
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
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