@@ -11,6 +11,7 @@ describe('Devbox (New API)', () => {
1111 beforeEach ( ( ) => {
1212 // Create mock client instance with proper structure
1313 mockClient = {
14+ baseURL : 'https://api.runloop.ai' ,
1415 devboxes : {
1516 createAndAwaitRunning : jest . fn ( ) ,
1617 retrieve : jest . fn ( ) ,
@@ -303,6 +304,23 @@ describe('Devbox (New API)', () => {
303304 expect ( url ) . toBe ( 'https://3000-mykey456.tunnel.runloop.ai' ) ;
304305 } ) ;
305306
307+ it ( 'should derive tunnel domain from client baseURL' , async ( ) => {
308+ mockClient . baseURL = 'https://api.runloop.pro' ;
309+ const mockTunnel = {
310+ tunnel_key : 'abc123xyz' ,
311+ auth_mode : 'open' as const ,
312+ create_time_ms : Date . now ( ) ,
313+ } ;
314+ const dataWithTunnel = { ...mockDevboxData , tunnel : mockTunnel } ;
315+ mockClient . devboxes . retrieve . mockResolvedValue ( dataWithTunnel ) ;
316+
317+ const url = await devbox . getTunnelUrl ( 8080 ) ;
318+
319+ expect ( url ) . toBe ( 'https://8080-abc123xyz.tunnel.runloop.pro' ) ;
320+
321+ mockClient . baseURL = 'https://api.runloop.ai' ;
322+ } ) ;
323+
306324 it ( 'should throw RunloopError when no tunnel has been enabled' , async ( ) => {
307325 const dataWithoutTunnel = { ...mockDevboxData , tunnel : null } ;
308326 mockClient . devboxes . retrieve . mockResolvedValue ( dataWithoutTunnel ) ;
0 commit comments