import expect from '@kbn/expect' ; import { FtrProviderContext } from '../../ftr_provider_context' ; export function MachineLearningJobWizardPopulationProvider ( { getService } ) { const comboBox = getService ( 'comboBox' ) ; const testSubjects = getService ( 'testSubjects' ) ; return { async assertPopulationFieldInputExists ( ) { await testSubjects . existOrFail ( 'mlPopulationSplitFieldSelect > comboBoxInput' ) ; } , async assertPopulationFieldSelection ( expectedIdentifier ) { const comboBoxSelectedOptions = await comboBox . getComboBoxSelectedOptions ( 'mlPopulationSplitFieldSelect > comboBoxInput' ) ; expect ( comboBoxSelectedOptions ) . to . eql ( expectedIdentifier , `Expected population field selection to be '${ expectedIdentifier }' (got '${ comboBoxSelectedOptions }')` ) ; } , async selectPopulationField ( identifier ) { await comboBox . set ( 'mlPopulationSplitFieldSelect > comboBoxInput' , identifier ) ; await this . assertPopulationFieldSelection ( [ identifier ] ) ; } , async assertDetectorSplitFieldInputExists ( detectorPosition ) { await testSubjects . existOrFail ( `mlDetector ${ detectorPosition } > mlByFieldSelect  > comboBoxInput` ) ; } , async assertDetectorSplitFieldSelection ( detectorPosition , expectedIdentifier ) { const comboBoxSelectedOptions = await comboBox . getComboBoxSelectedOptions ( `mlDetector ${ detectorPosition } > mlByFieldSelect  > comboBoxInput` ) ; expect ( comboBoxSelectedOptions ) . to . eql ( expectedIdentifier , `Expected detector split field selection to be '${ expectedIdentifier }' (got '${ comboBoxSelectedOptions }')` ) ; } , async selectDetectorSplitField ( detectorPosition , identifier ) { await comboBox . set ( `mlDetector ${ detectorPosition } > mlByFieldSelect  > comboBoxInput` , identifier ) ; await this . assertDetectorSplitFieldSelection ( detectorPosition , [ identifier ] ) ; } , async assertDetectorSplitExists ( detectorPosition ) { await testSubjects . existOrFail ( `mlDetector ${ detectorPosition } > mlDataSplit` ) ; await testSubjects . existOrFail ( `mlDetector ${ detectorPosition } > mlDataSplit > mlSplitCard front` ) ; } , async assertDetectorSplitFrontCardTitle ( detectorPosition , expectedFrontCardTitle ) { const actualSplitFrontCardTitle = await testSubjects . getVisibleText ( `mlDetector ${ detectorPosition } > mlDataSplit > mlSplitCard front > mlSplitCardTitle` ) ; expect ( actualSplitFrontCardTitle ) . to . eql ( expectedFrontCardTitle , `Expected front card title for detector position '${ detectorPosition }' to be '${ expectedFrontCardTitle }' (got '${ actualSplitFrontCardTitle }')` ) ; } , async assertDetectorSplitNumberOfBackCards ( detectorPosition , expectedNumberOfBackCards ) { const allBackCards = await testSubjects . findAll ( `mlDetector ${ detectorPosition } > mlDataSplit > mlSplitCard back` ) ; expect ( allBackCards ) . to . have . length ( expectedNumberOfBackCards , `Expected number of back cards for detector position '${ detectorPosition }' to be '${ expectedNumberOfBackCards }' (got '${ allBackCards . length }')` ) ; } , } ; }