import { FtrProviderContext } from '../../ftr_provider_context' ; export function UptimeNavigationProvider ( { getService , getPageObjects } ) { const retry = getService ( 'retry' ) ; const testSubjects = getService ( 'testSubjects' ) ; const find = getService ( 'find' ) ; const PageObjects = getPageObjects ( [ 'common' , 'timePicker' , 'header' ] ) ; const goToUptimeRoot = async ( ) => { await retry . tryForTime ( 60 * 1000 , async ( ) => { if ( await testSubjects . exists ( 'uptimeSettingsToOverviewLink' , { timeout : 0 } ) ) { await testSubjects . click ( 'uptimeSettingsToOverviewLink' ) ; await PageObjects . header . waitUntilLoadingHasFinished ( ) ; await testSubjects . existOrFail ( 'uptimeOverviewPage' , { timeout : 2000 } ) ; } else { await PageObjects . common . navigateToApp ( 'uptime' ) ; await PageObjects . header . waitUntilLoadingHasFinished ( ) ; await testSubjects . existOrFail ( 'uptimeOverviewPage' , { timeout : 2000 } ) ; } } ) ; } ; const refreshApp = async ( ) => { await testSubjects . click ( 'superDatePickerApplyTimeButton' , 10000 ) ; } ; return { async refreshApp ( ) { await refreshApp ( ) ; } , async goToUptime ( ) { await goToUptimeRoot ( ) ; } , goToSettings : async ( ) => { await goToUptimeRoot ( ) ; await testSubjects . click ( 'settings-page-link' , 5000 ) ; await testSubjects . existOrFail ( 'uptimeSettingsPage' , { timeout : 10000 } ) ; } , checkIfOnMonitorPage : async ( monitorId ) => { const monitorPage = await testSubjects . exists ( 'uptimeMonitorPage' , { timeout : 1000 } ) ; if ( monitorId && monitorPage ) { const thisMonitorPage = ( await testSubjects . getVisibleText ( 'monitor-page-title' ) ) === monitorId ; return monitorPage && thisMonitorPage ; } else { return monitorPage ; } } , goToMonitor : async ( monitorId ) => { if ( ! ( await testSubjects . exists ( 'uptimeMonitorPage' , { timeout : 0 } ) ) ) { return retry . try ( async ( ) => { await testSubjects . click ( `monitor-page-link-${ monitorId }` ) ; } ) ; await testSubjects . existOrFail ( 'uptimeMonitorPage' , { timeout : 30000 , } ) ; } } , goToCertificates : async ( ) => { if ( ! ( await testSubjects . exists ( 'uptimeCertificatesPage' , { timeout : 0 } ) ) ) { return retry . try ( async ( ) => { if ( await find . existsByCssSelector ( '[href="/app/uptime/certificates"]' , 0 ) ) { await find . clickByCssSelector ( '[href="/app/uptime/certificates"]' ) ; } await testSubjects . existOrFail ( 'uptimeCertificatesPage' ) ; } ) ; } return true ; } , async loadDataAndGoToMonitorPage ( dateStart , dateEnd , monitorId ) { await PageObjects . timePicker . setAbsoluteRange ( dateStart , dateEnd ) ; await this . goToMonitor ( monitorId ) ; } , async isOnDetailsPage ( ) { return await testSubjects . exists ( 'uptimeMonitorPage' , { timeout : 0 } ) ; } , async goToHomeViaBreadCrumb ( ) { await testSubjects . click ( 'breadcrumb first' ) ; } , } ; }