Skip to content

test: Test apps locally before deploying via pytest fixtures. #1055

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

Merged
merged 45 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
a0da1e5
Move deploy tests under playwright-shiny
karangattu Jan 23, 2024
156ee9e
pyright changes
karangattu Jan 23, 2024
70b975f
move it to a different directory
karangattu Jan 24, 2024
ffea0a1
Merge branch 'main' into deploy-tests-under-playwright-shiny
karangattu Jan 24, 2024
7658a52
Modify path to deploys
karangattu Jan 24, 2024
1a202b7
Modify path to deploys tests
karangattu Jan 24, 2024
da0f7fe
don't skip plotly app
karangattu Jan 24, 2024
dc18116
black formatting
karangattu Jan 24, 2024
0e31c72
rename the shinyapps.io json files
karangattu Jan 25, 2024
9ea2628
Rename the plotly shinyapps.io json file
karangattu Jan 25, 2024
20639a0
Merge branch 'main' into deploy-tests-under-playwright-shiny
schloerke Jan 25, 2024
ac1b0b7
Add plotly deploys app to transformer error list. Expand on path name…
schloerke Jan 25, 2024
15cb922
Missed app name update
schloerke Jan 25, 2024
1119b36
Discard changes to ...playwright/deploys/apps/plotly_app/app.py
schloerke Jan 25, 2024
1e23071
Revert playwright-deploys job and makefile entry
schloerke Jan 25, 2024
756f213
Move deploys apps
schloerke Jan 25, 2024
4c8c490
Deploy app to consistent locations
schloerke Jan 25, 2024
d18671b
Ignore more apps
schloerke Jan 25, 2024
a3b5880
Merge branch 'main' into deploy-tests-under-playwright-shiny
schloerke Jan 25, 2024
6ff659a
rename the rsconnect json files
karangattu Jan 25, 2024
518d575
Delete app.py
schloerke Jan 29, 2024
a25e410
Revert init deletion
schloerke Jan 29, 2024
e31dba9
Add flag to/not to deploy _deploys_ apps during testing
schloerke Jan 29, 2024
5e23d00
Pass through yielded app to write logic once
schloerke Jan 29, 2024
a656d32
Make fixture that deploys or runs an app locally
schloerke Jan 29, 2024
cd46c05
Use new fixture
schloerke Jan 29, 2024
e20575e
Add comment of debug options
schloerke Jan 29, 2024
3ef4aab
Merge branch 'main' into deploy-tests-under-playwright-shiny
schloerke Jan 29, 2024
949569f
pyright lint
schloerke Jan 29, 2024
a8b530a
Delete test_deploys_examples.py
schloerke Jan 29, 2024
3e8c5d1
Update deploy_utils.py
schloerke Jan 29, 2024
e483251
Make CI playwright more descriptive when testing
schloerke Jan 29, 2024
fd8f5c8
Update pytest.yaml
schloerke Jan 29, 2024
db70485
Explicitly wait up to 2 mins for text to resolve
schloerke Jan 29, 2024
d1107ed
remove fastapi from app_requirements.txt
karangattu Jan 30, 2024
2e239a8
add timeout to page default
karangattu Jan 30, 2024
dcda99b
Move pre-test to be in deploys GHA job. Only deploy if on push or PR …
schloerke Jan 30, 2024
fda6e8b
Remove skip if python version != 3.10
schloerke Jan 30, 2024
66cdbf9
Test deploy apps using 12 processes
schloerke Jan 30, 2024
dd80734
Do not use dynamic locator property
schloerke Jan 30, 2024
67d2e49
Get the __file__ info from request in fixture
schloerke Jan 30, 2024
72aa4c5
Do not first use locator that must internally resolve. Instead, nativ…
schloerke Jan 30, 2024
168aad9
Use correct deploy name
schloerke Jan 31, 2024
1838875
Shorten folder names
schloerke Jan 31, 2024
5c3b353
Rename deploy files
schloerke Jan 31, 2024
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
Prev Previous commit
Next Next commit
Deploy app to consistent locations
  • Loading branch information
schloerke committed Jan 25, 2024
commit 4c8c490e0f3eb001f97a057aaa08f290a300daaf
16 changes: 8 additions & 8 deletions tests/playwright/deploys/plotly/test_plotly_app.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import os

import pytest
from conftest import ShinyAppProc
from playwright.sync_api import Page, expect
from utils.deploy_utils import prepare_deploy_and_open_url, skip_if_not_python_310
from utils.deploy_utils import (
deploy_locations,
prepare_deploy_and_open_url,
skip_if_not_python_310,
)

COUNTRY = "Afghanistan"
APP_NAME = "example_deploy_app_A"
Expand All @@ -13,12 +16,9 @@

@skip_if_not_python_310
@pytest.mark.only_browser("chromium")
@pytest.mark.parametrize("location", ["connect", "shinyapps", "local"])
def test_deploys(page: Page, location: str, local_app: ShinyAppProc) -> None:
if location == "local":
page.goto(local_app.url)
else:
prepare_deploy_and_open_url(page, app_file_path, location, APP_NAME)
@pytest.mark.parametrize("location", deploy_locations)
def test_deploys(page: Page, location: str) -> None:
prepare_deploy_and_open_url(page, app_file_path, location, APP_NAME)

expect(page.get_by_text(COUNTRY)).to_have_count(1, timeout=EXPECT_TIMEOUT)
page.get_by_role("cell", name=COUNTRY).click(timeout=EXPECT_TIMEOUT)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
import os

import pytest
from conftest import ShinyAppProc
from controls import Accordion
from playwright.sync_api import Page
from utils.deploy_utils import prepare_deploy_and_open_url, skip_if_not_python_310
from utils.deploy_utils import (
deploy_locations,
prepare_deploy_and_open_url,
skip_if_not_python_310,
)

APP_NAME = "shiny_express_accordion"
app_file_path = os.path.dirname(os.path.abspath(__file__))


@skip_if_not_python_310
@pytest.mark.only_browser("chromium")
@pytest.mark.parametrize("location", ["connect", "shinyapps", "local"])
def test_express_accordion(page: Page, location: str, local_app: ShinyAppProc) -> None:
if location == "local":
page.goto(local_app.url)
else:
prepare_deploy_and_open_url(page, app_file_path, location, APP_NAME)
@pytest.mark.parametrize("location", deploy_locations)
def test_express_accordion(page: Page, location: str) -> None:
prepare_deploy_and_open_url(page, app_file_path, location, APP_NAME)

acc = Accordion(page, "express_accordion")
acc_panel_2 = acc.accordion_panel("Panel 2")
acc_panel_2.expect_open(True)
Expand Down
19 changes: 9 additions & 10 deletions tests/playwright/deploys/shiny-express-dataframe/test_dataframe.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
import os

import pytest
from conftest import ShinyAppProc
from controls import OutputDataFrame
from playwright.sync_api import Page
from utils.deploy_utils import prepare_deploy_and_open_url, skip_if_not_python_310
from utils.deploy_utils import (
deploy_locations,
prepare_deploy_and_open_url,
skip_if_not_python_310,
)

APP_NAME = "shiny-express-dataframe"
app_file_path = os.path.dirname(os.path.abspath(__file__))


@skip_if_not_python_310
@pytest.mark.only_browser("chromium")
@pytest.mark.parametrize("location", ["connect", "shinyapps", "local"])
def test_express_dataframe_deploys(
page: Page, location: str, local_app: ShinyAppProc
) -> None:
if location == "local":
page.goto(local_app.url)
else:
prepare_deploy_and_open_url(page, app_file_path, location, APP_NAME)
@pytest.mark.parametrize("location", deploy_locations)
def test_express_dataframe_deploys(page: Page, location: str) -> None:
prepare_deploy_and_open_url(page, app_file_path, location, APP_NAME)

dataframe = OutputDataFrame(page, "sample_data_frame")
dataframe.expect_n_row(6)
17 changes: 9 additions & 8 deletions tests/playwright/deploys/shiny-express-folium/test_folium.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
import os

import pytest
from conftest import ShinyAppProc
from playwright.sync_api import Page, expect
from utils.deploy_utils import prepare_deploy_and_open_url, skip_if_not_python_310
from utils.deploy_utils import (
deploy_locations,
prepare_deploy_and_open_url,
skip_if_not_python_310,
)

APP_NAME = "shiny-express-folium"
app_file_path = os.path.dirname(os.path.abspath(__file__))


@skip_if_not_python_310
@pytest.mark.only_browser("chromium")
@pytest.mark.parametrize("location", ["connect", "shinyapps", "local"])
def test_folium_map(page: Page, location: str, local_app: ShinyAppProc) -> None:
if location == "local":
page.goto(local_app.url)
else:
prepare_deploy_and_open_url(page, app_file_path, location, APP_NAME)
@pytest.mark.parametrize("location", deploy_locations)
def test_folium_map(page: Page, location: str) -> None:
prepare_deploy_and_open_url(page, app_file_path, location, APP_NAME)

expect(page.get_by_text("Static Map")).to_have_count(1)
expect(page.get_by_text("Map inside of render express call")).to_have_count(1)
# map inside the @render.express
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import os

import pytest
from conftest import ShinyAppProc
from controls import LayoutNavsetTab
from playwright.sync_api import Page
from utils.deploy_utils import prepare_deploy_and_open_url, skip_if_not_python_310
from utils.deploy_utils import (
deploy_locations,
prepare_deploy_and_open_url,
skip_if_not_python_310,
)

APP_NAME = "shiny-express-folium"
app_file_path = os.path.dirname(os.path.abspath(__file__))


@skip_if_not_python_310
@pytest.mark.only_browser("chromium")
@pytest.mark.parametrize("location", ["connect", "shinyapps", "local"])
def test_page_default(page: Page, location: str, local_app: ShinyAppProc) -> None:
if location == "local":
page.goto(local_app.url)
else:
prepare_deploy_and_open_url(page, app_file_path, location, APP_NAME)
@pytest.mark.parametrize("location", deploy_locations)
def test_page_default(page: Page, location: str) -> None:
prepare_deploy_and_open_url(page, app_file_path, location, APP_NAME)
nav_html = LayoutNavsetTab(page, "express_navset_tab")
nav_html.expect_content("pre 0pre 1pre 2")
nav_html.set("div")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
import os

import pytest
from conftest import ShinyAppProc
from controls import Card, OutputTextVerbatim
from playwright.sync_api import Page
from utils.deploy_utils import prepare_deploy_and_open_url, skip_if_not_python_310
from utils.deploy_utils import (
deploy_locations,
prepare_deploy_and_open_url,
skip_if_not_python_310,
)

APP_NAME = "express_page_fillable"
app_file_path = os.path.dirname(os.path.abspath(__file__))


@skip_if_not_python_310
@pytest.mark.only_browser("chromium")
@pytest.mark.parametrize("location", ["connect", "shinyapps", "local"])
def test_express_page_fillable(
page: Page, location: str, local_app: ShinyAppProc
) -> None:
if location == "local":
page.goto(local_app.url)
else:
prepare_deploy_and_open_url(page, app_file_path, location, APP_NAME)
@pytest.mark.parametrize("location", deploy_locations)
def test_express_page_fillable(page: Page, location: str) -> None:
prepare_deploy_and_open_url(page, app_file_path, location, APP_NAME)

card = Card(page, "card")
output_txt = OutputTextVerbatim(page, "txt")
output_txt.expect_value("50")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
import os

import pytest
from conftest import ShinyAppProc
from controls import Card, OutputTextVerbatim
from playwright.sync_api import Page
from utils.deploy_utils import prepare_deploy_and_open_url, skip_if_not_python_310
from utils.deploy_utils import (
deploy_locations,
prepare_deploy_and_open_url,
skip_if_not_python_310,
)

APP_NAME = "express_page_fluid"
app_file_path = os.path.dirname(os.path.abspath(__file__))


@skip_if_not_python_310
@pytest.mark.only_browser("chromium")
@pytest.mark.parametrize("location", ["connect", "shinyapps", "local"])
def test_express_page_fluid(page: Page, location: str, local_app: ShinyAppProc) -> None:
if location == "local":
page.goto(local_app.url)
else:
prepare_deploy_and_open_url(page, app_file_path, location, APP_NAME)
@pytest.mark.parametrize("location", deploy_locations)
def test_express_page_fluid(page: Page, location: str) -> None:
prepare_deploy_and_open_url(page, app_file_path, location, APP_NAME)

card = Card(page, "card")
output_txt = OutputTextVerbatim(page, "txt")
output_txt.expect_value("50")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import os

import pytest
from conftest import ShinyAppProc
from controls import OutputTextVerbatim, Sidebar
from playwright.sync_api import Page
from utils.deploy_utils import prepare_deploy_and_open_url, skip_if_not_python_310
from utils.deploy_utils import (
deploy_locations,
prepare_deploy_and_open_url,
skip_if_not_python_310,
)
from utils.express_utils import compare_annotations

from shiny import ui
Expand All @@ -16,14 +19,10 @@

@skip_if_not_python_310
@pytest.mark.only_browser("chromium")
@pytest.mark.parametrize("location", ["connect", "shinyapps", "local"])
def test_express_page_sidebar(
page: Page, location: str, local_app: ShinyAppProc
) -> None:
if location == "local":
page.goto(local_app.url)
else:
prepare_deploy_and_open_url(page, app_file_path, location, APP_NAME)
@pytest.mark.parametrize("location", deploy_locations)
def test_express_page_sidebar(page: Page, location: str) -> None:
prepare_deploy_and_open_url(page, app_file_path, location, APP_NAME)

sidebar = Sidebar(page, "sidebar")
sidebar.expect_text("SidebarTitle Sidebar Content")
output_txt = OutputTextVerbatim(page, "txt")
Expand Down
2 changes: 2 additions & 0 deletions tests/playwright/utils/deploy_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
reason="Test requires Python 3.10",
)

deploy_locations = ["connect", "shinyapps"]


def exception_swallower(
function: typing.Callable[[str, str], str]
Expand Down