Skip to content

Commit

Permalink
test: test IntSlider bug to avoid regression
Browse files Browse the repository at this point in the history
test #3597
  • Loading branch information
maartenbreddels committed May 13, 2023
1 parent 511663a commit 46db30a
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ jobs:
python -m pip install --upgrade pip
pip install file://$PWD/python/ipywidgets#egg=ipywidgets[test]
- name: Test with pytest
env:
SOLARA_TEST_RUNNERS: "jupyter_notebook,jupyter_lab"
run: |
pip install pytest
cd python/ipywidgets
Expand Down
37 changes: 37 additions & 0 deletions python/ipywidgets/ipywidgets/widgets/tests/test_slider.py
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()
1 change: 1 addition & 0 deletions python/ipywidgets/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ test =
pytest>=3.6.0
pytest-cov
pytz
solara[pytest]

[options.package_data]
ipywidgets =
Expand Down

0 comments on commit 46db30a

Please sign in to comment.