Skip to content

test(backend): wait for the named realtime events instead of a frame count - #264

Merged
arrzdev merged 1 commit into
mainfrom
test/realtime-settle-events
Nov 1, 2026
Merged

arrzdev merged 1 commit into
mainfrom
test/realtime-settle-events

Conversation

@arrzdev

@arrzdev arrzdev commented Nov 1, 2026

Copy link
Copy Markdown
Owner

What

The two realtime tests in game.routes.test.ts waited for "any 2 frames" on the watched channel. A late invites-changed beacon from the setup (the accept in openGame()) can land after the channel opens and fill that count, so the resign test sometimes returned before games-changed arrived:

received ['invites-changed', 'game-updated'], expected to contain 'game-updated' and 'games-changed'

settle now takes the events the test expects and waits until all of them have arrived (same 1 s ceiling), then returns every event seen. Both tests in the block use it. No product code changes.

Verification

  • game.routes.test.ts 20 runs in a row (for i in $(seq 1 20); do pnpm exec vitest run src/http/routes/game.routes.test.ts; done): passed 20/20, 49 tests each
  • pnpm typecheck: pass
  • pnpm biome:check: pass
  • pnpm exec turbo run build --filter=@repo/backend...: pass
  • pnpm --filter @repo/backend test:coverage: pass, 343 tests, floors met (All files 94.18 stmts / 84.86 branches / 97.53 funcs / 95.15 lines)

The installed Vitest (4.1.12) has no --repeat flag, so the 20 runs used a shell loop.

…count

A late invites-changed beacon from the setup could fill the frame count
before the event under test arrived, so the resign test failed at random.

@arrzdev arrzdev left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve. settle now waits for the named events, so a late setup beacon can no longer fill the count. Both realtime tests use it, test-only, CI green.

@arrzdev
arrzdev merged commit 3075983 into main Nov 1, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant