@@ -8,11 +8,13 @@ vi.mock("../env.js");
88vi . mock ( "../telemetry/telemetryService.js" ) ;
99vi . mock ( "../ui/index.js" ) ;
1010vi . mock ( "../util/git.js" ) ;
11+ vi . mock ( "../util/exit.js" ) ;
1112
1213const mockWorkos = vi . mocked ( await import ( "../auth/workos.js" ) ) ;
1314const mockEnv = vi . mocked ( await import ( "../env.js" ) ) ;
1415const mockGit = vi . mocked ( await import ( "../util/git.js" ) ) ;
1516const mockStartRemoteTUIChat = vi . mocked ( await import ( "../ui/index.js" ) ) ;
17+ const mockExit = vi . mocked ( await import ( "../util/exit.js" ) ) ;
1618
1719// Mock fetch globally
1820const mockFetch = vi . fn ( ) ;
@@ -62,6 +64,10 @@ describe("remote command", () => {
6264
6365 mockFetch . mockResolvedValue ( {
6466 ok : true ,
67+ headers : {
68+ get : ( name : string ) =>
69+ name === "content-type" ? "application/json" : null ,
70+ } ,
6571 json : async ( ) => ( {
6672 id : "test-agent-id" ,
6773 url : "ws://test-url.com" ,
@@ -70,6 +76,9 @@ describe("remote command", () => {
7076 } ) ;
7177
7278 mockStartRemoteTUIChat . startRemoteTUIChat . mockResolvedValue ( { } as any ) ;
79+
80+ // Mock gracefulExit to prevent process.exit during tests
81+ mockExit . gracefulExit . mockResolvedValue ( undefined ) ;
7382 } ) ;
7483
7584 it ( "should include idempotency key in request body when provided" , async ( ) => {
@@ -151,10 +160,18 @@ describe("remote command", () => {
151160 mockFetch
152161 . mockResolvedValueOnce ( {
153162 ok : true ,
163+ headers : {
164+ get : ( name : string ) =>
165+ name === "content-type" ? "application/json" : null ,
166+ } ,
154167 json : async ( ) => ( { url : "ws://tunnel-url.com" , port : 9090 } ) ,
155168 } )
156169 . mockResolvedValue ( {
157170 ok : true ,
171+ headers : {
172+ get : ( name : string ) =>
173+ name === "content-type" ? "application/json" : null ,
174+ } ,
158175 json : async ( ) => ( {
159176 id : "test-agent-id" ,
160177 url : "ws://test-url.com" ,
@@ -187,6 +204,10 @@ describe("remote command", () => {
187204
188205 mockFetch . mockResolvedValueOnce ( {
189206 ok : true ,
207+ headers : {
208+ get : ( name : string ) =>
209+ name === "content-type" ? "application/json" : null ,
210+ } ,
190211 json : async ( ) => tunnelResponse ,
191212 } ) ;
192213
0 commit comments