Skip to content

Commit 46db30a

Browse files
test: test IntSlider bug to avoid regression
test #3597
1 parent 511663a commit 46db30a

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

.github/workflows/tests.yml

+2
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ jobs:
105105
python -m pip install --upgrade pip
106106
pip install file://$PWD/python/ipywidgets#egg=ipywidgets[test]
107107
- name: Test with pytest
108+
env:
109+
SOLARA_TEST_RUNNERS: "jupyter_notebook,jupyter_lab"
108110
run: |
109111
pip install pytest
110112
cd python/ipywidgets
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import playwright.async_api
2+
from IPython.display import display
3+
4+
5+
def center(locator):
6+
box = locator.bounding_box()
7+
x, y = box["x"] + box["width"] / 2, box["y"] + box["height"] / 2
8+
return x, y
9+
10+
11+
def test_slider_tap(ipywidgets_runner, page_session: playwright.sync_api.Page):
12+
def kernel():
13+
import ipywidgets as widgets
14+
15+
slider = widgets.IntSlider(
16+
continuous_update=False,
17+
)
18+
text = widgets.HTML(value="Nothing happened")
19+
20+
def echo(change):
21+
if change["new"] > 0:
22+
text.value = "slider is greater than 0"
23+
else:
24+
text.value = "slider is 0"
25+
26+
slider.observe(echo, names="value")
27+
slider.add_class("slider-test")
28+
text.add_class("text-test")
29+
display(slider)
30+
display(text)
31+
32+
ipywidgets_runner(kernel)
33+
text = page_session.locator(".text-test")
34+
slider = page_session.wait_for_selector(".slider-test")
35+
x, y = center(slider)
36+
page_session.mouse.click(x, y)
37+
text.locator("text=slider is greater than 0").wait_for()

python/ipywidgets/setup.cfg

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ test =
4747
pytest>=3.6.0
4848
pytest-cov
4949
pytz
50+
solara[pytest]
5051

5152
[options.package_data]
5253
ipywidgets =

0 commit comments

Comments
 (0)