Skip to content

Commit

Permalink
Prepare e2e test for on_change callback
Browse files Browse the repository at this point in the history
  • Loading branch information
raethlein committed May 22, 2024
1 parent 39d3923 commit 6a86336
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
9 changes: 9 additions & 0 deletions e2e_playwright/custom_components/popular_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,22 @@ def use_folium():
def use_option_menu():
from streamlit_option_menu import option_menu

key = "my_option_menu"

# TODO: uncomment the on_change callback as soon as streamlit-option-menu is updated and uses the new on_change callback
# def on_change():
# selection = st.session_state[key]
# st.write(f"Selection changed to {selection}")

with st.sidebar:
selected = option_menu(
"Main Menu",
["Home", "Settings"],
icons=["house", "gear"],
menu_icon="cast",
default_index=1,
key=key,
# on_change=on_change,
)
st.write(selected)

Expand Down
7 changes: 7 additions & 0 deletions e2e_playwright/custom_components/popular_components_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ def test_option_menu(app: Page):
_expect_no_exception(app)
_expect_iframe_attached(app)

# TODO: uncomment the on_change callback as soon as streamlit-option-menu is updated and uses the new on_change callback
# frame_locator = app.frame_locator("iframe")
# frame_locator.locator("a", has_text="Home").click()
# expect(
# app.get_by_test_id("stMarkdown").filter(has_text="Selection changed to Home")
# ).to_be_visible()


def test_url_fragment(app: Page):
"""Test that the url-fragment component renders"""
Expand Down

0 comments on commit 6a86336

Please sign in to comment.