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

Add UI tests #5764

Merged
merged 5 commits into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
47 changes: 47 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,50 @@ jobs:
run: |
conda activate test-environment
codecov
ui_test_suite:
name: UI tests on ${{ matrix.os }} with Python 3.9
needs: [pre_commit]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
hoxbro marked this conversation as resolved.
Show resolved Hide resolved
timeout-minutes: 60
defaults:
run:
shell: bash -el {0}
env:
DESC: "Python ${{ matrix.python-version }} tests"
PYTHONIOENCODING: "utf-8"
PANEL_LOG_LEVEL: info
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SETUPTOOLS_ENABLE_FEATURES: "legacy-editable"
# Without this env var `doit env_create ...` uses by default
# the `pyviz` channel, except that we don't want to configure
# it as one of the sources.
PYCTDEV_SELF_CHANNEL: "pyviz/label/dev"
steps:
- uses: holoviz-dev/holoviz_tasks/install@v0.1a13
with:
name: ui_test_suite
python-version: 3.9
channels: pyviz/label/dev,bokeh,conda-forge,nodefaults
envs: "-o recommended -o tests -o build"
cache: true
playwright: true
conda-mamba: mamba
id: install
- name: doit env_capture
run: |
conda activate test-environment
doit env_capture
- name: doit test_ui
run: |
conda activate test-environment
doit test_ui
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: ./coverage.xml
flags: ui-tests
fail_ci_if_error: false # optional (default = false)
17 changes: 2 additions & 15 deletions holoviews/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
import pytest
from panel.tests.conftest import server_cleanup, port, pytest_addoption, pytest_collection_modifyitems # noqa

from panel.io import state


@pytest.fixture(autouse=True)
def server_cleanup():
"""
Clean up after test fails
"""
try:
yield
finally:
state.kill_all_servers()
state._indicators.clear()
state._locations.clear()
state.cache.clear()
CUSTOM_MARKS = ('ui',)
29 changes: 29 additions & 0 deletions holoviews/tests/ui/bokeh/test_layout.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import time

import pytest

pytestmark = pytest.mark.ui
hoxbro marked this conversation as resolved.
Show resolved Hide resolved

from panel.io.server import serve
from panel.widgets import Button


def test_button_click(page, port):
button = Button(name='Click')

events = []
def cb(event):
events.append(event)
button.on_click(cb)

serve(button, port=port, threaded=True, show=False)

time.sleep(0.2)

page.goto(f"http://localhost:{port}")

page.click('.bk-btn')

time.sleep(0.1)

assert len(events) == 1
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ filterwarnings = [
"ignore:Creating an ndarray from ragged nested sequences:numpy.VisibleDeprecationWarning:holoviews.core.data.spatialpandas"
]

[tool.coverage]
run.concurrency = ["greenlet"]

[tool.ruff]
target-version = "py37"

Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
]

extras_require['tests_nb'] = ['nbval']
extras_require['ui'] = ['playwright', 'pytest-playwright']

# Notebook dependencies
extras_require["notebook"] = ["ipython >=5.4.0", "notebook"]
Expand Down
9 changes: 8 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

[tox]
# python version test group extra envs extra commands
envlist = {py37,py38,py39,py310,py311}-{unit,examples,all_recommended,simple}-{default}-{dev,pkg}
envlist = {py37,py38,py39,py310,py311}-{unit,ui,examples,all_recommended,simple}-{default}-{dev,pkg}

[_simple]
description = Install holoviews without any optional dependencies
Expand All @@ -25,6 +25,11 @@ description = Run unit tests with coverage and all the optional test dependencie
deps = .[tests_gpu]
commands = pytest holoviews --cov=./holoviews -vv

[_ui]
description = Run UI tests
deps = .[tests, ui]
commands = pytest holoviews --cov=./holoviews --cov-report=xml --ui --browser chromium

[_examples]
description = Test that default examples run
deps = .[examples_tests]
Expand All @@ -50,12 +55,14 @@ commands = examples-pkg: {[_pkg]commands}
unit: {[_unit]commands}
unit_core: {[_unit_core]commands}
unit_gpu: {[_unit_gpu]commands}
ui: {[_ui]commands}
simple: {[_simple]commands}
examples: {[_examples]commands}
all_recommended: {[_all_recommended]commands}

deps = unit: {[_unit]deps}
unit_core: {[_unit_core]deps}
unit_gpu: {[_unit_gpu]deps}
ui: {[_ui]commands}
examples: {[_examples]deps}
all_recommended: {[_all_recommended]deps}