import { FtrProviderContext } from '../../ftr_provider_context' ; export default function spaceSelectorFunctionalTests ( { getService , getPageObjects , } ) { const esArchiver = getService ( 'esArchiver' ) ; const listingTable = getService ( 'listingTable' ) ; const PageObjects = getPageObjects ( [ 'common' , 'dashboard' , 'header' , 'home' , 'security' , 'spaceSelector' , ] ) ; describe ( 'Spaces' , function ( ) { before ( async ( ) => { await esArchiver . load ( 'x-pack/test/functional/es_archives/spaces/selector' ) ; } ) ; after ( async ( ) => await esArchiver . unload ( 'x-pack/test/functional/es_archives/spaces/selector' ) ) ; this . tags ( 'includeFirefox' ) ; describe . skip ( 'Space Selector' , ( ) => { before ( async ( ) => { await PageObjects . security . forceLogout ( ) ; } ) ; afterEach ( async ( ) => { await PageObjects . security . forceLogout ( ) ; } ) ; it ( 'allows user to navigate to different spaces' , async ( ) => { const spaceId = 'another-space' ; await PageObjects . security . login ( undefined , undefined , { expectSpaceSelector : true , } ) ; await PageObjects . spaceSelector . clickSpaceCard ( spaceId ) ; await PageObjects . spaceSelector . expectHomePage ( spaceId ) ; await PageObjects . spaceSelector . openSpacesNav ( ) ; await PageObjects . spaceSelector . clickSpaceAvatar ( 'default' ) ; await PageObjects . spaceSelector . expectHomePage ( 'default' ) ; } ) ; } ) ; describe . skip ( 'Search spaces in popover' , ( ) => { const spaceId = 'default' ; before ( async ( ) => { await PageObjects . security . forceLogout ( ) ; await PageObjects . security . login ( undefined , undefined , { expectSpaceSelector : true , } ) ; } ) ; after ( async ( ) => { await PageObjects . security . forceLogout ( ) ; } ) ; it ( 'allows user to search for spaces' , async ( ) => { await PageObjects . spaceSelector . clickSpaceCard ( spaceId ) ; await PageObjects . spaceSelector . expectHomePage ( spaceId ) ; await PageObjects . spaceSelector . openSpacesNav ( ) ; await PageObjects . spaceSelector . expectSearchBoxInSpacesSelector ( ) ; } ) ; it ( 'search for "ce 1" and find one space' , async ( ) => { await PageObjects . spaceSelector . setSearchBoxInSpacesSelector ( 'ce 1' ) ; await PageObjects . spaceSelector . expectToFindThatManySpace ( 1 ) ; } ) ; it ( 'search for "dog" and find NO space' , async ( ) => { await PageObjects . spaceSelector . setSearchBoxInSpacesSelector ( 'dog' ) ; await PageObjects . spaceSelector . expectToFindThatManySpace ( 0 ) ; await PageObjects . spaceSelector . expectNoSpacesFound ( ) ; } ) ; } ) ; describe ( 'Spaces Data' , ( ) => { const spaceId = 'another-space' ; const sampleDataHash = '/tutorial_directory/sampleData' ; const expectDashboardRenders = async ( dashName ) => { await listingTable . searchForItemWithName ( dashName ) ; await listingTable . clickItemLink ( 'dashboard' , dashName ) ; await PageObjects . header . waitUntilLoadingHasFinished ( ) ; await PageObjects . dashboard . waitForRenderComplete ( ) ; } ; before ( async ( ) => { await PageObjects . security . login ( undefined , undefined , { expectSpaceSelector : true , } ) ; await PageObjects . spaceSelector . clickSpaceCard ( 'default' ) ; await PageObjects . common . navigateToApp ( 'home' , { hash : sampleDataHash , } ) ; await PageObjects . home . addSampleDataSet ( 'logs' ) ; await PageObjects . common . navigateToApp ( 'home' , { hash : sampleDataHash , basePath : `/s/${ spaceId }` , } ) ; await PageObjects . home . addSampleDataSet ( 'logs' ) ; } ) ; after ( async ( ) => { await PageObjects . common . navigateToApp ( 'home' , { hash : sampleDataHash , } ) ; await PageObjects . home . removeSampleDataSet ( 'logs' ) ; await PageObjects . security . forceLogout ( ) ; } ) ; describe ( 'displays separate data for each space' , ( ) => { it ( 'in the default space' , async ( ) => { await PageObjects . common . navigateToApp ( 'dashboard' ) ; await expectDashboardRenders ( '[Logs] Web Traffic' ) ; } ) ; it ( 'in a custom space' , async ( ) => { await PageObjects . common . navigateToApp ( 'dashboard' , { basePath : `/s/${ spaceId }` , } ) ; await expectDashboardRenders ( '[Logs] Web Traffic' ) ; } ) ; } ) ; } ) ; } ) ; }