import querystring from 'querystring' ; import { encode , RisonValue } from 'rison-node' ; import { FtrProviderContext } from '../ftr_provider_context' ; import { LogPositionUrlState } from '../../../../x-pack/plugins/infra/public/containers/logs/log_position/with_log_position_url_state' ; import { FlyoutOptionsUrlState } from '../../../../x-pack/plugins/infra/public/containers/logs/log_flyout' ; export interface TabsParams { stream : { logPosition ? : Partial < LogPositionUrlState > ; flyoutOptions ? : Partial < FlyoutOptionsUrlState > ; } ; settings : never ; 'log-categories' : any ; 'log-rate' : any ; } export function InfraLogsPageProvider ( { getPageObjects , getService } ) { const testSubjects = getService ( 'testSubjects' ) ; const pageObjects = getPageObjects ( [ 'common' ] ) ; return { async navigateTo ( ) { await pageObjects . common . navigateToApp ( 'infraLogs' ) ; } , async navigateToTab < T extends LogsUiTab > ( logsUiTab , params ? ) { let qs = '' ; if ( params ) { const parsedParams = { } ; for ( const key in params ) { if ( params . hasOwnProperty ( key ) ) { const value = params [ key ] as unknown as RisonValue ; parsedParams [ key ] = encode ( value ) ; } } qs = '?' + querystring . stringify ( parsedParams ) ; } await pageObjects . common . navigateToUrlWithBrowserHistory ( 'infraLogs' , `/${ logsUiTab }` , qs , { ensureCurrentUrl : false } ) ; } , async getLogStream ( ) { return await testSubjects . find ( 'logStream' ) ; } , } ; } type LogsUiTab = 'log-categories' | 'log-rate' | 'settings' | 'stream' ;