import { SPACES } from '../../common/lib/spaces' ; import { getTestSuiteFactory } from '../../common/suites/get' ; import { FtrProviderContext } from '../../common/ftr_provider_context' ; export default function getSpaceTestSuite ( { getService } ) { const supertestWithoutAuth = getService ( 'supertestWithoutAuth' ) ; const esArchiver = getService ( 'esArchiver' ) ; const { getTest , createExpectResults , createExpectNotFoundResult , nonExistantSpaceId } = getTestSuiteFactory ( esArchiver , supertestWithoutAuth ) ; describe ( 'get' , ( ) => { [ { currentSpaceId : SPACES . DEFAULT . spaceId , spaceId : SPACES . DEFAULT . spaceId , } , { currentSpaceId : SPACES . DEFAULT . spaceId , spaceId : SPACES . SPACE_1 . spaceId , } , { currentSpaceId : SPACES . SPACE_1 . spaceId , spaceId : SPACES . DEFAULT . spaceId , } , { currentSpaceId : SPACES . SPACE_1 . spaceId , spaceId : SPACES . SPACE_1 . spaceId , } , ] . forEach ( ( scenario ) => { getTest ( `can access ${ scenario . spaceId } from within the ${ scenario . currentSpaceId } space` , { spaceId : scenario . spaceId , currentSpaceId : scenario . currentSpaceId , tests : { default : { statusCode : 200 , response : createExpectResults ( scenario . spaceId ) , } , } , } ) ; } ) ; [ { currentSpaceId : SPACES . DEFAULT . spaceId , spaceId : nonExistantSpaceId , } , ] . forEach ( ( scenario ) => { getTest ( `can't access ${ scenario . spaceId } from within the ${ scenario . currentSpaceId } space` , { spaceId : scenario . spaceId , currentSpaceId : scenario . currentSpaceId , tests : { default : { statusCode : 404 , response : createExpectNotFoundResult ( ) , } , } , } ) ; } ) ; } ) ; }