@@ -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,24 @@ 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+ const mockTunnel = {
309+ tunnel_key : 'abc123xyz' ,
310+ auth_mode : 'open' as const ,
311+ create_time_ms : Date . now ( ) ,
312+ } ;
313+ const dataWithTunnel = { ...mockDevboxData , tunnel : mockTunnel } ;
314+ mockClient . devboxes . retrieve . mockResolvedValue ( dataWithTunnel ) ;
315+
316+ mockClient . baseURL = 'https://api.runloop.pro' ;
317+ expect ( await devbox . getTunnelUrl ( 8080 ) ) . toBe ( 'https://8080-abc123xyz.tunnel.runloop.pro' ) ;
318+
319+ mockClient . baseURL = 'http://127.0.0.1:8080' ;
320+ expect ( await devbox . getTunnelUrl ( 8080 ) ) . toBe ( 'https://8080-abc123xyz.tunnel.127.0.0.1' ) ;
321+
322+ mockClient . baseURL = 'https://api.runloop.ai' ;
323+ } ) ;
324+
306325 it ( 'should throw RunloopError when no tunnel has been enabled' , async ( ) => {
307326 const dataWithoutTunnel = { ...mockDevboxData , tunnel : null } ;
308327 mockClient . devboxes . retrieve . mockResolvedValue ( dataWithoutTunnel ) ;
0 commit comments