import expect from '@kbn/expect' ; import { FtrProviderContext } from '../../ftr_provider_context' ; export function MachineLearningJobSelectionProvider ( { getService } ) { const testSubjects = getService ( 'testSubjects' ) ; return { async assertJobSelection ( jobOrGroupIds ) { const selectedJobsOrGroups = await testSubjects . findAll ( 'mlJobSelectionBadges > ~mlJobSelectionBadge' ) ; const actualJobOrGroupLabels = await Promise . all ( selectedJobsOrGroups . map ( async ( badge ) => await badge . getVisibleText ( ) ) ) ; expect ( actualJobOrGroupLabels ) . to . eql ( jobOrGroupIds , `Job selection should display jobs or groups '${ jobOrGroupIds }' (got '${ actualJobOrGroupLabels }')` ) ; } , async assertJobSelectionNotContains ( jobOrGroupId ) { const selectedJobsOrGroups = await testSubjects . findAll ( 'mlJobSelectionBadges > ~mlJobSelectionBadge' ) ; const actualJobOrGroupLabels = await Promise . all ( selectedJobsOrGroups . map ( async ( badge ) => await badge . getVisibleText ( ) ) ) ; expect ( actualJobOrGroupLabels ) . to . not . contain ( jobOrGroupId , `Job selection should not contain job or group '${ jobOrGroupId }' (got '${ actualJobOrGroupLabels }')` ) ; } , } ; }