import expect from '@kbn/expect' ; import { FtrProviderContext } from '../../ftr_provider_context' ; const policyName = 'testPolicy1' ; const repoName = 'test' ; export default ( { getPageObjects , getService } ) => { const pageObjects = getPageObjects ( [ 'common' , 'indexLifecycleManagement' ] ) ; const log = getService ( 'log' ) ; const retry = getService ( 'retry' ) ; const esClient = getService ( 'es' ) ; const security = getService ( 'security' ) ; describe ( 'Home page' , function ( ) { before ( async ( ) => { await security . testUser . setRoles ( [ 'manage_ilm' ] , true ) ; await esClient . snapshot . createRepository ( { name : repoName , body : { type : 'fs' , settings : { location : '/tmp/' , } , } , verify : false , } ) ; await pageObjects . common . navigateToApp ( 'indexLifecycleManagement' ) ; } ) ; after ( async ( ) => { await esClient . snapshot . deleteRepository ( { name : repoName } ) ; await esClient . ilm . deleteLifecycle ( { name : policyName } ) ; await security . testUser . restoreDefaults ( ) ; } ) ; it ( 'Loads the app' , async ( ) => { await log . debug ( 'Checking for page header' ) ; const headerText = await pageObjects . indexLifecycleManagement . pageHeaderText ( ) ; expect ( headerText ) . to . be ( 'Index Lifecycle Policies' ) ; const createPolicyButton = await pageObjects . indexLifecycleManagement . createPolicyButton ( ) ; expect ( await createPolicyButton . isDisplayed ( ) ) . to . be ( true ) ; } ) ; it ( 'Create new policy with all Phases' , async ( ) => { await pageObjects . indexLifecycleManagement . createNewPolicyAndSave ( { policyName , warmEnabled : true , coldEnabled : true , frozenEnabled : true , deleteEnabled : true , snapshotRepository : repoName , } ) ; await retry . waitFor ( 'navigation back to home page.' , async ( ) => { return ( ( await pageObjects . indexLifecycleManagement . pageHeaderText ( ) ) === 'Index Lifecycle Policies' ) ; } ) ; await pageObjects . indexLifecycleManagement . increasePolicyListPageSize ( ) ; const createdPolicy = await pageObjects . indexLifecycleManagement . getPolicyRow ( policyName ) ; expect ( createdPolicy . length ) . to . be ( 1 ) ; } ) ; } ) ; } ;