import { FtrProviderContext } from '../ftr_provider_context' ; const ENTERPRISE_SEARCH_USER = 'enterprise_search' ; const ENTERPRISE_SEARCH_PASSWORD = 'changeme' ; import { createEngine , createMetaEngine , indexData , waitForIndexedDocs , destroyEngine , IEngine , } from './app_search_client' ; export interface IUser { user : string ; password : string ; } export type { IEngine } ; export class AppSearchService { getEnterpriseSearchUser ( ) { return { user : ENTERPRISE_SEARCH_USER , password : ENTERPRISE_SEARCH_PASSWORD , } ; } createEngine ( ) { const engineName = `test-engine-${ new Date ( ) . getTime ( ) }` ; return createEngine ( engineName ) ; } async createEngineWithDocs ( ) { const engine = await this . createEngine ( ) ; const docs = [ { id : 1 , name : 'doc1' } , { id : 2 , name : 'doc2' } , { id : 3 , name : 'doc2' } , ] ; await indexData ( engine . name , docs ) ; await waitForIndexedDocs ( engine . name ) ; return engine ; } createMetaEngine ( sourceEngines ) { const engineName = `test-meta-engine-${ new Date ( ) . getTime ( ) }` ; return createMetaEngine ( engineName , sourceEngines ) ; } destroyEngine ( engineName ) { return destroyEngine ( engineName ) ; } } export async function AppSearchServiceProvider ( { getService } ) { const lifecycle = getService ( 'lifecycle' ) ; const security = getService ( 'security' ) ; lifecycle . beforeTests . add ( async ( ) => { await security . user . create ( ENTERPRISE_SEARCH_USER , { password : ENTERPRISE_SEARCH_PASSWORD , roles : [ 'kibana_admin' ] , full_name : ENTERPRISE_SEARCH_USER , } ) ; } ) ; return new AppSearchService ( ) ; }