Skip to content

test(mecatui): eliminate real polling waits with virtual time - #1919

Merged
JAORMX merged 1 commit into
mainfrom
fix/mcp-polling-test-virtual-time
Sep 25, 2026
Merged

JAORMX merged 1 commit into
mainfrom
fix/mcp-polling-test-virtual-time

Conversation

@JAORMX

@JAORMX JAORMX commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Run the existing open/copy cases in TestMCPAuthorizationOpeningOrCopyingStartsPolling inside isolated testing/synctest bubbles.

This removes the two real three-second polling waits while retaining the production polling command, production interval, injected controller/browser/clipboard fakes, and every existing assertion. No production code or timing configuration changes.

T.Run remains outside each bubble; the model uses the bubble-owned t.Context().

Measured benefit

Same targeted test, forced uncached with -count=1:

Test execution time
Before 6.01 s
After 0.01 s

These are per-test execution times from go test -json, not estimates based on command counts or claims about whole-suite speedup.

Verification

  • Targeted test passed before and after the change.
  • Entire cmd/mecatui/ui package passed.
  • Authorization and broker polling tests passed 20 repetitions under -race:
    go test -race -count=20 -run '^(TestMCPAuthorization|TestMecatuiBrokerPollingLiveness)' -timeout 120s ./cmd/mecatui/ui
  • Mutation check: temporarily routing the recheck to cancellation caused both open/copy cases to fail with rechecks = 0, want 1; the mutation was reverted and the test passed again.
  • Independent test review found no blockers.
  • git diff --check passed.

Scope and readiness

Routine: test-only replacement of wall-clock waiting with the standard library's virtual-time test support. No interface or behavior changes, assertion removal, or documentation changes.

Draft because repository-wide final lint/test/race gates have not been run for this candidate. The focused and package checks above are complete; this PR does not claim completion of the aggregate pre-ready gates.

Execute the existing open/copy polling assertions inside synctest bubbles, preserving the production interval and eliminating real timer waits.

Co-Authored-By: mecatl <[email protected]>
@JAORMX
JAORMX marked this pull request as ready for review September 25, 2026 10:11
@JAORMX
JAORMX merged commit 4acc595 into main Sep 25, 2026
62 of 66 checks passed
@JAORMX
JAORMX deleted the fix/mcp-polling-test-virtual-time branch September 25, 2026 10:21
@toolhive-release-app toolhive-release-app Bot mentioned this pull request Sep 25, 2026
2 tasks
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