Skip to content

test: seed the stateful activity mock instead of scripting handlers - #613

Merged
zgeoff merged 3 commits into
mainfrom
idle-client-mock-db
Jul 16, 2026
Merged

test: seed the stateful activity mock instead of scripting handlers#613
zgeoff merged 3 commits into
mainfrom
idle-client-mock-db

Conversation

@zgeoff

@zgeoff zgeoff commented Jul 16, 2026

Copy link
Copy Markdown
Owner

Description

Moves idle-client's happy-path worker tests off per-test scripted oRPC handlers and onto the stateful @vers/mock-services backend: tests seed db collections and authenticate with a bearer whose subject owns the seeded avatar, so resyncs, continuations, and appends hit the same state transitions the real service applies.

  • Migrated: all 7 resync-handler tests, 2 of 3 continuation tests, the client-message resync test; input captures became mock-db reads.
  • The mock's trackActivityProgress now closes the stream (row → stopped) when a batch ends on a terminal checkpoint, matching the real service — without it a fast-forward's continuation start conflicts with its own just-finished row.
  • Stays scripted per the testing conventions: transport failures, unmodeled error codes, scripted call sequences, and request-field captures (run-fast-forward, create-checkpoint-submitter, worker-runtime's incidental stub).

Testing

  • bun run typecheck passes
  • bun run test passes
  • bun run lint passes
  • New tests added for new functionality

Review in cubic

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: d1ea504a-d3dc-4d40-91c1-32b7c1a1afe4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Changes

Activity integration behavior

Layer / File(s) Summary
Terminal activity progress
libs/testing/mock-services/src/activity/track-activity-progress.ts
The mock marks activity rows as stopped when the final checkpoint is completed or failed.
Authenticated resync flow
libs/game/idle-client/src/worker/handle-client-message.test.ts, libs/game/idle-client/src/worker/handle-request-resync-message.test.ts
Resync tests now use authenticated ORPC clients, seeded database activity rows, deterministic submitter flushing, and persisted checkpoint assertions.
Continuation activity selection
libs/game/idle-client/src/worker/run-continuation.test.ts
Continuation tests validate minted and conflicting active activity rows through the authenticated ORPC and mock database flow.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • zgeoff/vers#567: Related terminal activity stopping and appended-anchor handling.
  • zgeoff/vers#580: Related activity simulation and checkpoint submission wiring.
  • zgeoff/vers#609: Related idle-client resync and broadcast behavior.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: moving tests to a stateful activity mock instead of scripted handlers.
Description check ✅ Passed The description is directly related to the changeset and accurately describes the migration to the stateful mock backend.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch idle-client-mock-db

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@libs/game/idle-client/src/worker/handle-request-resync-message.test.ts`:
- Around line 41-54: Update the test setup’s scheduleFlush callback and returned
flush helper to queue every scheduled flush callback instead of overwriting
capturedFlush. Ensure ctx.flush() drains all queued callbacks, preserving
multi-activity work even when later scheduleFlush calls occur before flushing.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 573fe20f-c7e0-47bb-9ea2-a836ed995d53

📥 Commits

Reviewing files that changed from the base of the PR and between cadb9ce and 0712654.

📒 Files selected for processing (4)
  • libs/game/idle-client/src/worker/handle-client-message.test.ts
  • libs/game/idle-client/src/worker/handle-request-resync-message.test.ts
  • libs/game/idle-client/src/worker/run-continuation.test.ts
  • libs/testing/mock-services/src/activity/track-activity-progress.ts

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread libs/testing/mock-services/src/activity/track-activity-progress.ts Outdated
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