import { FtrProviderContext } from '../../ftr_provider_context' ; export function MachineLearningJobSourceSelectionProvider ( { getService } ) { const testSubjects = getService ( 'testSubjects' ) ; const retry = getService ( 'retry' ) ; return { async assertSourceListContainsEntry ( sourceName ) { await testSubjects . existOrFail ( `savedObjectTitle${ sourceName }` ) ; } , async filterSourceSelection ( sourceName ) { await testSubjects . setValue ( 'savedObjectFinderSearchInput' , sourceName , { clearWithKeyboard : true , } ) ; await this . assertSourceListContainsEntry ( sourceName ) ; } , async selectSource ( sourceName , nextPageSubj ) { await this . filterSourceSelection ( sourceName ) ; await retry . tryForTime ( 30 * 1000 , async ( ) => { await testSubjects . clickWhenNotDisabled ( `savedObjectTitle${ sourceName }` ) ; await testSubjects . existOrFail ( nextPageSubj , { timeout : 10 * 1000 } ) ; } ) ; } , async selectSourceForAnomalyDetectionJob ( sourceName ) { await this . selectSource ( sourceName , 'mlPageJobTypeSelection' ) ; } , async selectSourceForAnalyticsJob ( sourceName ) { await this . selectSource ( sourceName , 'mlAnalyticsCreationContainer' ) ; } , async selectSourceForIndexBasedDataVisualizer ( sourceName ) { await this . selectSource ( sourceName , 'dataVisualizerIndexPage' ) ; } , } ; }