Skip to content

[feat] Add AppTarget class for test abstraction#13737

Merged
sfc-gh-bnisco merged 1 commit intodevelopfrom
01-22-_feat_add_app_target
Feb 12, 2026
Merged

[feat] Add AppTarget class for test abstraction#13737
sfc-gh-bnisco merged 1 commit intodevelopfrom
01-22-_feat_add_app_target

Conversation

@sfc-gh-bnisco
Copy link
Copy Markdown
Collaborator

@sfc-gh-bnisco sfc-gh-bnisco commented Jan 29, 2026

Describe your changes

Introduce an AppTarget abstraction so Playwright E2E tests can interact with the Streamlit app consistently whether it’s loaded at the top-level (local / external-direct) or embedded in an iframe (external-host mode).

  • Add AppTarget (and app_target fixture) to centralize "where does the app DOM live?" (page vs iframe) so tests/helpers don’t need to branch on external hosting mode.
  • Add app_base_url + build_app_url(...) and standardize navigation/URL building to work for both localhost and externally hosted apps (including hash-fragment app_hash routing).
  • Update shared helpers (LocatorContext Protocol) so utilities can accept page/frame contexts (and AppTarget) without leaking iframe details into tests.
  • Document external test mode + new fixtures in E2E guidance (.cursor/rules, AGENTS.md, GitHub instructions).

Testing Plan

  • No additional tests needed as this is a testing utility class that will be used by other E2E tests
  • The functionality will be validated through usage in future Playwright E2E tests

Contribution License Agreement

By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

@snyk-io
Copy link
Copy Markdown
Contributor

snyk-io bot commented Jan 29, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@sfc-gh-bnisco sfc-gh-bnisco added change:feature PR contains new feature or enhancement implementation impact:internal PR changes only affect internal code security-assessment-completed labels Jan 29, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jan 29, 2026

✅ PR preview is ready!

Name Link
📦 Wheel file https://core-previews.s3-us-west-2.amazonaws.com/pr-13737/streamlit-1.54.0-py3-none-any.whl
📦 @streamlit/component-v2-lib Download from artifacts
🕹️ Preview app pr-13737.streamlit.app (☁️ Deploy here if not accessible)

@sfc-gh-bnisco
Copy link
Copy Markdown
Collaborator Author

sfc-gh-bnisco commented Jan 29, 2026

@sfc-gh-bnisco sfc-gh-bnisco force-pushed the 01-22-_feat_add_app_target branch from d7fbba4 to ee161af Compare January 29, 2026 01:04
@sfc-gh-bnisco sfc-gh-bnisco force-pushed the 01-22-_feat_add_external_url_runner_in_e2e_playwright branch from 2099055 to e0ba6f5 Compare January 29, 2026 01:04
@sfc-gh-bnisco sfc-gh-bnisco force-pushed the 01-22-_feat_add_app_target branch 2 times, most recently from ed0152b to 52e9c40 Compare January 29, 2026 01:31
@sfc-gh-bnisco sfc-gh-bnisco requested a review from Copilot January 29, 2026 01:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Purpose: This PR introduces a new AppTarget class to provide a unified abstraction for interacting with Streamlit apps during Playwright E2E tests, regardless of whether they're running in local mode or external/iframe-hosted mode.

Changes:

  • Added AppTarget class and helper functions in e2e_playwright/shared/app_target.py to abstract app interaction across different hosting modes
  • Enhanced e2e_playwright/conftest.py with new app_target fixture and build_app_url utility function for flexible URL construction
  • Updated e2e_playwright/shared/app_utils.py to introduce LocatorContext Protocol for type-safe polymorphic locator contexts
  • Updated documentation in AGENTS.md, e2e_playwright.instructions.md, and e2e_playwright.mdc to reflect the new fixtures and external test mode

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
e2e_playwright/shared/app_target.py Introduces AppTarget class for unified app interaction and moves StaticPage class here
e2e_playwright/shared/app_utils.py Adds LocatorContext Protocol and updates function signatures to support the new abstraction
e2e_playwright/conftest.py Adds app_target fixture, build_app_url helper, refactors URL handling for external modes
e2e_playwright/AGENTS.md Documents new app_target fixture and external test mode configuration
.github/instructions/e2e_playwright.instructions.md Same documentation updates for GitHub instructions
.cursor/rules/e2e_playwright.mdc Same documentation updates for Cursor rules

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jan 29, 2026

📈 Frontend coverage change detected

The frontend unit test (vitest) coverage has increased by 0.0200%

  • Current PR: 86.8400% (13884 lines, 1827 missed)
  • Latest develop: 86.8200% (13884 lines, 1829 missed)

✅ Coverage change is within normal range.

📊 View detailed coverage comparison

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.

@sfc-gh-bnisco sfc-gh-bnisco force-pushed the 01-22-_feat_add_app_target branch 2 times, most recently from 8bdee90 to eaa3de0 Compare January 29, 2026 06:00
@sfc-gh-bnisco sfc-gh-bnisco force-pushed the 01-22-_feat_add_external_url_runner_in_e2e_playwright branch from 5b7e6e1 to d6871d4 Compare January 29, 2026 19:16
@sfc-gh-bnisco sfc-gh-bnisco force-pushed the 01-22-_feat_add_app_target branch from eaa3de0 to 83ca0ac Compare January 29, 2026 19:16
@sfc-gh-bnisco sfc-gh-bnisco marked this pull request as ready for review January 29, 2026 22:06
@sfc-gh-bnisco sfc-gh-bnisco requested a review from a team as a code owner January 29, 2026 22:06
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 2, 2026

Summary

This PR introduces the AppTarget abstraction and URL utilities to make Playwright E2E tests work consistently across local, external-direct, and external-hosted iframe modes. It updates core fixtures and shared helpers plus documentation to guide usage in external test mode.

Code Quality

Overall structure is clean and the new abstraction is well-contained. One potential pitfall:

  • LocatorContext explicitly advertises Locator support, but reset_hovering/reset_focus now call get_by_test_id("stApp") on the passed context, which will scope to the locator subtree and can fail unless the locator actually contains stApp. If tests ever pass a widget-level Locator, this becomes a runtime failure. Consider either restoring the previous Locator.page fallback or tightening the protocol/docs to require a page/frame/app-level context. (e2e_playwright/shared/app_utils.py lines 30-41, 1002-1015)

Test Coverage

No new tests were added. Given these are E2E infrastructure changes, this is acceptable, but note that build_app_url and AppTarget behaviors are not directly exercised by unit tests.

Backwards Compatibility

No user-facing API changes; this is internal test infrastructure. Existing tests should continue to work, though build_app_url changes URL composition logic slightly (e.g., host-only base URLs may no longer be forced to trailing slashes).

Security & Risk

Low risk. Changes are confined to test tooling; no production code paths modified.

Recommendations

  1. Clarify or adjust LocatorContext usage so reset_hovering/reset_focus behave correctly with a Locator input (restore locator.page fallback or narrow accepted types). (e2e_playwright/shared/app_utils.py lines 30-41, 1002-1015)
  2. Consider making iframe targeting explicit (e.g., .first or an assertion of a single match) so app_target consistently uses the same iframe it updated when multiple iframes match the selector. (e2e_playwright/conftest.py lines 621-632)

Verdict

APPROVED: Solid abstraction and fixture updates with no blocking issues; a couple of minor hardening opportunities noted above.


This is an automated AI review using gpt-5.2-codex-high. Please verify the feedback and use your judgment.

@sfc-gh-bnisco sfc-gh-bnisco force-pushed the 01-22-_feat_add_external_url_runner_in_e2e_playwright branch from d6871d4 to bf9998a Compare February 4, 2026 21:34
@sfc-gh-bnisco sfc-gh-bnisco force-pushed the 01-22-_feat_add_app_target branch from 83ca0ac to 9bdbbc0 Compare February 4, 2026 21:34
Copy link
Copy Markdown
Collaborator

@lukasmasuch lukasmasuch left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@sfc-gh-bnisco sfc-gh-bnisco force-pushed the 01-22-_feat_add_external_url_runner_in_e2e_playwright branch from bf9998a to 8a999a0 Compare February 12, 2026 00:42
@sfc-gh-bnisco sfc-gh-bnisco force-pushed the 01-22-_feat_add_app_target branch from 9bdbbc0 to 5383b0c Compare February 12, 2026 00:42
@sfc-gh-bnisco
Copy link
Copy Markdown
Collaborator Author

sfc-gh-bnisco commented Feb 12, 2026

Merge activity

  • Feb 12, 8:25 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Feb 12, 8:27 PM UTC: Graphite rebased this pull request as part of a merge.
  • Feb 12, 9:08 PM UTC: @sfc-gh-bnisco merged this pull request with Graphite.

@sfc-gh-bnisco sfc-gh-bnisco changed the base branch from 01-22-_feat_add_external_url_runner_in_e2e_playwright to graphite-base/13737 February 12, 2026 20:25
@sfc-gh-bnisco sfc-gh-bnisco changed the base branch from graphite-base/13737 to develop February 12, 2026 20:25
@sfc-gh-bnisco sfc-gh-bnisco force-pushed the 01-22-_feat_add_app_target branch from 5383b0c to 1392ea3 Compare February 12, 2026 20:26
@sfc-gh-bnisco sfc-gh-bnisco merged commit 352c4c1 into develop Feb 12, 2026
43 of 44 checks passed
@sfc-gh-bnisco sfc-gh-bnisco deleted the 01-22-_feat_add_app_target branch February 12, 2026 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:feature PR contains new feature or enhancement implementation impact:internal PR changes only affect internal code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants