import * as osdTestServer from '../../../test_helpers/osd_server' ; describe ( 'legacy service' , ( ) => { describe ( 'http server' , ( ) => { let root ; beforeEach ( ( ) => { root = osdTestServer . createRoot ( { migrations : { skip : true } , plugins : { initialize : false } , } ) ; } , 30000 ) ; afterEach ( async ( ) => await root . shutdown ( ) ) ; it ( "handles http request in Legacy platform if New platform doesn't handle it" , async ( ) => { const { http } = await root . setup ( ) ; const rootUrl = '/route' ; const router = http . createRouter ( rootUrl ) ; router . get ( { path : '/new-platform' , validate : false } , ( context , req , res ) => res . ok ( { body : 'from-new-platform' } ) ) ; await root . start ( ) ; const legacyPlatformUrl = `${ rootUrl }/legacy-platform` ; const osdServer = osdTestServer . getOsdServer ( root ) ; osdServer . server . route ( { method : 'GET' , path : legacyPlatformUrl , handler : ( ) => 'ok from legacy server' , } ) ; await osdTestServer . request . get ( root , '/route/new-platform' ) . expect ( 200 , 'from-new-platform' ) ; await osdTestServer . request . get ( root , legacyPlatformUrl ) . expect ( 200 , 'ok from legacy server' ) ; } ) ; it ( 'throws error if Legacy and New platforms register handler for the same route' , async ( ) => { const { http } = await root . setup ( ) ; const rootUrl = '/route' ; const router = http . createRouter ( rootUrl ) ; router . get ( { path : '' , validate : false } , ( context , req , res ) => res . ok ( { body : 'from-new-platform' } ) ) ; await root . start ( ) ; const osdServer = osdTestServer . getOsdServer ( root ) ; expect ( ( ) => osdServer . server . route ( { method : 'GET' , path : rootUrl , handler : ( ) => 'ok from legacy server' , } ) ) . toThrowErrorMatchingInlineSnapshot ( `"New route /route conflicts with existing /route"` ) ; } ) ; } ) ; } ) ;