From fa1668c9f914dc12c3650f111271cda391c9a061 Mon Sep 17 00:00:00 2001 From: "Maarten A. Breddels" Date: Wed, 6 Sep 2023 09:15:54 +0200 Subject: [PATCH] test: support serialization of event data for a mouse click We did not add tests in #76. --- tests/ui/test_events.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/ui/test_events.py b/tests/ui/test_events.py index d7d4278..d58b1b2 100644 --- a/tests/ui/test_events.py +++ b/tests/ui/test_events.py @@ -36,3 +36,26 @@ def on_click_inner(*ignore): inner_sel.click() page_session.locator("text=Clicked").wait_for() mock_outer.assert_called_once() + + +def test_mouse_event(solara_test, page_session: playwright.sync_api.Page): + div = vue.Html(tag="div", children=["Click Me!"]) + last_event_data = None + + def on_click(widget, event, data): + nonlocal last_event_data + last_event_data = data + div.children = ["Clicked"] + + div.on_event("click", on_click) + display(div) + + # click in the div + box = page_session.locator("text=Click Me!").bounding_box() + assert box is not None + page_session.mouse.click(box["x"], box["y"]) + + page_session.locator("text=Clicked").wait_for() + assert last_event_data is not None + assert last_event_data["x"] == box["x"] + assert last_event_data["y"] == box["y"]