@@ -178,6 +178,37 @@ describe('browser-client', () => {
178178 expect ( MockedRemoteConfigClient ) . not . toHaveBeenCalled ( ) ;
179179 } ) ;
180180
181+ test ( 'shares the HTTP client with remote config, diagnostics, and transport changes' , async ( ) => {
182+ const httpClient = {
183+ send : jest . fn ( ) . mockResolvedValue ( { status : 200 , ok : true , text : async ( ) => '{"code":200}' } ) ,
184+ } ;
185+ await client . init ( apiKey , { httpClient, autocapture : false } ) . promise ;
186+ const customFetch = MockedRemoteConfigClient . mock . calls [ 0 ] [ 4 ] as core . RemoteConfigCustomFetch ;
187+ const request : core . RemoteConfigFetchRequest = {
188+ url : 'https://example.com/config' ,
189+ method : 'GET' ,
190+ headers : { } ,
191+ signal : new AbortController ( ) . signal ,
192+ } ;
193+ await customFetch ( request ) ;
194+ expect ( httpClient . send ) . toHaveBeenLastCalledWith ( request ) ;
195+ await ( client . config . diagnosticsClient as DiagnosticsClient ) . fetch ( {
196+ tags : { } ,
197+ histogram : { } ,
198+ counters : { } ,
199+ events : [ ] ,
200+ } ) ;
201+ expect ( httpClient . send ) . toHaveBeenLastCalledWith (
202+ expect . objectContaining ( {
203+ url : expect . stringContaining ( 'diagnostics.' ) ,
204+ method : 'POST' ,
205+ } ) ,
206+ ) ;
207+ client . setTransport ( 'beacon' ) ;
208+ await client . config . transportProvider . send ( 'https://example.com/events' , { api_key : apiKey , events : [ ] } ) ;
209+ expect ( httpClient . send ) . toHaveBeenLastCalledWith ( expect . objectContaining ( { url : 'https://example.com/events' } ) ) ;
210+ } ) ;
211+
181212 test ( 'should pass remoteConfig.serverUrl to RemoteConfigClient when provided' , async ( ) => {
182213 const customServerUrl = 'https://my-proxy.com/remote-config' ;
183214
@@ -192,6 +223,7 @@ describe('browser-client', () => {
192223 expect . anything ( ) , // loggerProvider
193224 'US' , // default serverZone
194225 customServerUrl , // our custom URL
226+ undefined , // default config transport
195227 ) ;
196228 } ) ;
197229
@@ -423,6 +455,8 @@ describe('browser-client', () => {
423455 enabled : expectedEnabled ,
424456 sampleRate : expectedSampleRate ,
425457 } ,
458+ undefined ,
459+ undefined ,
426460 ) ;
427461
428462 // Verify that the diagnostics config was applied
@@ -2408,7 +2442,7 @@ describe('browser-client', () => {
24082442 createTransport . mockClear ( ) ;
24092443 client . setTransport ( 'xhr' ) ;
24102444
2411- expect ( createTransport ) . toHaveBeenCalledWith ( 'xhr' ) ;
2445+ expect ( createTransport ) . toHaveBeenCalledWith ( 'xhr' , undefined ) ;
24122446 } ) ;
24132447
24142448 test ( 'should keep custom endpoint compression setting when switching transport' , async ( ) => {
@@ -2422,7 +2456,7 @@ describe('browser-client', () => {
24222456 createTransport . mockClear ( ) ;
24232457 client . setTransport ( 'xhr' ) ;
24242458
2425- expect ( createTransport ) . toHaveBeenCalledWith ( 'xhr' ) ;
2459+ expect ( createTransport ) . toHaveBeenCalledWith ( 'xhr' , undefined ) ;
24262460 } ) ;
24272461
24282462 test ( 'should defer set transport' , ( ) => {
0 commit comments