import expect from '@kbn/expect' ; import { FtrProviderContext } from '../../ftr_provider_context' ; export function TransformDiscoverProvider ( { getService } ) { const find = getService ( 'find' ) ; const testSubjects = getService ( 'testSubjects' ) ; return { async assertDiscoverQueryHits ( expectedDiscoverQueryHits ) { await testSubjects . existOrFail ( 'discoverQueryHits' ) ; const actualDiscoverQueryHits = await testSubjects . getVisibleText ( 'discoverQueryHits' ) ; expect ( actualDiscoverQueryHits ) . to . eql ( expectedDiscoverQueryHits , `Discover query hits should be ${ expectedDiscoverQueryHits }, got ${ actualDiscoverQueryHits }` ) ; } , async assertNoResults ( expectedDestinationIndex ) { const actualIndexPatternSwitchLinkText = await ( await testSubjects . find ( 'indexPattern-switch-link' ) ) . getVisibleText ( ) ; expect ( actualIndexPatternSwitchLinkText ) . to . eql ( expectedDestinationIndex , `Destination index should be ${ expectedDestinationIndex }, got ${ actualIndexPatternSwitchLinkText }` ) ; await testSubjects . existOrFail ( 'discoverNoResults' ) ; } , async assertSuperDatePickerToggleQuickMenuButtonExists ( ) { await testSubjects . existOrFail ( 'superDatePickerToggleQuickMenuButton' ) ; } , async openSuperDatePicker ( ) { await testSubjects . click ( 'superDatePickerToggleQuickMenuButton' ) ; await testSubjects . existOrFail ( 'superDatePickerQuickMenu' ) ; } , async quickSelectYears ( ) { const quickMenuElement = await testSubjects . find ( 'superDatePickerQuickMenu' ) ; await find . selectValue ( `[aria-label*="Time unit"]` , 'y' ) ; const applyButton = await quickMenuElement . findByClassName ( 'euiQuickSelect__applyButton' ) ; const actualApplyButtonText = await applyButton . getVisibleText ( ) ; expect ( actualApplyButtonText ) . to . be ( 'Apply' ) ; await applyButton . click ( ) ; await testSubjects . existOrFail ( 'discoverQueryHits' ) ; } , } ; }