import { act } from 'react-dom/test-utils' ; import { registerTestBed , TestBed , AsyncTestBedConfig } from '@kbn/test/jest' ; import { EsDeprecations } from '../../../public/application/components/es_deprecations' ; import { WithAppDependencies } from '../helpers' ; const testBedConfig = { memoryRouter : { initialEntries : [ '/es_deprecations' ] , componentRoutePath : '/es_deprecations' , } , doMountAsync : true , } ; export type ElasticsearchTestBed = TestBed & { actions : ReturnType < typeof createActions > ; } ; const createActions = ( testBed ) => { const { component , find } = testBed ; /**
     * User Actions
     */ const table = { clickRefreshButton : async ( ) => { await act ( async ( ) => { find ( 'refreshButton' ) . simulate ( 'click' ) ; } ) ; component . update ( ) ; } , clickDeprecationRowAt : async ( deprecationType , index ) => { await act ( async ( ) => { find ( `deprecation-${ deprecationType }` ) . at ( index ) . simulate ( 'click' ) ; } ) ; component . update ( ) ; } , } ; const searchBar = { clickTypeFilterDropdownAt : async ( index ) => { await act ( async ( ) => { find ( 'searchBarContainer' ) . find ( '.euiPopover' ) . find ( '.euiFilterButton' ) . at ( index ) . simulate ( 'click' ) ; } ) ; component . update ( ) ; } , setSearchInputValue : async ( searchValue ) => { await act ( async ( ) => { find ( 'searchBarContainer' ) . find ( 'input' ) . simulate ( 'keyup' , { target : { value : searchValue } } ) ; } ) ; component . update ( ) ; } , clickCriticalFilterButton : async ( ) => { await act ( async ( ) => { find ( 'searchBarContainer' ) . find ( '.euiFilterButton' ) . at ( 0 ) . simulate ( 'click' ) ; } ) ; component . update ( ) ; } , } ; const pagination = { clickPaginationAt : async ( index ) => { await act ( async ( ) => { find ( `pagination-button-${ index }` ) . simulate ( 'click' ) ; } ) ; component . update ( ) ; } , clickRowsPerPageDropdown : async ( ) => { await act ( async ( ) => { find ( 'tablePaginationPopoverButton' ) . simulate ( 'click' ) ; } ) ; component . update ( ) ; } , } ; const mlDeprecationFlyout = { clickUpgradeSnapshot : async ( ) => { await act ( async ( ) => { find ( 'mlSnapshotDetails.upgradeSnapshotButton' ) . simulate ( 'click' ) ; } ) ; component . update ( ) ; } , clickDeleteSnapshot : async ( ) => { await act ( async ( ) => { find ( 'mlSnapshotDetails.deleteSnapshotButton' ) . simulate ( 'click' ) ; } ) ; component . update ( ) ; } , } ; const indexSettingsDeprecationFlyout = { clickDeleteSettingsButton : async ( ) => { await act ( async ( ) => { find ( 'deleteSettingsButton' ) . simulate ( 'click' ) ; } ) ; component . update ( ) ; } , } ; const reindexDeprecationFlyout = { clickReindexButton : async ( ) => { await act ( async ( ) => { find ( 'startReindexingButton' ) . simulate ( 'click' ) ; } ) ; component . update ( ) ; } , } ; return { table , searchBar , pagination , mlDeprecationFlyout , reindexDeprecationFlyout , indexSettingsDeprecationFlyout , } ; } ; export const setupElasticsearchPage = async ( overrides ? ) : Promise < ElasticsearchTestBed > => { const initTestBed = registerTestBed ( WithAppDependencies ( EsDeprecations , overrides ) , testBedConfig ) ; const testBed = await initTestBed ( ) ; return { ... testBed , actions : createActions ( testBed ) , } ; } ;