Skip to content

fix: make the close/reset timer tests deterministic - #394

Merged
abelonogov-ld merged 1 commit into
mainfrom
andrey/unit-test-fixes
Aug 21, 2026
Merged

fix: make the close/reset timer tests deterministic#394
abelonogov-ld merged 1 commit into
mainfrom
andrey/unit-test-fixes

Conversation

@abelonogov-ld

@abelonogov-ld abelonogov-ld commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

closeCancelsPendingTimer and resetCancelsPendingTimer slept for a fraction of the debounce window and then asserted the timer never fired. On a loaded runner that sleep can overshoot the window, and once the timer has begun firing neither close() nor reset() can recall it, so the tests failed for reasons unrelated to the behaviour they cover.

Both now drive a ManualTaskExecutor instead of sleeping, asserting that the scheduled task was cancelled and that draining the queue runs nothing.

Requirements

  • I have added test coverage for new or changed functionality
  • I have followed the repository's pull request submission guidelines
  • I have validated my changes against all supported platform versions

Related issues

Provide links to any issues in this repository or elsewhere relating to this pull request.

Describe the solution you've provided

Provide a clear and concise description of what you expect to happen.

Describe alternatives you've considered

Provide a clear and concise description of any alternative solutions or features you've considered.

Additional context

Add any other context about the pull request here.


Note

Overview
Makes closeCancelsPendingTimer and resetCancelsPendingTimer deterministic by driving a ManualTaskExecutor instead of sleeping a fraction of the debounce window.

Those sleeps could overshoot on a loaded runner, so the timer fired before close()/reset() could cancel it. The tests now assert the scheduled task was cancelled and that draining the queue runs nothing.

Reviewed by Cursor Bugbot for commit 0160533. Bugbot is set up for automated code reviews on this repo. Configure here.

closeCancelsPendingTimer and resetCancelsPendingTimer slept for a fraction
of the debounce window and then asserted the timer never fired. On a loaded
runner that sleep can overshoot the window, and once the timer has begun
firing neither close() nor reset() can recall it, so the tests failed for
reasons unrelated to the behaviour they cover.

Both now drive a ManualTaskExecutor instead of sleeping, asserting that the
scheduled task was cancelled and that draining the queue runs nothing.

Co-authored-by: Cursor <cursoragent@cursor.com>
@abelonogov-ld
abelonogov-ld requested a review from a team as a code owner August 21, 2026 20:06
@abelonogov-ld
abelonogov-ld merged commit 984d2e6 into main Aug 21, 2026
8 checks passed
@abelonogov-ld
abelonogov-ld deleted the andrey/unit-test-fixes branch August 21, 2026 20:19
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.

2 participants