import expect from '@kbn/expect' ; import { FtrProviderContext } from '../../common/ftr_provider_context' ; import { NavLinksBuilder } from '../../common/nav_links_builder' ; import { FeaturesService } from '../../common/services' ; import { UICapabilitiesService } from '../../common/services/ui_capabilities' ; import { SpaceScenarios } from '../scenarios' ; export default function navLinksTests ( { getService } ) { const uiCapabilitiesService = getService ( 'uiCapabilities' ) ; const featuresService = getService ( 'features' ) ; const uiCapabilitiesExceptions = [ 'enterpriseSearch' , 'appSearch' , 'workplaceSearch' , ] ; describe ( 'navLinks' , ( ) => { let navLinksBuilder ; before ( async ( ) => { const features = await featuresService . get ( ) ; navLinksBuilder = new NavLinksBuilder ( features ) ; } ) ; SpaceScenarios . forEach ( ( scenario ) => { it ( `${ scenario . name }` , async ( ) => { const uiCapabilities = await uiCapabilitiesService . get ( { spaceId : scenario . id } ) ; switch ( scenario . id ) { case 'everything_space' : expect ( uiCapabilities . success ) . to . be ( true ) ; expect ( uiCapabilities . value ) . to . have . property ( 'navLinks' ) ; expect ( uiCapabilities . value ! . navLinks ) . to . eql ( navLinksBuilder . except ( ... uiCapabilitiesExceptions ) ) ; break ; case 'nothing_space' : expect ( uiCapabilities . success ) . to . be ( true ) ; expect ( uiCapabilities . value ) . to . have . property ( 'navLinks' ) ; expect ( uiCapabilities . value ! . navLinks ) . to . eql ( navLinksBuilder . only ( 'management' ) ) ; break ; case 'foo_disabled_space' : expect ( uiCapabilities . success ) . to . be ( true ) ; expect ( uiCapabilities . value ) . to . have . property ( 'navLinks' ) ; expect ( uiCapabilities . value ! . navLinks ) . to . eql ( navLinksBuilder . except ( 'foo' , ... uiCapabilitiesExceptions ) ) ; break ; default : throw new UnreachableError ( scenario ) ; } } ) ; } ) ; } ) ; }