import React from 'react' ; import { render , waitFor } from '@testing-library/react' ; import { PIVOT_SUPPORTED_AGGS } from '../../../../../../common/types/pivot_aggs' ; import { PivotAggsConfig , PivotGroupByConfig , PIVOT_SUPPORTED_GROUP_BY_AGGS , } from '../../../../common' ; import { SearchItems } from '../../../../hooks/use_search_items' ; import { StepDefineExposedState } from './common' ; import { StepDefineSummary } from './step_define_summary' ; jest . mock ( '../../../../../shared_imports' ) ; jest . mock ( '../../../../../app/app_dependencies' ) ; import { MlSharedContext } from '../../../../../app/__mocks__/shared_context' ; import { getMlSharedImports } from '../../../../../shared_imports' ; describe ( 'Transform: <DefinePivotSummary />' , ( ) => { test ( 'Minimal initialization' , async ( ) => { const mlSharedImports = await getMlSharedImports ( ) ; const searchItems = { indexPattern : { title : 'the-index-pattern-title' , fields : [ ] as any [ ] , } as SearchItems [ 'indexPattern' ] , } ; const groupBy = { agg : PIVOT_SUPPORTED_GROUP_BY_AGGS . TERMS , field : 'the-group-by-field' , aggName : 'the-group-by-agg-name' , dropDownName : 'the-group-by-drop-down-name' , } ; const agg = { agg : PIVOT_SUPPORTED_AGGS . AVG , field : 'the-agg-field' , aggName : 'the-group-by-agg-name' , dropDownName : 'the-group-by-drop-down-name' , } ; const formState = { aggList : { 'the-agg-name' : agg } , groupByList : { 'the-group-by-name' : groupBy } , isAdvancedPivotEditorEnabled : false , isAdvancedSourceEditorEnabled : false , sourceConfigUpdated : false , searchLanguage : 'kuery' , searchString : 'the-query' , searchQuery : 'the-search-query' , valid : true , validationStatus : { isValid : true , } , transformFunction : 'pivot' , previewRequest : { pivot : { aggregations : { 'the-agg-name' : agg , } , group_by : { 'the-group-by-name' : groupBy , } , } , } , } ; const { queryByText } = render ( < MlSharedContext . Provider value = { mlSharedImports } > < StepDefineSummary formState = { formState } searchItems = { searchItems as SearchItems } / > < /MlSharedContext.Provider>); await waitFor ( ( ) => { expect ( queryByText ( 'Group by' ) ) . toBeInTheDocument ( ) ; expect ( queryByText ( 'Aggregations' ) ) . toBeInTheDocument ( ) ; } ) ; } ) ; } ) ;