MCPcopy Index your code
hub / github.com/reflex-dev/reflex / test_mixed_cond_event_lambda

Function test_mixed_cond_event_lambda

tests/integration/test_event_chain.py:750–778  ·  view source on GitHub ↗

Verify a lambda returning rx.cond with a FunctionVar branch and an EventSpec branch. Each branch is exercised end-to-end: the FunctionVar branch updates a DOM data-attribute via a frontend-only function, and the EventSpec branch dispatches a backend event handler. Args: eve

(event_chain: AppHarness, driver: WebDriver)

Source from the content-addressed store, hash-verified

748
749
750def test_mixed_cond_event_lambda(event_chain: AppHarness, driver: WebDriver):
751 """Verify a lambda returning rx.cond with a FunctionVar branch and an EventSpec branch.
752
753 Each branch is exercised end-to-end: the FunctionVar branch updates a DOM
754 data-attribute via a frontend-only function, and the EventSpec branch
755 dispatches a backend event handler.
756
757 Args:
758 event_chain: AppHarness for the event_chain app
759 driver: selenium WebDriver open to the app
760 """
761 assert_token(event_chain, driver)
762 cond_input = driver.find_element(By.ID, "cond_input")
763 marker = driver.find_element(By.ID, "mixed_cond_marker")
764 btn = driver.find_element(By.ID, "mixed_cond_btn")
765
766 # Default cond_input ("") -> EventSpec branch fires the backend handler.
767 btn.click()
768 poll_assert_event_order(driver, ["event_arg:ev_branch"])
769 assert marker.get_attribute("data-value") == ""
770
771 # Switch to the FunctionVar branch and click again.
772 cond_input.send_keys("fn")
773 assert event_chain.poll_for_content(marker, exp_not_equal="") == "fn"
774 btn.click()
775 AppHarness._poll_for(lambda: marker.get_attribute("data-value") == "fn_branch")
776 assert marker.get_attribute("data-value") == "fn_branch"
777 # Backend event order is unchanged because only the frontend function ran.
778 poll_assert_event_order(driver, ["event_arg:ev_branch"])

Callers

nothing calls this directly

Calls 4

poll_assert_event_orderFunction · 0.90
poll_for_contentMethod · 0.80
_poll_forMethod · 0.80
assert_tokenFunction · 0.70

Tested by

no test coverage detected