-
Notifications
You must be signed in to change notification settings - Fork 948
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: test IntSlider bug to avoid regression
test #3597
- Loading branch information
1 parent
511663a
commit 46db30a
Showing
3 changed files
with
40 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
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,37 @@ | ||
import playwright.async_api | ||
from IPython.display import display | ||
|
||
|
||
def center(locator): | ||
box = locator.bounding_box() | ||
x, y = box["x"] + box["width"] / 2, box["y"] + box["height"] / 2 | ||
return x, y | ||
|
||
|
||
def test_slider_tap(ipywidgets_runner, page_session: playwright.sync_api.Page): | ||
def kernel(): | ||
import ipywidgets as widgets | ||
|
||
slider = widgets.IntSlider( | ||
continuous_update=False, | ||
) | ||
text = widgets.HTML(value="Nothing happened") | ||
|
||
def echo(change): | ||
if change["new"] > 0: | ||
text.value = "slider is greater than 0" | ||
else: | ||
text.value = "slider is 0" | ||
|
||
slider.observe(echo, names="value") | ||
slider.add_class("slider-test") | ||
text.add_class("text-test") | ||
display(slider) | ||
display(text) | ||
|
||
ipywidgets_runner(kernel) | ||
text = page_session.locator(".text-test") | ||
slider = page_session.wait_for_selector(".slider-test") | ||
x, y = center(slider) | ||
page_session.mouse.click(x, y) | ||
text.locator("text=slider is greater than 0").wait_for() |
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 |
---|---|---|
|
@@ -47,6 +47,7 @@ test = | |
pytest>=3.6.0 | ||
pytest-cov | ||
pytz | ||
solara[pytest] | ||
|
||
[options.package_data] | ||
ipywidgets = | ||
|