import { SPACES } from '../../common/lib/spaces' ; import { getTestScenarios } from '../../../saved_object_api_integration/common/lib/saved_object_test_utils' ; import { getShareableReferencesTestSuiteFactory , GetShareableReferencesTestCase , TEST_CASE_OBJECTS , EXPECTED_RESULTS , } from '../../common/suites/get_shareable_references' ; import { FtrProviderContext } from '../../common/ftr_provider_context' ; const { DEFAULT : { spaceId : DEFAULT_SPACE_ID } , SPACE_1 : { spaceId : SPACE_1_ID } , SPACE_2 : { spaceId : SPACE_2_ID } , } = SPACES ; const createTestCases = ( spaceId ) : GetShareableReferencesTestCase [ ] => { const objects = [ TEST_CASE_OBJECTS . SHAREABLE_TYPE , TEST_CASE_OBJECTS . SHAREABLE_TYPE_DOES_NOT_EXIST , TEST_CASE_OBJECTS . NON_SHAREABLE_TYPE , ] ; if ( spaceId === DEFAULT_SPACE_ID ) { return [ { objects , expectedResults : EXPECTED_RESULTS . IN_DEFAULT_SPACE } ] ; } else if ( spaceId === SPACE_1_ID ) { return [ { objects , expectedResults : EXPECTED_RESULTS . IN_SPACE_1 } ] ; } else if ( spaceId === SPACE_2_ID ) { return [ { objects , expectedResults : EXPECTED_RESULTS . IN_SPACE_2 } ] ; } throw new Error ( `Unexpected test case for space '${ spaceId }'!` ) ; } ; export default function ( { getService } ) { const supertest = getService ( 'supertest' ) ; const esArchiver = getService ( 'esArchiver' ) ; const { addTests , createTestDefinitions } = getShareableReferencesTestSuiteFactory ( esArchiver , supertest ) ; const createTests = ( spaceId ) => { const testCases = createTestCases ( spaceId ) ; return createTestDefinitions ( testCases , false ) ; } ; describe ( '_get_shareable_references' , ( ) => { getTestScenarios ( ) . spaces . forEach ( ( { spaceId } ) => { const tests = createTests ( spaceId ) ; addTests ( `targeting the ${ spaceId } space` , { spaceId , tests } ) ; } ) ; } ) ; }