import expect from '@kbn/expect' ; import { FtrProviderContext } from '../../ftr_provider_context' ; import { MlApi } from './api' ; import { MlCommonUI } from './common_ui' ; type ModelType = 'regression' | 'classification' ; export function TrainedModelsProvider ( { getService } , mlApi , mlCommonUI ) { const testSubjects = getService ( 'testSubjects' ) ; const retry = getService ( 'retry' ) ; return { async createTestTrainedModels ( modelType , count = 10 , withIngestPipelines = false ) { await mlApi . createTestTrainedModels ( modelType , count , withIngestPipelines ) ; } , async assertStats ( expectedTotalCount ) { await retry . tryForTime ( 5 * 1000 , async ( ) => { const actualStats = await testSubjects . getVisibleText ( 'mlInferenceModelsStatsBar' ) ; expect ( actualStats ) . to . eql ( `Total trained models: ${ expectedTotalCount }` ) ; } ) ; } , async assertTableExists ( ) { await testSubjects . existOrFail ( '~mlModelsTable' ) ; } , async assertRowsNumberPerPage ( rowsNumber ) { await mlCommonUI . assertRowsNumberPerPage ( 'mlModelsTableContainer' , rowsNumber ) ; } , } ; }