forked from streamlit/streamlit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate redisplayed widgets test to playwright (streamlit#8894)
## Describe your changes Migrates the redisplayed_widgets cypress e2e test to playwright and merges it with the `widget_state_heavy_usage` test into one test. --- **Contribution License Agreement** By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.
- Loading branch information
1 parent
b09b419
commit 51cd0c9
Showing
7 changed files
with
96 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2024) | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from playwright.sync_api import Page, expect | ||
|
||
from e2e_playwright.shared.app_utils import click_checkbox, expect_markdown | ||
|
||
|
||
def test_clicking_a_lot_still_keeps_state(app: Page): | ||
"""Test the the widget state is correctly handled on very fast clicks. | ||
Related to: https://github.com/streamlit/streamlit/issues/4836 | ||
""" | ||
number_input_down_button = app.get_by_test_id("stNumberInput").locator( | ||
"button.step-up" | ||
) | ||
for _ in range(40): | ||
number_input_down_button.click() | ||
|
||
expect_markdown(app, "40") | ||
|
||
|
||
def test_doesnt_save_widget_state_on_redisplay(app: Page): | ||
"""Test that widget state is not saved when a widget is redisplayed | ||
after a rerun. | ||
Related to: https://github.com/streamlit/streamlit/issues/3512 | ||
""" | ||
click_checkbox(app, "Display widgets") | ||
click_checkbox(app, "Show hello") | ||
expect_markdown(app, "hello") | ||
|
||
# Hide widgets: | ||
click_checkbox(app, "Display widgets") | ||
|
||
# Show widgets again: | ||
click_checkbox(app, "Display widgets") | ||
|
||
# Should not show hello again -> the widget state was not saved | ||
markdown_el = app.get_by_test_id("stMarkdown").filter(has_text="hello") | ||
expect(markdown_el).not_to_be_attached() | ||
|
||
|
||
def test_doesnt_save_widget_state_on_redisplay_with_keyed_widget(app: Page): | ||
"""Test that widget state is not saved when a keyed widget is redisplayed | ||
after a rerun. | ||
Related to: https://github.com/streamlit/streamlit/issues/3512 | ||
""" | ||
click_checkbox(app, "Display widgets") | ||
click_checkbox(app, "Show goodbye") | ||
expect_markdown(app, "goodbye") | ||
|
||
# Hide widgets: | ||
click_checkbox(app, "Display widgets") | ||
|
||
# Show widgets again: | ||
click_checkbox(app, "Display widgets") | ||
|
||
# Should not show goodbye again -> the widget state was not saved | ||
markdown_el = app.get_by_test_id("stMarkdown").filter(has_text="goodbye") | ||
expect(markdown_el).not_to_be_attached() |