import { FtrProviderContext } from '../../ftr_provider_context' ; import { DynamicSettings } from '../../../../plugins/uptime/common/runtime_types' ; export function UptimeSettingsProvider ( { getService } ) { const testSubjects = getService ( 'testSubjects' ) ; const retry = getService ( 'retry' ) ; const changeInputField = async ( text , field ) => { const input = await testSubjects . find ( field , 5000 ) ; await input . clearValueWithKeyboard ( ) ; await input . type ( text ) ; } ; return { go : async ( ) => { await testSubjects . click ( 'settings-page-link' , 5000 ) ; } , changeHeartbeatIndicesInput : async ( text ) => { await changeInputField ( text , 'heartbeat-indices-input-loaded' ) ; } , changeErrorThresholdInput : async ( text ) => { await changeInputField ( text , 'expiration-threshold-input-loaded' ) ; } , changeWarningThresholdInput : async ( text ) => { await changeInputField ( text , 'age-threshold-input-loaded' ) ; } , loadFields : async ( ) : Promise < DynamicSettings > => { const indInput = await testSubjects . find ( 'heartbeat-indices-input-loaded' , 5000 ) ; const expirationInput = await testSubjects . find ( 'expiration-threshold-input-loaded' , 5000 ) ; const ageInput = await testSubjects . find ( 'age-threshold-input-loaded' , 5000 ) ; const heartbeatIndices = await indInput . getAttribute ( 'value' ) ; const expiration = await expirationInput . getAttribute ( 'value' ) ; const age = await ageInput . getAttribute ( 'value' ) ; return { heartbeatIndices , certAgeThreshold : parseInt ( age , 10 ) , certExpirationThreshold : parseInt ( expiration , 10 ) , defaultConnectors : [ ] , } ; } , applyButtonIsDisabled : async ( ) => { return ! ! ( await ( await testSubjects . find ( 'apply-settings-button' ) ) . getAttribute ( 'disabled' ) ) ; } , apply : async ( ) => { await ( await testSubjects . find ( 'apply-settings-button' ) ) . click ( ) ; await retry . waitFor ( 'submit to succeed' , async ( ) => { const disabled = await ( await testSubjects . find ( 'heartbeat-indices-input-loaded' , 5000 ) ) . getAttribute ( 'disabled' ) ; return disabled === null ; } ) ; } , } ; }