[Remote clusters] Fixed skipped test for search bar (#97472)

* Fixed skipped search test

* Fixed eslint error

* Added setSearchBarValue helper to testbed and unskipped search tests in CCR

* Fixed eslint errors and added a comment to the setSearchBarValue method

* Added a mock for EuiSearchBox

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Yulia Čech 2021-05-05 13:05:35 +02:00 committed by GitHub
parent 349b7e9f8e
commit 8ce3ea0238
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 53 additions and 20 deletions

View file

@ -5,6 +5,7 @@
* 2.0.
*/
import React from 'react';
import { act } from 'react-dom/test-utils';
import { getRouter } from '../../../public/application/services';
@ -16,6 +17,19 @@ import { setupEnvironment, getRandomString, findTestSubject } from '../helpers';
import { setup } from './remote_clusters_list.helpers';
jest.mock('@elastic/eui/lib/components/search_bar/search_box', () => {
return {
EuiSearchBox: (props) => (
<input
data-test-subj={props['data-test-subj'] || 'mockSearchBox'}
onChange={(event) => {
props.onSearch(event.target.value);
}}
/>
),
};
});
describe('<RemoteClusterList />', () => {
const { server, httpRequestsMockHelpers } = setupEnvironment();
@ -64,7 +78,6 @@ describe('<RemoteClusterList />', () => {
});
describe('when there are multiple pages of remote clusters', () => {
let find;
let table;
let actions;
let component;
@ -88,7 +101,7 @@ describe('<RemoteClusterList />', () => {
httpRequestsMockHelpers.setLoadRemoteClustersResponse(remoteClusters);
await act(async () => {
({ find, table, actions, form, component } = setup());
({ table, actions, component, form } = setup());
});
component.update();
@ -103,9 +116,8 @@ describe('<RemoteClusterList />', () => {
expect(tableCellsValues.length).toBe(10);
});
// Skipped until we can figure out how to get this test to work.
test.skip('search works', () => {
form.setInputValue(find('remoteClusterSearch'), 'unique');
test('search works', () => {
form.setInputValue('remoteClusterSearch', 'unique');
const { tableCellsValues } = table.getMetaData('remoteClusterListTable');
expect(tableCellsValues.length).toBe(1);
});