-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dd236a3
commit e0b7af2
Showing
1 changed file
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import ipywidgets | ||
import playwright.sync_api | ||
import pytest | ||
from solara import display | ||
|
||
import ipyreact | ||
|
||
|
||
def test_children_text(solara_test, page_session: playwright.sync_api.Page): | ||
def on_click(event_data): | ||
b.children = ["Clicked"] | ||
|
||
b = ipyreact.Widget( | ||
_type="button", | ||
events={"onClick": on_click}, | ||
children=["Click me"], | ||
props={"class": "test-button"}, | ||
) | ||
|
||
display(b) | ||
button = page_session.locator(".test-button") | ||
button.click() | ||
page_session.locator(".test-button >> text=Clicked").wait_for() | ||
|
||
|
||
def test_children_react(solara_test, page_session: playwright.sync_api.Page): | ||
def on_click(event_data): | ||
b.children = [ | ||
ipyreact.Widget( | ||
_type="span", props={"className": "test-span"}, children=["direct child"] | ||
) | ||
] | ||
|
||
b = ipyreact.Widget( | ||
_type="button", | ||
events={"onClick": on_click}, | ||
children=["Click me"], | ||
props={"className": "test-button"}, | ||
) | ||
|
||
display(b) | ||
button = page_session.locator(".test-button") | ||
button.click() | ||
# direct child, not a grandchild (e.g. extra div around it) | ||
page_session.locator(".test-button > .test-span").wait_for() | ||
|
||
|
||
@pytest.mark.xfail | ||
def test_children_ipywidgets(solara_test, page_session: playwright.sync_api.Page): | ||
def on_click(event_data): | ||
html = ipywidgets.HTML(value="not a direct child") | ||
html.add_class("test-html") | ||
b.children = [html] | ||
|
||
b = ipyreact.Widget( | ||
_type="button", | ||
events={"onClick": on_click}, | ||
children=["Click me"], | ||
props={"className": "test-button"}, | ||
) | ||
|
||
display(b) | ||
button = page_session.locator(".test-button") | ||
button.click() | ||
# not per se a direct child | ||
page_session.locator(".test-button >> .test-html").wait_for() |