55 * hanging until a watchdog calls it "hung". Runs against real PostgreSQL and Redis: the call is
66 * persisted and dispatched by the production stream handlers, the desktop claims it through the
77 * authorize route and reports through the confirm route.
8+ * Cases own separate calls and waiters; the shared authorization and parent-run fixtures stay fixed.
89 */
910import { deleteWorkspaceFixture , insertWorkspaceFixture } from '@sim/db/testing/workspace-fixtures'
1011import { authMock , authMockFns } from '@sim/testing/mocks/auth.mock'
11- import { afterAll , beforeAll , describe , expect , it , vi } from 'vitest'
12+ import { afterAll , beforeAll , describe , it , vi } from 'vitest'
1213
1314const { redisUrl, inheritedEnv } = await vi . hoisted ( async ( ) => {
1415 const { readTestRedisUrl } = await import ( '@sim/db/testing/test-infrastructure' )
@@ -69,7 +70,7 @@ afterAll(async () => {
6970 }
7071} )
7172
72- describe . runIf ( Boolean ( redisUrl ) ) ( 'a desktop tool call nobody picks up' , ( ) => {
73+ describe . runIf ( Boolean ( redisUrl ) ) . concurrent ( 'a desktop tool call nobody picks up' , ( ) => {
7374 const userId = generateId ( )
7475 const workspaceId = generateId ( )
7576 const chatId = generateId ( )
@@ -181,12 +182,13 @@ describe.runIf(Boolean(redisUrl))('a desktop tool call nobody picks up', () => {
181182 await db . delete ( user ) . where ( eq ( user . id , userId ) )
182183 } )
183184
184- it . each ( [
185+ it . for ( [
185186 [ 'browser_snapshot' , { } ] ,
186187 [ 'terminal' , { operation : 'run' , args : { command : 'ls' } } ] ,
187- ] ) (
188+ ] as const ) (
188189 'tells the agent a %s call never started, and refuses a late pickup' ,
189- async ( toolName , args ) => {
190+ { timeout : TURN_WAIT_MS + 10_000 } ,
191+ async ( [ toolName , args ] , { expect } ) => {
190192 const startedAt = Date . now ( )
191193 const { toolCallId, answer } = await agentCalls ( toolName , args )
192194
@@ -203,13 +205,12 @@ describe.runIf(Boolean(redisUrl))('a desktop tool call nobody picks up', () => {
203205 . where ( eq ( copilotAsyncToolCalls . toolCallId , toolCallId ) )
204206 expect ( row . status ) . toBe ( 'failed' )
205207 expect ( ( await desktopClaims ( toolCallId ) ) . ok ) . toBe ( false )
206- } ,
207- TURN_WAIT_MS + 10_000
208+ }
208209 )
209210
210211 it (
211212 'keeps waiting for a call the desktop picked up in time, past the pickup grace' ,
212- async ( ) => {
213+ async ( { expect } ) => {
213214 const { toolCallId, answer } = await agentCalls ( 'browser_snapshot' , { } )
214215 expect ( ( await desktopClaims ( toolCallId ) ) . status ) . toBe ( 200 )
215216
@@ -229,7 +230,7 @@ describe.runIf(Boolean(redisUrl))('a desktop tool call nobody picks up', () => {
229230
230231 it (
231232 'never lets a stale "not started" report end a call the desktop is running' ,
232- async ( ) => {
233+ async ( { expect } ) => {
233234 const { toolCallId, answer } = await agentCalls ( 'terminal' , {
234235 operation : 'run' ,
235236 args : { command : 'bun run test' } ,
@@ -258,7 +259,7 @@ describe.runIf(Boolean(redisUrl))('a desktop tool call nobody picks up', () => {
258259
259260 it (
260261 'tells the agent a local read nobody picked up never started, for a desktop that claims reads' ,
261- async ( ) => {
262+ async ( { expect } ) => {
262263 const startedAt = Date . now ( )
263264 const { toolCallId, answer } = await agentCalls (
264265 'read_local_file' ,
@@ -277,7 +278,7 @@ describe.runIf(Boolean(redisUrl))('a desktop tool call nobody picks up', () => {
277278
278279 it (
279280 'lets a desktop that claimed a local read keep reading it, past the pickup grace' ,
280- async ( ) => {
281+ async ( { expect } ) => {
281282 const { toolCallId, answer } = await agentCalls (
282283 'grep' ,
283284 { path : 'user-local/Project--mount-1' , pattern : 'TODO' } ,
@@ -302,7 +303,7 @@ describe.runIf(Boolean(redisUrl))('a desktop tool call nobody picks up', () => {
302303
303304 it (
304305 'reads as before for a desktop that does not claim local reads' ,
305- async ( ) => {
306+ async ( { expect } ) => {
306307 const { toolCallId, answer } = await agentCalls ( 'read_local_file' , {
307308 path : '/Users/me/notes.txt' ,
308309 } )
0 commit comments