Skip to content

Commit 989f86e

Browse files
committed
Add docstrings for functions and classes
1 parent 4c07953 commit 989f86e

File tree

1 file changed

+37
-3
lines changed

1 file changed

+37
-3
lines changed

tests/integration/tests_playwright/test_frontend_path.py

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99

1010
def OnLoadRedirectApp():
11+
"""App to demonstrate an on_load redirection issue.
12+
13+
See https://github.com/reflex-dev/reflex/issues/5674 for details.
14+
"""
1115
import reflex as rx
1216

1317
@rx.page("/")
@@ -49,6 +53,16 @@ def bouncer():
4953

5054
@pytest.fixture
5155
def onload_redirect_app(tmp_path_factory) -> Generator[AppHarness, None, None]:
56+
"""Start the OnLoadRedirectApp without setting REFLEX_FRONTEND_PATH".
57+
58+
This is a baseline used to show on_load redirects work without a frontend_path.
59+
60+
Args:
61+
tmp_path_factory: pytest tmp_path_factory fixture
62+
63+
Yields:
64+
running AppHarness instance
65+
"""
5266
with AppHarnessProd.create(
5367
root=tmp_path_factory.mktemp("frontend_path_app"),
5468
app_source=OnLoadRedirectApp,
@@ -61,6 +75,16 @@ def onload_redirect_app(tmp_path_factory) -> Generator[AppHarness, None, None]:
6175
def onload_redirect_with_prefix_app(
6276
tmp_path_factory,
6377
) -> Generator[AppHarness, None, None]:
78+
"""Start the OnLoadRedirectApp with REFLEX_FRONTEND_PATH set to "/prefix".
79+
80+
This simulates setting the REFLEX_FRONTEND_PATH to identify issues with redirection.
81+
82+
Args:
83+
tmp_path_factory: pytest tmp_path_factory fixture
84+
85+
Yields:
86+
running AppHarness instance
87+
"""
6488
prefix = "/prefix"
6589
try:
6690
environment.REFLEX_FRONTEND_PATH.set(prefix)
@@ -76,18 +100,28 @@ def onload_redirect_with_prefix_app(
76100

77101

78102
@pytest.mark.parametrize(
79-
("app_fixture_name", "prefix"),
103+
("app_fixture_name", "frontend_path"),
80104
[
81105
("onload_redirect_app", ""),
82106
("onload_redirect_with_prefix_app", "/prefix"),
83107
],
84108
)
85-
def test_onload_redirect(app_fixture_name: str, prefix: str, page: Page, request):
109+
def test_onload_redirect(
110+
app_fixture_name: str, frontend_path: str, page: Page, request
111+
):
112+
"""Ensure that on_load redirects work correctly when a frontend_path is present.
113+
114+
Args:
115+
app_fixture_name: Name of the app fixture to use for the test.
116+
frontend_path: The REFLEX_FRONTEND_PATH used by the app fixture.
117+
page: Playwright Page object to interact with the app.
118+
request: Pytest request object to access fixtures.
119+
"""
86120
app_fixture = request.getfixturevalue(app_fixture_name)
87121
assert app_fixture.frontend_url is not None
88122

89123
base_url = app_fixture.frontend_url.rstrip("/")
90-
base_url += prefix
124+
base_url += frontend_path
91125
page.goto(f"{base_url}/")
92126
expect(page.get_by_text("This is the index page!")).to_be_visible()
93127

0 commit comments

Comments
 (0)