forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SecuritySolution] Fix minimize amd maximize panel actions (elastic#1…
…56518) ## Summary Issues: elastic#155857 | elastic#156253 This PR fixed minimize amd maximize panel actions in Security Dashboard view. https://user-images.githubusercontent.com/6295984/235910244-1cca8dda-cd4c-40b7-977a-69fa00021f81.mov ### Checklist Delete any items that are not applicable to this PR. - [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 --------- Co-authored-by: Pablo Machado <[email protected]> (cherry picked from commit c278f4e)
- Loading branch information
Showing
4 changed files
with
157 additions
and
35 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
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
107 changes: 107 additions & 0 deletions
107
x-pack/plugins/security_solution/public/dashboards/pages/details/index.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,107 @@ | ||
/* | ||
* 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 { render } from '@testing-library/react'; | ||
import React from 'react'; | ||
import { Router } from 'react-router-dom'; | ||
import { DashboardView } from '.'; | ||
import { useCapabilities } from '../../../common/lib/kibana'; | ||
import { TestProviders } from '../../../common/mock'; | ||
|
||
jest.mock('react-router-dom', () => { | ||
const actual = jest.requireActual('react-router-dom'); | ||
return { | ||
...actual, | ||
useParams: jest.fn().mockReturnValue({ detailName: 'mockSavedObjectId' }), | ||
}; | ||
}); | ||
|
||
jest.mock('../../../common/lib/kibana', () => { | ||
const actual = jest.requireActual('../../../common/lib/kibana'); | ||
return { | ||
...actual, | ||
useCapabilities: jest.fn().mockReturnValue({ show: true, showWriteControls: true }), | ||
}; | ||
}); | ||
|
||
jest.mock('../../../common/components/dashboards/dashboard_renderer', () => ({ | ||
DashboardRenderer: jest | ||
.fn() | ||
.mockImplementation((props) => ( | ||
<div data-test-subj={`dashboard-view-${props.savedObjectId}`} /> | ||
)), | ||
})); | ||
|
||
type Action = 'PUSH' | 'POP' | 'REPLACE'; | ||
const pop: Action = 'POP'; | ||
const location = { | ||
pathname: '/network', | ||
search: '', | ||
state: '', | ||
hash: '', | ||
}; | ||
const mockHistory = { | ||
length: 2, | ||
location, | ||
action: pop, | ||
push: jest.fn(), | ||
replace: jest.fn(), | ||
go: jest.fn(), | ||
goBack: jest.fn(), | ||
goForward: jest.fn(), | ||
block: jest.fn(), | ||
createHref: jest.fn(), | ||
listen: jest.fn(), | ||
}; | ||
|
||
describe('DashboardView', () => { | ||
beforeEach(() => { | ||
(useCapabilities as unknown as jest.Mock).mockReturnValue({ | ||
show: true, | ||
showWriteControls: true, | ||
}); | ||
}); | ||
test('render when no error state', () => { | ||
const { queryByTestId } = render( | ||
<Router history={mockHistory}> | ||
<DashboardView /> | ||
</Router>, | ||
{ wrapper: TestProviders } | ||
); | ||
|
||
expect(queryByTestId(`dashboard-view-mockSavedObjectId`)).toBeInTheDocument(); | ||
}); | ||
|
||
test('render a prompt when error state exists', () => { | ||
(useCapabilities as unknown as jest.Mock).mockReturnValue({ | ||
show: false, | ||
showWriteControls: true, | ||
}); | ||
const { queryByTestId } = render( | ||
<Router history={mockHistory}> | ||
<DashboardView /> | ||
</Router>, | ||
{ wrapper: TestProviders } | ||
); | ||
|
||
expect(queryByTestId(`dashboard-view-mockSavedObjectId`)).not.toBeInTheDocument(); | ||
expect(queryByTestId(`dashboard-view-error-prompt-wrapper`)).toBeInTheDocument(); | ||
}); | ||
|
||
test('render dashboard view with height', () => { | ||
const { queryByTestId } = render( | ||
<Router history={mockHistory}> | ||
<DashboardView /> | ||
</Router>, | ||
{ wrapper: TestProviders } | ||
); | ||
|
||
expect(queryByTestId(`dashboard-view-wrapper`)).toHaveStyle({ | ||
'min-height': `calc(100vh - 140px)`, | ||
}); | ||
}); | ||
}); |
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