import expect from '@kbn/expect' ; import { FtrProviderContext } from '../../../ftr_provider_context' ; export default function ( { getPageObjects , getService } ) { const spacesService = getService ( 'spaces' ) ; const PageObjects = getPageObjects ( [ 'common' , 'dashboard' , 'security' , 'error' ] ) ; const appsMenu = getService ( 'appsMenu' ) ; const testSubjects = getService ( 'testSubjects' ) ; describe ( 'spaces' , ( ) => { describe ( 'space with no features disabled' , ( ) => { before ( async ( ) => { await spacesService . create ( { id : 'custom_space' , name : 'custom_space' , disabledFeatures : [ ] , } ) ; } ) ; after ( async ( ) => { await spacesService . delete ( 'custom_space' ) ; } ) ; it ( 'shows Machine Learning navlink' , async ( ) => { await PageObjects . common . navigateToApp ( 'home' , { basePath : '/s/custom_space' , } ) ; const navLinks = ( await appsMenu . readLinks ( ) ) . map ( ( link ) => link . text ) ; expect ( navLinks ) . to . contain ( 'Machine Learning' ) ; } ) ; it ( `can navigate to app` , async ( ) => { await PageObjects . common . navigateToApp ( 'ml' , { basePath : '/s/custom_space' , } ) ; await testSubjects . existOrFail ( 'mlPageOverview' ) ; } ) ; } ) ; describe ( 'space with ML disabled' , ( ) => { before ( async ( ) => { await spacesService . create ( { id : 'custom_space' , name : 'custom_space' , disabledFeatures : [ 'ml' ] , } ) ; } ) ; after ( async ( ) => { await spacesService . delete ( 'custom_space' ) ; } ) ; it ( `doesn't show Machine Learning navlink` , async ( ) => { await PageObjects . common . navigateToApp ( 'home' , { basePath : '/s/custom_space' , } ) ; const navLinks = ( await appsMenu . readLinks ( ) ) . map ( ( link ) => link . text ) ; expect ( navLinks ) . not . to . contain ( 'Machine Learning' ) ; } ) ; it ( `navigating to app returns a 404` , async ( ) => { await PageObjects . common . navigateToUrl ( 'ml' , '' , { basePath : '/s/custom_space' , shouldLoginIfPrompted : false , ensureCurrentUrl : false , } ) ; await PageObjects . error . expectNotFound ( ) ; } ) ; } ) ; } ) ; }