Refactor test_evnt_actions_throttle_debounce to be more forgiving#5824
Merged
adhami3310 merged 1 commit intomainfrom Sep 25, 2025
Merged
Refactor test_evnt_actions_throttle_debounce to be more forgiving#5824adhami3310 merged 1 commit intomainfrom
test_evnt_actions_throttle_debounce to be more forgiving#5824adhami3310 merged 1 commit intomainfrom
Conversation
Allow exp_events (-2 / +1) throttle events to be considered a test pass as long as they're followed by the debounce event as the final event.
Contributor
There was a problem hiding this comment.
Greptile Overview
Summary
This PR refactors the test_event_actions_throttle_debounce test to be more resilient to timing-related race conditions that can occur in throttle/debounce event testing.
Key changes:
- Extracted a
_backend_statehelper function to eliminate code duplication - Improved test logic to wait specifically for the debounce event and then validate throttle event counts within an acceptable range (±2/+1 events)
- Added debugging output to help with future test failures
- Removed dependency on the
poll_for_orderfixture in favor of direct state polling
The refactoring addresses inherent race conditions in timing-dependent tests while maintaining the core test validation logic.
Confidence Score: 4/5
- This PR is safe to merge with minimal risk
- The changes improve test reliability by handling race conditions more gracefully. The code refactoring reduces duplication and maintains existing functionality. Only minor style issue with print statement usage instead of logging.
- No files require special attention
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| tests/integration/test_event_actions.py | 4/5 | Refactored throttle/debounce test to handle race conditions more gracefully with acceptable timing tolerances. Minor style issue with print statement usage. |
Sequence Diagram
sequenceDiagram
participant Test as test_event_actions_throttle_debounce
participant Driver as WebDriver
participant App as TestEventAction App
participant State as EventActionState
Test->>Driver: Find throttle button
Test->>Driver: Find debounce button
loop For 2 seconds (exp_events * 0.2s)
Test->>Driver: Click throttle button
Driver->>App: Throttled onClick event
App->>State: on_click_throttle() (maybe)
Test->>Driver: Click debounce button
Driver->>App: Debounced onClick event (cancelled)
end
Note over App,State: Final debounce event fires after 200ms delay
App->>State: on_click_debounce()
Test->>App: Poll for debounce event
App->>Test: Wait until debounce received
Test->>App: Get final state
App->>Test: Return event order list
Test->>Test: Count throttle events
Test->>Test: Assert (exp_events-2) <= actual <= (exp_events+1)
Test->>Test: Assert final order = [throttle_events...] + [debounce_event]
1 file reviewed, 1 comment
CodSpeed Performance ReportMerging #5824 will not alter performanceComparing Summary
|
adhami3310
approved these changes
Sep 25, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Allow exp_events (-2 / +1) throttle events to be considered a test pass as long as they're followed by the debounce event as the final event.