Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: test IntSlider bug to avoid regression #3772

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,12 @@ 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
pytest --cov=ipywidgets ipywidgets
playwright install
pytest --cov=ipywidgets --pyargs ipywidgets

spec:
name: Message Specification
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