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.
[Graph] EUI-ification of search bar (elastic#45351)
- Loading branch information
Showing
16 changed files
with
355 additions
and
54 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
@import './search_bar'; | ||
@import './venn_diagram/index'; | ||
@import './settings/index'; |
11 changes: 11 additions & 0 deletions
11
x-pack/legacy/plugins/graph/public/components/_search_bar.scss
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,11 @@ | ||
.gphSearchBar { | ||
padding: 0 $euiSizeS; | ||
} | ||
|
||
.gphSearchBar__datasourceButton { | ||
height: 100% !important; | ||
} | ||
|
||
.gphSearchBar__datasourceButtonTooltip { | ||
padding: 0; | ||
} |
63 changes: 63 additions & 0 deletions
63
x-pack/legacy/plugins/graph/public/components/search_bar.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,63 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { SearchBar } from './search_bar'; | ||
import { shallowWithIntl } from 'test_utils/enzyme_helpers'; | ||
import React, { ReactElement } from 'react'; | ||
import { CoreStart } from 'src/core/public'; | ||
import { IndexPatternSavedObject } from '../types'; | ||
import { act } from 'react-dom/test-utils'; | ||
import { EuiFieldText } from '@elastic/eui'; | ||
import { openSourceModal } from '../services/source_modal'; | ||
|
||
jest.mock('../services/source_modal', () => ({ openSourceModal: jest.fn() })); | ||
|
||
describe('search_bar', () => { | ||
it('should render search bar and submit queryies', () => { | ||
const querySubmit = jest.fn(); | ||
const instance = shallowWithIntl( | ||
<SearchBar | ||
isLoading={false} | ||
onIndexPatternSelected={() => {}} | ||
onQuerySubmit={querySubmit} | ||
savedObjects={{} as CoreStart['savedObjects']} | ||
uiSettings={{} as CoreStart['uiSettings']} | ||
overlays={{} as CoreStart['overlays']} | ||
currentIndexPattern={{ attributes: { title: 'Testpattern' } } as IndexPatternSavedObject} | ||
/> | ||
); | ||
act(() => { | ||
instance.find(EuiFieldText).simulate('change', { target: { value: 'testQuery' } }); | ||
}); | ||
|
||
act(() => { | ||
instance.find('form').simulate('submit', { preventDefault: () => {} }); | ||
}); | ||
|
||
expect(querySubmit).toHaveBeenCalledWith('testQuery'); | ||
}); | ||
|
||
it('should render index pattern picker', () => { | ||
const indexPatternSelected = jest.fn(); | ||
const instance = shallowWithIntl( | ||
<SearchBar | ||
isLoading={false} | ||
onIndexPatternSelected={indexPatternSelected} | ||
onQuerySubmit={() => {}} | ||
savedObjects={{} as CoreStart['savedObjects']} | ||
uiSettings={{} as CoreStart['uiSettings']} | ||
overlays={{} as CoreStart['overlays']} | ||
currentIndexPattern={{ attributes: { title: 'Testpattern' } } as IndexPatternSavedObject} | ||
/> | ||
); | ||
|
||
// pick the button component out of the tree because | ||
// it's part of a popover and thus not covered by enzyme | ||
(instance.find(EuiFieldText).prop('prepend') as ReactElement).props.children.props.onClick(); | ||
|
||
expect(openSourceModal).toHaveBeenCalled(); | ||
}); | ||
}); |
Oops, something went wrong.