-
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][Notes] - allow filtering by user (#195519)
- Loading branch information
1 parent
7c38873
commit d85b51d
Showing
21 changed files
with
309 additions
and
64 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
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
65 changes: 65 additions & 0 deletions
65
x-pack/plugins/security_solution/public/notes/components/search_row.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,65 @@ | ||
/* | ||
* 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 { fireEvent, render, screen } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import React from 'react'; | ||
import { SearchRow } from './search_row'; | ||
import { SEARCH_BAR_TEST_ID, USER_SELECT_TEST_ID } from './test_ids'; | ||
import { useSuggestUsers } from '../../common/components/user_profiles/use_suggest_users'; | ||
|
||
jest.mock('../../common/components/user_profiles/use_suggest_users'); | ||
|
||
const mockDispatch = jest.fn(); | ||
jest.mock('react-redux', () => { | ||
const original = jest.requireActual('react-redux'); | ||
|
||
return { | ||
...original, | ||
useDispatch: () => mockDispatch, | ||
}; | ||
}); | ||
|
||
describe('SearchRow', () => { | ||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
(useSuggestUsers as jest.Mock).mockReturnValue({ | ||
isLoading: false, | ||
data: [{ user: { username: 'test' } }, { user: { username: 'elastic' } }], | ||
}); | ||
}); | ||
|
||
it('should render the component', () => { | ||
const { getByTestId } = render(<SearchRow />); | ||
|
||
expect(getByTestId(SEARCH_BAR_TEST_ID)).toBeInTheDocument(); | ||
expect(getByTestId(USER_SELECT_TEST_ID)).toBeInTheDocument(); | ||
}); | ||
|
||
it('should call the correct action when entering a value in the search bar', async () => { | ||
const { getByTestId } = render(<SearchRow />); | ||
|
||
const searchBox = getByTestId(SEARCH_BAR_TEST_ID); | ||
|
||
await userEvent.type(searchBox, 'test'); | ||
await userEvent.keyboard('{enter}'); | ||
|
||
expect(mockDispatch).toHaveBeenCalled(); | ||
}); | ||
|
||
it('should call the correct action when select a user', async () => { | ||
const { getByTestId } = render(<SearchRow />); | ||
|
||
const userSelect = getByTestId('comboBoxSearchInput'); | ||
userSelect.focus(); | ||
|
||
const option = await screen.findByText('test'); | ||
fireEvent.click(option); | ||
|
||
expect(mockDispatch).toHaveBeenCalled(); | ||
}); | ||
}); |
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
Oops, something went wrong.