Skip to content

Refactor test_evnt_actions_throttle_debounce to be more forgiving#5824

Merged
adhami3310 merged 1 commit intomainfrom
masenf/test-event-actions-flake
Sep 25, 2025
Merged

Refactor test_evnt_actions_throttle_debounce to be more forgiving#5824
adhami3310 merged 1 commit intomainfrom
masenf/test-event-actions-flake

Conversation

@masenf
Copy link
Copy Markdown
Collaborator

@masenf masenf commented Sep 25, 2025

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.

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.
Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

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_state helper 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_order fixture 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]
Loading

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment thread tests/integration/test_event_actions.py
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Sep 25, 2025

CodSpeed Performance Report

Merging #5824 will not alter performance

Comparing masenf/test-event-actions-flake (a491be0) with main (104bcbe)

Summary

✅ 8 untouched

@adhami3310 adhami3310 merged commit 269723b into main Sep 25, 2025
41 checks passed
@adhami3310 adhami3310 deleted the masenf/test-event-actions-flake branch September 25, 2025 17:59
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