[feat] Utilize standardized app_base_url throughout e2e tests#13679
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
✅ PR preview is ready!
|
This stack of pull requests is managed by Graphite. Learn more about stacking. |
a1cf074 to
62eec2f
Compare
9e9dfa9 to
24b4488
Compare
24b4488 to
07b02c8
Compare
62eec2f to
1bccb97
Compare
📉 Frontend coverage change detectedThe frontend unit test (vitest) coverage has decreased by 0.0000%
✅ Coverage change is within normal range. |
a86c1f8 to
6e57b44
Compare
SummaryThis PR refactors the E2E test infrastructure to utilize a standardized Key changes:
Code QualityThe implementation is well-structured and follows good practices: Strengths:
Minor observations:
Test CoverageThis PR is a refactoring effort that updates existing tests rather than adding new functionality to test. The changes are appropriate because:
The documentation updates in all three files (
Backwards CompatibilityNo breaking changes. This PR only modifies test infrastructure and does not affect the Streamlit library's public API or behavior. All changes are internal to the E2E testing framework. The Security & RiskNo security concerns identified.
Low regression risk:
RecommendationsThe PR is well-implemented and ready for merge. The following are minor suggestions for future consideration (not blocking):
VerdictAPPROVED: This PR is a well-executed refactoring that standardizes URL handling across E2E tests, enabling external app testing while maintaining backward compatibility. The code quality is high, documentation is updated, and there are no security concerns or breaking changes. This is an automated AI review using |
There was a problem hiding this comment.
Pull request overview
Standardizes E2E test URL construction by introducing an app_base_url + build_app_url(...) approach (instead of hardcoded http://localhost:{app_port}), and adds infrastructure to target apps embedded in external host pages via iframes.
Changes:
- Replace hardcoded localhost URL building across multiple E2E tests with
app_base_url+build_app_url(...). - Extend Playwright fixtures/utilities to support external host pages + iframe targeting (
app_target, new CLI options). - Broaden a few shared helpers to work with iframe contexts (
FrameLocator).
Reviewed changes
Copilot reviewed 29 out of 29 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| e2e_playwright/websocket_reconnects_test.py | Switch metrics/media URL building to app_base_url + build_app_url. |
| e2e_playwright/web_server_test.py | Replace localhost hardcoding; add helper for ws URL derivation. |
| e2e_playwright/st_video_test.py | Update media routing + navigation to use app_base_url. |
| e2e_playwright/st_text_test.py | Make tooltip test iframe-compatible via app_target/FrameLocator. |
| e2e_playwright/st_sidebar_flicker_test.py | Use build_app_url for query-based navigation. |
| e2e_playwright/st_main_layout_test.py | Use build_app_url when navigating in custom server fixture. |
| e2e_playwright/st_image_test.py | Update media routing + navigation to use app_base_url. |
| e2e_playwright/st_file_uploader_test.py | Update upload routing + navigation to use app_base_url. |
| e2e_playwright/st_download_button_test.py | Update media routing + navigation to use app_base_url. |
| e2e_playwright/st_context_test.py | Assert against app_base_url instead of localhost+port. |
| e2e_playwright/st_chat_input_test.py | Build navigation URLs with build_app_url rather than parsing app_port. |
| e2e_playwright/st_audio_test.py | Update media routing + navigation to use app_base_url. |
| e2e_playwright/shared/app_utils.py | Allow tooltip helpers to accept FrameLocator contexts. |
| e2e_playwright/multipage_apps_v2/mpa_v2_basics_test.py | Replace localhost hardcoding in multipage URL assertions/navigation. |
| e2e_playwright/multipage_apps/mpa_basics_test.py | Replace localhost hardcoding in multipage URL assertions/navigation. |
| e2e_playwright/mega_tester_app_test.py | Use app_target for iframe-compatible assertions; remove direct navigation call. |
| e2e_playwright/hostframe_app_test.py | Align iframe context URL expectations with app_base_url; add hostframe-load test. |
| e2e_playwright/host_config_test.py | Use app_base_url/build_app_url for host-config routing/navigation. |
| e2e_playwright/host_config_bypass_test.py | Replace localhost base URL usage with app_base_url. |
| e2e_playwright/forward_msg_cache_test.py | Replace localhost navigation with build_app_url(app_base_url, ...). |
| e2e_playwright/custom_components/component_errors_test.py | Replace localhost routing/navigation with app_base_url/build_app_url. |
| e2e_playwright/conftest.py | Add build_app_url, app_target, and CLI/fixtures for external host+iframe mode; generalize load/run waits. |
| e2e_playwright/config_static_serving_test.py | Replace localhost hardcoding for static asset requests. |
| e2e_playwright/compilation_error_dialog_test.py | Use build_app_url for manual navigation. |
| e2e_playwright/basic_app_test.py | Replace localhost navigation with build_app_url(app_base_url, ...). |
| e2e_playwright/auth_test.py | Replace localhost URL waits with build_app_url(app_base_url, ...). |
| e2e_playwright/AGENTS.md | Document app_base_url/build_app_url guidance and “no localhost hardcoding”. |
| .github/instructions/e2e_playwright.instructions.md | Same guidance for contributors/agents. |
| .cursor/rules/e2e_playwright.mdc | Same guidance for Cursor rules. |
Comments suppressed due to low confidence (1)
e2e_playwright/shared/app_utils.py:951
- The
expect_help_tooltipsignature now allowsFrameLocator, but the docstring still documentsappas aPageonly. Updating the parameter docs to reflect the accepted types will make it clearer how to use this helper in iframe-targeted tests.
def expect_help_tooltip(
app: Locator | Page | FrameLocator,
element_with_help_tooltip: Locator,
tooltip_text: str | re.Pattern[str],
) -> None:
"""Expect a tooltip to be displayed when hovering over the help symbol of an element.
6e57b44 to
fe1a970
Compare
07b02c8 to
212927b
Compare
212927b to
6ca20fe
Compare
fe1a970 to
ca84594
Compare
e2e_playwright/AGENTS.md
Outdated
| - Never hardcode `http://localhost:{app_port}` in tests or fixtures. | ||
| - Use `app_base_url` for navigation, routing, and URL assertions. |
There was a problem hiding this comment.
This bullet says to never hardcode http://localhost:{app_port} in “tests or fixtures”, but app_base_url in e2e_playwright/conftest.py intentionally constructs http://localhost:{app_port} as the default fallback. Consider clarifying the rule to apply to test modules (or “outside conftest”), e.g. “Don’t build localhost URLs in test files; use app_base_url/build_app_url instead.”
| - Never hardcode `http://localhost:{app_port}` in tests or fixtures. | |
| - Use `app_base_url` for navigation, routing, and URL assertions. | |
| - Never hardcode `http://localhost:{app_port}` in test modules (outside `conftest.py`). | |
| - Use `app_base_url` for navigation, routing, and URL assertions instead of building localhost URLs directly in tests. |
2cd96c1 to
ef72adc
Compare
5f43c64 to
5c81234
Compare
081ef48 to
cf2273e
Compare
1968bfb to
696cc5b
Compare
cf2273e to
53f11ff
Compare
SummaryThis PR standardizes Playwright e2e tests on Code QualityTwo remaining localhost assumptions undermine the new URL-handling guidance and will break when running against external app URLs or base paths. AUTH_SECRETS_TEMPLATE = """
[auth]
redirect_uri = "http://localhost:{app_port}/oauth2callback"
cookie_secret = "your_cookie_secret_here"
expose_tokens = ["id", "access"]
[auth.testprovider]
client_id = "test-client-id"
client_secret = "test-client-secret"
server_metadata_url = "http://localhost:{oidc_server_port}/.well-known/openid-configuration"
"""@pytest.fixture(scope="module")
def prepare_secrets_file(app_port: int, oidc_server_port: int):
"""Fixture that inject the correct port to auth_secrets.toml file redirect_uri."""
# Read in the file
rendered_secrets = AUTH_SECRETS_TEMPLATE.format(
app_port=app_port, oidc_server_port=oidc_server_port
) # First test without file upload config
with iframed_app.page.expect_request(lambda request: request.method == "PUT") as r:
file_chooser.set_files(files=files[0])
url = r.value.url
headers = r.value.all_headers()
response = r.value.response()
assert response is not None
assert response.status == 204 # Upload successful
assert url.startswith("http://localhost")
assert "_stcore/upload_file" in url
assert "header1" not in headersTest CoverageChanges are confined to e2e tests and guidance; no new unit tests are expected. However, external/embedded test runs will still fail or mis-route in the two locations above until Backwards CompatibilityNo runtime behavior changes; these are test-only updates. Security & RiskLow risk overall. The main regression risk is e2e runs against externally hosted apps (or base paths) still failing due to remaining hardcoded localhost URLs. Recommendations
VerdictCHANGES_REQUESTED: A couple of remaining localhost hardcodes conflict with the PR’s new external-compatible URL handling and will break external app runs until updated. This is an automated AI review using |
|
I addressed the requested changes by AI in this latest push. |
696cc5b to
8c8547b
Compare
53f11ff to
27dda05
Compare
27dda05 to
d365ccf
Compare
8c8547b to
1ebc6fd
Compare
Merge activity
|
d365ccf to
757f876
Compare

Describe your changes
app_port/http://localhost:{app_port}toapp_base_url+build_app_url(...)for navigation, request calls, route interception, and URL assertions.ws://vswss://fromapp_base_url(so the same tests work for https/external runs, not just local http).e2e_playwright/AGENTS.md,.githubinstructions, and Cursor rules).Testing Plan
Contribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.