MCPcopy
hub / github.com/reflex-dev/reflex / poll_assert_event_order

Function poll_assert_event_order

tests/integration/utils.py:114–138  ·  view source on GitHub ↗

Poll until the actual event order matches the expected event order, accounting for sets in the expected order. Args: driver: WebDriver instance. exp_event_order: the expected events recorded in the State, where some entries may be sets of events that can occur in any order.

(
    driver: WebDriver,
    exp_event_order: Sequence[str | set[str]],
    xpath: str = '//*[@id="event_order"]/p',
)

Source from the content-addressed store, hash-verified

112
113
114def poll_assert_event_order(
115 driver: WebDriver,
116 exp_event_order: Sequence[str | set[str]],
117 xpath: str = '//*[@id="event_order"]/p',
118) -> None:
119 """Poll until the actual event order matches the expected event order, accounting for sets in the expected order.
120
121 Args:
122 driver: WebDriver instance.
123 exp_event_order: the expected events recorded in the State, where some entries may be sets of events that can occur in any order.
124 xpath: The XPath to the event order elements.
125
126 Raises:
127 AssertionError: if the actual event order does not match the expected event order after polling.
128 """
129 n_exp_events = n_expected_events(exp_event_order)
130
131 def _has_number_of_expected_events():
132 event_elements = driver.find_elements(By.XPATH, xpath)
133 return len(event_elements) == n_exp_events
134
135 AppHarness._poll_for(_has_number_of_expected_events)
136
137 event_elements = driver.find_elements(By.XPATH, xpath)
138 assert_event_order([elem.text for elem in event_elements], exp_event_order)
139
140
141# Type alias for an ordering rule: ((event_a, occurrence_a), (event_b, occurrence_b)).

Calls 3

n_expected_eventsFunction · 0.85
assert_event_orderFunction · 0.85
_poll_forMethod · 0.80

Tested by 7

test_event_actionsFunction · 0.72
test_event_chain_clickFunction · 0.72
test_event_chain_on_loadFunction · 0.72
test_on_load_navigateFunction · 0.68