Skip to content

Commit 2dc2d59

Browse files
committed
test(realtime): use the shared sleep helper in the new join tests
check:utils bans the inline new Promise(setTimeout) form; the two stalled-join tests were the only new offenders.
1 parent f7d6387 commit 2dc2d59

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

apps/realtime/src/handlers/file-doc.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
FILE_DOC_SEED,
88
} from '@sim/realtime-protocol/file-doc'
99
import { ROOM_TYPES } from '@sim/realtime-protocol/rooms'
10+
import { sleep } from '@sim/utils/helpers'
1011
import * as decoding from 'lib0/decoding'
1112
import * as encoding from 'lib0/encoding'
1213
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
@@ -293,7 +294,7 @@ describe('setupWorkspaceFileDocHandlers', () => {
293294
// This join's own authorize saw the pre-revocation state, and the sweep records
294295
// the revocation (later read ticket) while it is still in flight.
295296
commitRoomPermission('user-stale', room, null, beginRoomPermissionRead())
296-
await new Promise((resolve) => setTimeout(resolve, 31_000))
297+
await sleep(31_000)
297298
return { allowed: true, status: 200, workspaceId: 'ws-1', workspacePermission: 'write' }
298299
})
299300

apps/realtime/src/handlers/workspace-invalidation-room.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* @vitest-environment node
33
*/
44
import { ROOM_TYPES } from '@sim/realtime-protocol/rooms'
5+
import { sleep } from '@sim/utils/helpers'
56
import { beforeEach, describe, expect, it, vi } from 'vitest'
67
import type { IRoomManager } from '@/rooms'
78

@@ -185,7 +186,7 @@ describe.each([ROOM_TYPES.WORKSPACE_FILES, ROOM_TYPES.WORKSPACE_TABLES] as const
185186
'admin',
186187
beginRoomPermissionRead()
187188
)
188-
await new Promise((resolve) => setTimeout(resolve, 31_000))
189+
await sleep(31_000)
189190
} else {
190191
// Second call is the re-check's re-resolve: the client leaves during it.
191192
handlers[leaveEvent]({ workspaceId: 'ws-sup' })

0 commit comments

Comments
 (0)