Skip to content

Commit

Permalink
test: support serialization of event data for a mouse click
Browse files Browse the repository at this point in the history
We did not add tests in #76.
  • Loading branch information
maartenbreddels committed Sep 6, 2023
1 parent 5f7c469 commit fa1668c
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/ui/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

0 comments on commit fa1668c

Please sign in to comment.