-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SecuritySolution] Cases by status (#130670)
* init cases by status * [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix' * cases by status * tickLabel * [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix' * unit tests * unit tests * rm unused dependency * disable dashboard * dependency * enable dashboard * styling * styling * unit tests * styling * unit tests * disable dashboard * fix types * fix types * unit tests * unit test * unit tests * unit tests * unit tests * unit tests * unit tests * update i18n * remove cases api hack Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
- Loading branch information
1 parent
f5f0356
commit 56d0112
Showing
12 changed files
with
664 additions
and
45 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
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
92 changes: 92 additions & 0 deletions
92
...on/public/overview/components/detection_response/cases_by_status/cases_by_status.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,92 @@ | ||
/* | ||
* 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, screen } from '@testing-library/react'; | ||
import React from 'react'; | ||
import { BarChartComponentProps } from '../../../../common/components/charts/barchart'; | ||
import { useQueryToggle } from '../../../../common/containers/query_toggle'; | ||
import { TestProviders } from '../../../../common/mock'; | ||
import { CasesByStatus } from './cases_by_status'; | ||
jest.mock('../../../../common/components/link_to'); | ||
jest.mock('../../../../common/containers/query_toggle'); | ||
jest.mock('./use_cases_by_status', () => ({ | ||
useCasesByStatus: jest.fn().mockReturnValue({ | ||
closed: 1, | ||
inProgress: 2, | ||
isLoading: false, | ||
open: 3, | ||
totalCounts: 6, | ||
updatedAt: new Date('2022-04-08T12:00:00.000Z').valueOf(), | ||
}), | ||
})); | ||
jest.mock('../../../../common/lib/kibana', () => { | ||
const actual = jest.requireActual('../../../../common/lib/kibana'); | ||
return { | ||
...actual, | ||
useNavigation: jest.fn().mockReturnValue({ | ||
getAppUrl: jest.fn(), | ||
navigateTo: jest.fn(), | ||
}), | ||
}; | ||
}); | ||
jest.mock('../../../../common/components/charts/barchart', () => ({ | ||
BarChart: jest.fn((props: BarChartComponentProps) => <div data-test-subj="barChart" />), | ||
})); | ||
|
||
const mockSetToggle = jest.fn(); | ||
(useQueryToggle as jest.Mock).mockReturnValue({ | ||
toggleStatus: true, | ||
setToggleStatus: mockSetToggle, | ||
}); | ||
|
||
describe('CasesByStatus', () => { | ||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
test('renders title', () => { | ||
render( | ||
<TestProviders> | ||
<CasesByStatus /> | ||
</TestProviders> | ||
); | ||
expect(screen.getByTestId('header-section-title')).toHaveTextContent('Cases'); | ||
}); | ||
|
||
test('renders toggleQuery', () => { | ||
render( | ||
<TestProviders> | ||
<CasesByStatus /> | ||
</TestProviders> | ||
); | ||
expect(screen.getByTestId('query-toggle-header')).toBeInTheDocument(); | ||
}); | ||
|
||
test('renders BarChart', () => { | ||
render( | ||
<TestProviders> | ||
<CasesByStatus /> | ||
</TestProviders> | ||
); | ||
expect(screen.getByTestId('chart-wrapper')).toBeInTheDocument(); | ||
expect(screen.queryByTestId('bar-chart-mask')).not.toBeInTheDocument(); | ||
}); | ||
|
||
test('collapses content', () => { | ||
(useQueryToggle as jest.Mock).mockReturnValueOnce({ | ||
toggleStatus: false, | ||
setToggleStatus: mockSetToggle, | ||
}); | ||
render( | ||
<TestProviders> | ||
<CasesByStatus /> | ||
</TestProviders> | ||
); | ||
|
||
expect(screen.queryByTestId('chart-wrapper')).not.toBeInTheDocument(); | ||
}); | ||
}); |
Oops, something went wrong.