-
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.
Disable selection of filter status 'All' on AddToCaseAction (#99757)
* Fix: Disable selection of filter status 'All' on AddToCaseAction * UI: Hide disabled statuses on AddToCaseAction * Refactor: Rename disabledStatuses to hiddenStatuses * Fix: Pick the first valid status for initialFilterOptions Previously it was always picking 'open', but it wouldn't work when hiddenStatuses contains "open". * Add missing test Co-authored-by: Kibana Machine <[email protected]>
- Loading branch information
1 parent
b6635b0
commit fab9605
Showing
9 changed files
with
120 additions
and
44 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
70 changes: 70 additions & 0 deletions
70
x-pack/plugins/cases/public/components/all_cases/all_cases_generic.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,70 @@ | ||
/* | ||
* 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 { mount } from 'enzyme'; | ||
import { AllCasesGeneric } from './all_cases_generic'; | ||
|
||
import { TestProviders } from '../../common/mock'; | ||
import { useGetTags } from '../../containers/use_get_tags'; | ||
import { useGetReporters } from '../../containers/use_get_reporters'; | ||
import { useGetActionLicense } from '../../containers/use_get_action_license'; | ||
import { StatusAll } from '../../containers/types'; | ||
import { CaseStatuses } from '../../../common'; | ||
import { act } from 'react-dom/test-utils'; | ||
|
||
jest.mock('../../containers/use_get_reporters'); | ||
jest.mock('../../containers/use_get_tags'); | ||
jest.mock('../../containers/use_get_action_license'); | ||
jest.mock('../../containers/api'); | ||
|
||
const createCaseNavigation = { href: '', onClick: jest.fn() }; | ||
|
||
const alertDataMock = { | ||
type: 'alert', | ||
rule: { | ||
id: 'rule-id', | ||
name: 'rule', | ||
}, | ||
index: 'index-id', | ||
alertId: 'alert-id', | ||
}; | ||
|
||
describe('AllCasesGeneric ', () => { | ||
beforeEach(() => { | ||
jest.resetAllMocks(); | ||
(useGetTags as jest.Mock).mockReturnValue({ tags: ['coke', 'pepsi'], fetchTags: jest.fn() }); | ||
(useGetReporters as jest.Mock).mockReturnValue({ | ||
reporters: ['casetester'], | ||
respReporters: [{ username: 'casetester' }], | ||
isLoading: true, | ||
isError: false, | ||
fetchReporters: jest.fn(), | ||
}); | ||
(useGetActionLicense as jest.Mock).mockReturnValue({ | ||
actionLicense: null, | ||
isLoading: false, | ||
}); | ||
}); | ||
|
||
it('renders the first available status when hiddenStatus is given', () => | ||
act(async () => { | ||
const wrapper = mount( | ||
<TestProviders> | ||
<AllCasesGeneric | ||
alertData={alertDataMock} | ||
createCaseNavigation={createCaseNavigation} | ||
hiddenStatuses={[StatusAll, CaseStatuses.open]} | ||
isSelectorView={true} | ||
userCanCrud={true} | ||
/> | ||
</TestProviders> | ||
); | ||
|
||
expect(wrapper.find(`[data-test-subj="status-badge-in-progress"]`).exists()).toBeTruthy(); | ||
})); | ||
}); |
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
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