import { FtrProviderContext } from '../../ftr_provider_context' ; export function UptimeAlertsProvider ( { getService } ) { const testSubjects = getService ( 'testSubjects' ) ; const browser = getService ( 'browser' ) ; return { async openFlyout ( alertType ) { await testSubjects . click ( 'xpack.uptime.alertsPopover.toggleButton' ) ; await testSubjects . click ( 'xpack.uptime.openAlertContextPanel' ) ; if ( alertType === 'monitorStatus' ) { await testSubjects . click ( 'xpack.uptime.toggleAlertFlyout' ) ; } else if ( alertType === 'tls' ) { await testSubjects . click ( 'xpack.uptime.toggleTlsAlertFlyout' ) ; } await testSubjects . exists ( 'alertNameInput' ) ; } , async openMonitorStatusAlertType ( alertType ) { await testSubjects . click ( `xpack.uptime.alerts.${ alertType }-SelectOption` ) ; } , async setAlertTags ( tags ) { for ( let i = 0 ; i < tags . length ; i += 1 ) { await testSubjects . click ( 'comboBoxSearchInput' ) ; await testSubjects . setValue ( 'comboBoxInput' , tags [ i ] ) ; await browser . pressKeys ( browser . keys . ENTER ) ; } } , async setAlertName ( name ) { await testSubjects . setValue ( 'alertNameInput' , name ) ; } , async setAlertInterval ( value ) { await testSubjects . setValue ( 'intervalInput' , value ) ; } , async setAlertThrottleInterval ( value ) { await testSubjects . click ( 'notifyWhenSelect' ) ; await testSubjects . click ( 'onThrottleInterval' ) ; await testSubjects . setValue ( 'throttleInput' , value ) ; } , async setAlertExpressionValue ( expressionAttribute , fieldAttribute , value ) { await testSubjects . click ( expressionAttribute ) ; await testSubjects . setValue ( fieldAttribute , value ) ; await testSubjects . click ( expressionAttribute ) ; } , async setAlertStatusNumTimes ( value ) { await this . setAlertExpressionValue ( 'xpack.uptime.alerts.monitorStatus.numTimesExpression' , 'xpack.uptime.alerts.monitorStatus.numTimesField' , value ) ; } , async setAlertTimerangeSelection ( value ) { await this . setAlertExpressionValue ( 'xpack.uptime.alerts.monitorStatus.timerangeValueExpression' , 'xpack.uptime.alerts.monitorStatus.timerangeValueField' , value ) ; } , async setAlertExpressionSelectable ( expressionAttribute , selectableAttribute , optionAttributes ) { await testSubjects . click ( expressionAttribute ) ; await testSubjects . click ( selectableAttribute ) ; for ( let i = 0 ; i < optionAttributes . length ; i += 1 ) { await testSubjects . click ( optionAttributes [ i ] ) ; } await testSubjects . click ( expressionAttribute ) ; } , async setMonitorStatusSelectableToHours ( ) { await this . setAlertExpressionSelectable ( 'xpack.uptime.alerts.monitorStatus.timerangeUnitExpression' , 'xpack.uptime.alerts.monitorStatus.timerangeUnitSelectable' , [ 'xpack.uptime.alerts.monitorStatus.timerangeUnitSelectable.hoursOption' ] ) ; } , async clickAddFilter ( ) { await testSubjects . click ( 'uptimeCreateAlertAddFilter' ) ; } , async clickAddFilterLocation ( ) { await this . clickAddFilter ( ) ; await testSubjects . click ( 'uptimeAlertAddFilter.observer.geo.name' ) ; await testSubjects . click ( 'uptimeCreateStatusAlert.filter_location' ) ; } , async clickAddFilterPort ( ) { await this . clickAddFilter ( ) ; await testSubjects . click ( 'uptimeAlertAddFilter.url.port' ) ; await testSubjects . click ( 'uptimeCreateStatusAlert.filter_port' ) ; } , async clickAddFilterType ( ) { await this . clickAddFilter ( ) ; await testSubjects . click ( 'uptimeAlertAddFilter.monitor.type' ) ; await testSubjects . click ( 'uptimeCreateStatusAlert.filter_scheme' ) ; } , async clickSaveAlertButton ( ) { await testSubjects . click ( 'saveAlertButton' ) ; } , async clickSaveAlertsConfirmButton ( ) { await testSubjects . click ( 'confirmAlertSaveModal > confirmModalConfirmButton' , 20000 ) ; } , } ; }