import expect from '@kbn/expect' ; import { FtrProviderContext } from '../../../ftr_provider_context' ; export default function ( { getPageObjects , getService } ) { const esArchiver = getService ( 'esArchiver' ) ; const spacesService = getService ( 'spaces' ) ; const PageObjects = getPageObjects ( [ 'common' , 'settings' , 'security' , 'spaceSelector' ] ) ; const testSubjects = getService ( 'testSubjects' ) ; const appsMenu = getService ( 'appsMenu' ) ; const config = getService ( 'config' ) ; describe ( 'spaces feature controls' , ( ) => { before ( async ( ) => { await esArchiver . loadIfNeeded ( 'x-pack/test/functional/es_archives/logstash_functional' ) ; } ) ; 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 Management navlink' , async ( ) => { await PageObjects . common . navigateToApp ( 'home' , { basePath : '/s/custom_space' , } ) ; const navLinks = ( await appsMenu . readLinks ( ) ) . map ( ( link ) => link . text ) ; expect ( navLinks ) . to . contain ( 'Stack Management' ) ; } ) ; it ( `allows settings to be changed` , async ( ) => { await PageObjects . common . navigateToUrl ( 'management' , 'kibana/settings' , { basePath : `/s/custom_space` , ensureCurrentUrl : false , shouldLoginIfPrompted : false , shouldUseHashForSubUrl : false , } ) ; await PageObjects . settings . setAdvancedSettingsSelect ( 'dateFormat:tz' , 'America/Phoenix' ) ; const advancedSetting = await PageObjects . settings . getAdvancedSettings ( 'dateFormat:tz' ) ; expect ( advancedSetting ) . to . be ( 'America/Phoenix' ) ; } ) ; } ) ; describe ( 'space with Advanced Settings disabled' , function ( ) { before ( async ( ) => { await esArchiver . load ( 'x-pack/test/functional/es_archives/empty_kibana' ) ; await spacesService . create ( { id : 'custom_space' , name : 'custom_space' , disabledFeatures : [ 'advancedSettings' ] , } ) ; } ) ; after ( async ( ) => { await spacesService . delete ( 'custom_space' ) ; await esArchiver . unload ( 'x-pack/test/functional/es_archives/empty_kibana' ) ; } ) ; it ( `redirects to management home` , async ( ) => { await PageObjects . common . navigateToUrl ( 'management' , 'kibana/settings' , { basePath : `/s/custom_space` , ensureCurrentUrl : false , shouldLoginIfPrompted : false , shouldUseHashForSubUrl : false , } ) ; await testSubjects . existOrFail ( 'managementHome' , { timeout : config . get ( 'timeouts.waitFor' ) , } ) ; } ) ; } ) ; } ) ; }