import expect from '@kbn/expect' ; import { FtrProviderContext } from '../../ftr_provider_context' ; const getSpacePrefix = ( spaceId ) => { return spaceId && spaceId !== 'default' ? `/s/${ spaceId }` : `` ; } ; export default function ( { getPageObjects , getService } ) { const PageObjects = getPageObjects ( [ 'common' , 'security' , 'savedObjects' , 'spaceSelector' , 'settings' , ] ) ; const find = getService ( 'find' ) ; const kibanaServer = getService ( 'kibanaServer' ) ; const spacesService = getService ( 'spaces' ) ; const spaceId = 'space_1' ; const textIncludesAll = ( text , items ) => { const bools = items . map ( ( item ) => ! ! text . includes ( item ) ) ; return bools . every ( ( currBool ) => currBool === true ) ; } ; describe . skip ( 'spaces integration' , ( ) => { before ( async ( ) => { await spacesService . create ( { id : spaceId , name : spaceId } ) ; await kibanaServer . importExport . load ( 'x-pack/test/functional/fixtures/kbn_archiver/saved_objects_management/spaces_integration' , { space : spaceId } ) ; } ) ; after ( async ( ) => { await spacesService . delete ( spaceId ) ; } ) ; beforeEach ( async ( ) => { await PageObjects . common . navigateToUrl ( 'settings' , 'kibana/objects' , { basePath : getSpacePrefix ( spaceId ) , shouldUseHashForSubUrl : false , } ) ; await PageObjects . savedObjects . waitTableIsLoaded ( ) ; } ) ; it ( 'redirects to correct url when inspecting an object from a non-default space' , async ( ) => { const objects = await PageObjects . savedObjects . getRowTitles ( ) ; expect ( objects . includes ( 'A Pie' ) ) . to . be ( true ) ; await PageObjects . savedObjects . clickInspectByTitle ( 'A Pie' ) ; await PageObjects . common . waitUntilUrlIncludes ( getSpacePrefix ( spaceId ) ) ; const inspectContainer = await find . byClassName ( 'kibanaCodeEditor' ) ; const visibleContainerText = await inspectContainer . getVisibleText ( ) ; expect ( textIncludesAll ( visibleContainerText , [ 'A Pie' , 'title' , 'id' , 'type' , 'attributes' , 'references' , ] ) ) . to . be ( true ) ; expect ( visibleContainerText . includes ( 'A Pie' ) ) ; } ) ; } ) ; }