Skip to content
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
d173b7c
add initial placeholder file
karangattu May 13, 2025
b75da52
run it on branches starting with run-
karangattu May 13, 2025
86fc60f
just copy over the py-shiny-templates to the examples dir instead
karangattu May 13, 2025
6d8403c
Add dependencies required by example apps
karangattu May 14, 2025
c119aa9
check for shiny-output-error
karangattu May 14, 2025
35ebec9
linting issues
karangattu May 14, 2025
68edee6
skip safe exception tests for output errors
karangattu May 15, 2025
37df231
ignore global_pyplot expected output error
karangattu May 15, 2025
b208724
add relevant comments
karangattu May 15, 2025
aaa2ee4
Merge branch 'main' into run-py-shiny-template-tests
karangattu May 15, 2025
96771ad
install deps before running the tests
karangattu May 15, 2025
1dfd712
fix linting issues
karangattu May 15, 2025
3614b3f
see if this fixes pyright issues
karangattu May 15, 2025
5286042
Merge branch 'main' into run-py-shiny-template-tests
karangattu Jul 16, 2025
0de7da4
Remove unused import from app.py
karangattu Jul 16, 2025
ec648cc
Add new allowed deprecation warnings for cufflinks
karangattu Jul 16, 2025
c22da78
Skip template dependency install and tests on Python 3.9
karangattu Jul 16, 2025
ec26fe1
Skip test on Python 3.9 due to scikit-learn version
karangattu Jul 16, 2025
960fc91
Adjust make command to install deps
schloerke Jul 21, 2025
ae24fc2
Discard changes to tests/playwright/shiny/components/data_frame/edit/…
schloerke Jul 21, 2025
17a2825
Update pyproject.toml
schloerke Jul 21, 2025
6dc0c9b
default timeout is ok
schloerke Jul 21, 2025
9a5e2a0
Merge branch 'run-py-shiny-template-tests' of https://github.com/posi…
schloerke Jul 21, 2025
7d869e5
fix langchain install dep hell
schloerke Jul 21, 2025
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
11 changes: 11 additions & 0 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,17 @@ jobs:
working-directory: examples/brownian/shinymediapipe
run: |
npm ci
- name: Checkout py-shiny-templates repository
uses: actions/checkout@v4
with:
repository: posit-dev/py-shiny-templates
path: py-shiny-templates

- name: Install py-shiny-templates dependencies
if: matrix.python-version != '3.9'
# Scikit-learn 1.7.0+ requires Python 3.10+
run: |
make ci-install-py-shiny-templates-deps

- name: Run example app tests
timeout-minutes: 60
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ install-deps: FORCE ## install dependencies
pip install -e ".[dev,test]" --upgrade
ci-install-deps: FORCE
uv pip install -e ".[dev,test]"
ci-install-py-shiny-templates-deps: FORCE
uv pip install -r py-shiny-templates/requirements.txt

install-docs: FORCE
pip install -e ".[dev,test,doc]"
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ test = [
"dask[dataframe]",
"pyarrow",
"pyarrow-stubs",

]
dev = [
"black>=24.0",
Expand Down
19 changes: 18 additions & 1 deletion tests/playwright/examples/example_apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from pathlib import PurePath
from typing import Literal

from playwright.sync_api import ConsoleMessage, Page
from playwright.sync_api import ConsoleMessage, Page, expect

from shiny.run import ShinyAppProc, run_shiny_app

Expand All @@ -15,6 +15,9 @@
reruns = 1 if is_interactive else 3
reruns_delay = 0

SHINY_INIT_TIMEOUT = 30_000
ERROR_ELEMENT_TIMEOUT = 1_000


def get_apps(path: str) -> typing.List[str]:
full_path = pyshiny_root / path
Expand Down Expand Up @@ -91,11 +94,20 @@ def get_apps(path: str) -> typing.List[str]:
"FutureWarning: use_inf_as_na option is deprecated",
"pd.option_context('mode.use_inf_as_na", # continutation of line above,
"RuntimeWarning: invalid value encountered in dot", # some groups didn't have enough data points to create a meaningful line
"DatetimeIndex.format is deprecated and will be removed in a future version. Convert using index.astype(str) or index.map(formatter) instead.", # cufflinks package is using this method
"Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`", # cufflinks package is using this method
]
app_allow_js_errors: typing.Dict[str, typing.List[str]] = {
"examples/brownian": ["Failed to acquire camera feed:"],
}

# Check for Shiny output errors, except for known exception cases
app_allow_output_error = [
"shiny/api-examples/SafeException/app-express.py",
"shiny/api-examples/SafeException/app-core.py",
"examples/global_pyplot/app.py",
]


# Altered from `shinytest2:::app_wait_for_idle()`
# https://github.com/rstudio/shinytest2/blob/b8fdce681597e9610fc078aa6e376134c404f3bd/R/app-driver-wait.R
Expand Down Expand Up @@ -251,3 +263,8 @@ def on_console_msg(msg: ConsoleMessage) -> None:
+ " had JavaScript console errors!\n"
+ "* ".join(console_errors)
)

if ex_app_path not in app_allow_output_error:
# Ensure there are no output errors present
error_locator = page.locator(".shiny-output-error")
expect(error_locator).to_have_count(0, timeout=ERROR_ELEMENT_TIMEOUT)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice that this will check all apps for any output errors. 🎉 !

24 changes: 24 additions & 0 deletions tests/playwright/examples/test_external_templates.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import sys
from pathlib import Path

import pytest
from conftest import here_root
from example_apps import get_apps, reruns, reruns_delay, validate_example
from playwright.sync_api import Page

if not Path(here_root / "py-shiny-templates").exists():
pytest.skip(
"./py-shiny-templates dir is not available. Skipping test.",
allow_module_level=True,
)


@pytest.mark.skipif(
sys.version_info[:2] == (3, 9),
reason="Skipping test for Python 3.9 since scikit-learn pinned version is only supported on Python 3.10+",
)
@pytest.mark.only_browser("chromium")
@pytest.mark.flaky(reruns=reruns, reruns_delay=reruns_delay)
@pytest.mark.parametrize("ex_app_path", get_apps("py-shiny-templates"))
def test_external_templates(page: Page, ex_app_path: str) -> None:
validate_example(page, ex_app_path)
1 change: 1 addition & 0 deletions tests/playwright/shiny/components/data_frame/edit/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ def df_styles_fn(data: pd.DataFrame) -> list[StyleInfo]:

@render_widget
def country_detail_pop(): # pyright: ignore[reportUnknownParameterType]

import plotly.express as px

# Create the figure explicitly
Expand Down
Loading