@@ -16,6 +16,7 @@ import {
1616} from '../mocks' ;
1717import { act } from 'react-dom/test-utils' ;
1818import { ReactExpressionRendererType } from '../../../../../../../src/plugins/expressions/public' ;
19+ import { esFilters , IFieldType , IIndexPattern } from '../../../../../../../src/plugins/data/public' ;
1920import { SuggestionPanel , SuggestionPanelProps } from './suggestion_panel' ;
2021import { getSuggestions , Suggestion } from './suggestion_helpers' ;
2122import { EuiIcon , EuiPanel , EuiToolTip } from '@elastic/eui' ;
@@ -243,14 +244,25 @@ describe('suggestion_panel', () => {
243244 ( mockVisualization . toPreviewExpression as jest . Mock ) . mockReturnValueOnce ( 'test | expression' ) ;
244245 mockDatasource . toExpression . mockReturnValue ( 'datasource_expression' ) ;
245246
246- mount ( < SuggestionPanel { ...defaultProps } /> ) ;
247+ const indexPattern = ( { id : 'index1' } as unknown ) as IIndexPattern ;
248+ const field = ( { name : 'myfield' } as unknown ) as IFieldType ;
249+
250+ mount (
251+ < SuggestionPanel
252+ { ...defaultProps }
253+ frame = { {
254+ ...createMockFramePublicAPI ( ) ,
255+ filters : [ esFilters . buildExistsFilter ( field , indexPattern ) ] ,
256+ } }
257+ />
258+ ) ;
247259
248260 expect ( expressionRendererMock ) . toHaveBeenCalledTimes ( 1 ) ;
249261 const passedExpression = ( expressionRendererMock as jest . Mock ) . mock . calls [ 0 ] [ 0 ] . expression ;
250262
251263 expect ( passedExpression ) . toMatchInlineSnapshot ( `
252264 "kibana
253- | kibana_context timeRange=\\"{\\\\\\"from\\\\\\":\\\\\\"now-7d\\\\\\",\\\\\\"to\\\\\\":\\\\\\"now\\\\\\"}\\" query=\\"{\\\\\\"query\\\\\\":\\\\\\"\\\\\\",\\\\\\"language\\\\\\":\\\\\\"lucene\\\\\\"}\\" filters=\\"[]\\"
265+ | kibana_context timeRange=\\"{\\\\\\"from\\\\\\":\\\\\\"now-7d\\\\\\",\\\\\\"to\\\\\\":\\\\\\"now\\\\\\"}\\" query=\\"{\\\\\\"query\\\\\\":\\\\\\"\\\\\\",\\\\\\"language\\\\\\":\\\\\\"lucene\\\\\\"}\\" filters=\\"[{\\\\\\"meta\\\\\\":{\\\\\\"index\\\\\\":\\\\\\"index1\\\\\\"},\\\\\\"exists\\\\\\":{\\\\\\"field\\\\\\":\\\\\\"myfield\\\\\\"}} ]\\"
254266 | lens_merge_tables layerIds=\\"first\\" tables={datasource_expression}
255267 | test
256268 | expression"
0 commit comments