import expect from '@kbn/expect' ; import { FtrProviderContext } from '../../../api_integration/ftr_provider_context' ; import { appContextService } from '../../../../plugins/fleet/server/services' ; import { getTemplate } from '../../../../plugins/fleet/server/services/epm/elasticsearch/template/template' ; export default function ( { getService } ) { const templateName = 'bar' ; const templateIndexPattern = 'bar-*' ; const es = getService ( 'es' ) ; const mappings = { properties : { foo : { type : 'keyword' , } , } , } ; const fields = [ { name : 'foo' , type : 'keyword' , } , ] ; describe ( 'EPM - template' , async ( ) => { beforeEach ( async ( ) => { appContextService . start ( { elasticsearch : { client : { } } , logger : { warn : ( ) => { } , } , } ) ; } ) ; it ( 'can be loaded' , async ( ) => { const template = getTemplate ( { type : 'logs' , templateIndexPattern , fields , mappings , packageName : 'system' , composedOfTemplates : [ ] , templatePriority : 200 , } ) ; const { body : response1 } = await es . transport . request ( { method : 'PUT' , path : `/_index_template/${ templateName }` , body : template , } , { meta : true } ) ; expect ( response1 ) . to . eql ( { acknowledged : true } ) ; const { body : response2 } = await es . transport . request < any > ( { method : 'GET' , path : `/_index_template/${ templateName }` , } , { meta : true } ) ; expect ( response2 . index_templates [ 0 ] . index_template . index_patterns ) . to . eql ( [ templateIndexPattern , ] ) ; } ) ; } ) ; }