import expect from '@kbn/expect' ; import { FtrProviderContext } from '../../common/ftr_provider_context' ; export default function ApiTest ( { getService } ) { const registry = getService ( 'registry' ) ; const apmApiClient = getService ( 'apmApiClient' ) ; const endpoint = 'POST /internal/apm/latency/overall_distribution' ; const getOptions = ( ) => ( { params : { body : { environment : 'ENVIRONMENT_ALL' , start : '2020' , end : '2021' , kuery : '' , percentileThreshold : 95 , } , } , } ) ; registry . when ( 'latency overall distribution without data' , { config : 'trial' , archives : [ ] } , ( ) => { it ( 'handles the empty state' , async ( ) => { const response = await apmApiClient . readUser ( { endpoint , ... getOptions ( ) , } ) ; expect ( response . status ) . to . be ( 200 ) ; expect ( response . body ?. percentileThresholdValue ) . to . be ( undefined ) ; expect ( response . body ?. overallHistogram ?. length ) . to . be ( undefined ) ; } ) ; } ) ; registry . when ( 'latency overall distribution with data and default args' , { config : 'trial' , archives : [ '8.0.0' ] } , ( ) => { it ( 'returns percentileThresholdValue and overall histogram' , async ( ) => { const response = await apmApiClient . readUser ( { endpoint , ... getOptions ( ) , } ) ; expect ( response . status ) . to . eql ( 200 ) ; expect ( response . body ?. percentileThresholdValue ) . to . be ( 1309695.875 ) ; expect ( response . body ?. overallHistogram ?. length ) . to . be ( 101 ) ; } ) ; } ) ; }