Skip to content

Commit af278b7

Browse files
test(desktop): pin inbox order for calls persisted within one millisecond
1 parent cbb5970 commit af278b7

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

‎apps/sim/lib/desktop/application/executor.integration.ts‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,27 @@ describe.runIf(Boolean(redisUrl))('desktop background executor protocol', () =>
883883
).toEqual([first, second, vfs])
884884
})
885885

886+
it('lists calls persisted within the same millisecond in persistence order', async () => {
887+
const desktop = await signedInDesktop()
888+
const run = await boundRun(desktop)
889+
/** Ids sorted against persistence order, so an id tiebreak would reverse them. */
890+
const persisted = [generateId(), generateId(), generateId()].sort().reverse()
891+
await db.insert(copilotAsyncToolCalls).values(
892+
persisted.map((toolCallId, index) => ({
893+
runId: run.runId,
894+
toolCallId,
895+
toolName: 'browser_click',
896+
args: { ref: 'e1' },
897+
pickupDeadlineAt: sql`now() + interval '1 minute'`,
898+
createdAt: sql`date_trunc('milliseconds', localtimestamp) + ${index + 1} * interval '1 microsecond'`,
899+
}))
900+
)
901+
902+
expect(
903+
(await inbox(desktop)).items.map((item) => item.kind === 'call' && item.toolCallId)
904+
).toEqual(persisted)
905+
})
906+
886907
it('counts the device online after a pull or a stream open, and keeps it online when the stream closes', async () => {
887908
const desktop = await signedInDesktop()
888909
const presenceKey = `desktop:presence:${desktop.deviceId}`

0 commit comments

Comments
 (0)