Skip to content

Commit 2d25022

Browse files
committed
fix(tests): wait for durable text before recovery faults
1 parent 79a3717 commit 2d25022

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

‎apps/sim/lib/mothership/request/lifecycle/unattended.integration.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ import { ABANDONED_RUN_CURSOR_KEY } from '@/lib/mothership/async-runs/orphaned-r
139139
import { chatPubSub } from '@/lib/mothership/chat-status'
140140
import { takeOverAbandonedRuns } from '@/lib/mothership/request/application/abandoned-runs'
141141
import { startUnattendedTurn } from '@/lib/mothership/request/lifecycle/unattended'
142+
import { readEvents } from '@/lib/mothership/request/session/buffer'
142143
import {
143144
chatStreamLockKey,
144145
StreamControllerSupersededError,
@@ -316,6 +317,16 @@ describe.runIf(Boolean(redisUrl))('an unattended turn with no browser attached',
316317
expect(await start()).toBe('duplicate')
317318

318319
for (let death = 1; death <= 3; death++) {
320+
await waitFor(
321+
async () =>
322+
(await readEvents(occurrenceId, '0')).some(
323+
(event) =>
324+
event.type === 'text' &&
325+
event.payload.channel === 'assistant' &&
326+
event.payload.text === parts[death - 1]
327+
),
328+
'the current leg text to persist before the process dies'
329+
)
319330
await killController(chatId, occurrenceId)
320331
await takeOverUntilReattached(occurrenceId)
321332
if (death < 3) await waitFor(async () => worker.open.has(occurrenceId), 'the next leg')

0 commit comments

Comments
 (0)