Skip to content

Conversation

@kmcgrady
Copy link
Collaborator

@kmcgrady kmcgrady commented Oct 19, 2025

Describe your changes

Added end-to-end tests for AppNode hierarchy edge cases to ensure proper element rendering and state management. The tests verify:

  1. Element swapping replaces content in-place without leaving stale elements
  2. Element insertion correctly positions new content between existing elements
  3. Long computations properly handle stale elements during processing
  4. Placeholder updates correctly modify content without duplicating elements

The implementation includes a test app with multiple scenarios and corresponding Playwright tests that validate the expected behavior in each case.

Testing Plan

  • 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
Contributor

snyk-io bot commented Oct 19, 2025

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

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

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

@github-actions
Copy link
Contributor

github-actions bot commented Oct 19, 2025

✅ PR preview is ready!

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

@kmcgrady kmcgrady added change:refactor PR contains code refactoring without behavior change impact:internal PR changes only affect internal code security-assessment-completed Security assessment has been completed for PR labels Oct 19, 2025 — with Graphite App
@kmcgrady kmcgrady force-pushed the 10-19-create_e2e_tests_for_common_appnode_scenarios_not_particularly_tested branch from 48d1cd6 to 50e7ec0 Compare October 19, 2025 16:47
@kmcgrady kmcgrady requested a review from Copilot October 20, 2025 14:13
Copy link
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

This PR adds end-to-end tests for AppNode hierarchy scenarios to improve test coverage of edge cases in the AppNode implementation, which is undergoing significant changes.

Key Changes:

  • New E2E test suite covering four AppNode hierarchy scenarios: element swapping, element insertion, long computations with stale elements, and placeholder updates
  • Test app implementing the scenarios to be tested

Reviewed Changes

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

File Description
e2e_playwright/appnode_hierarchy_test.py E2E tests verifying AppNode hierarchy behavior for element swapping, insertion, stale element handling, and placeholder updates
e2e_playwright/appnode_hierarchy.py Test application providing interactive scenarios for AppNode hierarchy testing

_select_mode(app, "insert_between")

expect(
app.get_by_test_id("stMarkdown").filter(has_text="between")
Copy link

Copilot AI Oct 20, 2025

Choose a reason for hiding this comment

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

The filter has_text='between' will match both 'between' and 'insert_between' text. This assertion may pass unexpectedly if 'insert_between' is present. Use an exact text match or a more specific filter to avoid false positives.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is not true because insert_between is not a markdown element.

@kmcgrady kmcgrady marked this pull request as ready for review October 24, 2025 14:24

get_button(app, "run long compute").click()
# Wait one second to make sure stale elements are there (and styled correctly)
app.wait_for_timeout(1000)
Copy link
Contributor

Choose a reason for hiding this comment

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

The Streamlit E2E Tests guide explicitly prohibits using wait_for_timeout and requires using the wait_until utility instead. Replace app.wait_for_timeout(1000) with wait_until to wait for the specific condition of stale elements appearing with the data-stale attribute.

Spotted by Graphite Agent (based on custom rule: E2E Playwright Tests)

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This review is technically correct, but I am not sure it is possible to wait until the animation to stale ends. Open to ideas here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

If we were getting really strict, we could update our frontend logic that could set a class based on its animation state (eg: {stale-animating-in,stale,stale-animating-out}). Using those, we could write an assertion in the test code that waits for everything to have stale classes. That would probably be the most deterministic and not rely on timeout logic. But, probably not necessary at the moment.

@kmcgrady kmcgrady force-pushed the 10-19-create_e2e_tests_for_common_appnode_scenarios_not_particularly_tested branch 2 times, most recently from 09805fb to 89ad1a4 Compare October 24, 2025 16:42
@kmcgrady kmcgrady force-pushed the 10-19-create_e2e_tests_for_common_appnode_scenarios_not_particularly_tested branch from 89ad1a4 to 6b854af Compare October 24, 2025 16:56

get_button(app, "run long compute").click()
# Wait one second to make sure stale elements are there (and styled correctly)
app.wait_for_timeout(1000)
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we were getting really strict, we could update our frontend logic that could set a class based on its animation state (eg: {stale-animating-in,stale,stale-animating-out}). Using those, we could write an assertion in the test code that waits for everything to have stale classes. That would probably be the most deterministic and not rely on timeout logic. But, probably not necessary at the moment.

@kmcgrady kmcgrady merged commit 16fee06 into develop Oct 27, 2025
39 checks passed
@kmcgrady kmcgrady deleted the 10-19-create_e2e_tests_for_common_appnode_scenarios_not_particularly_tested branch October 27, 2025 22:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:refactor PR contains code refactoring without behavior change impact:internal PR changes only affect internal code security-assessment-completed Security assessment has been completed for PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants