diff --git a/tests/playwright.py b/tests/playwright.py index b5968c3..a2acb47 100644 --- a/tests/playwright.py +++ b/tests/playwright.py @@ -188,7 +188,14 @@ def test_e2e(search_function, label: str, i: int, status: StatusType, page: Page ###### 3. search for term x and select first option ###### search_term = "x" - search_result = search_function(search_term)[0] + # NOTE: do not use first result, otherwise the highlighting will always be correct + # and it's unclear if the selection locator is working as intended + search_result = search_function(search_term)[1] + + if not isinstance(search_result, tuple): + search_text = str(search_result) + else: + search_text = str(search_result[0]) loc_searchbox.focus() loc_searchbox.fill(search_term) @@ -202,17 +209,12 @@ def test_e2e(search_function, label: str, i: int, status: StatusType, page: Page ###### 4. check if the option is displayed ###### - if not isinstance(search_result, tuple): - search_text = str(search_result) - else: - search_text = str(search_result[0]) - - l_option = frame(page, i).wait_for_selector(f"text={search_text}", state="attached") + l_option = frame(page, i).locator(f"[role='option'] >> text={search_text}") - assert l_option is not None + if l_option.count() == 0: + assert False, f"option not found: {search_text}" - l_option.focus() - l_option.press("Enter") + l_option.click() wait_for_streamlit(page) diff --git a/tests/utils.py b/tests/utils.py index 21061f6..b69445f 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -87,27 +87,21 @@ def selection_to_text(result): ), dict( search_function=search, - default=None, label=search.__name__, - clear_on_submit=True, key=search.__name__, ), dict( search_function=search_rnd_delay, - default=None, - clear_on_submit=False, label=search_rnd_delay.__name__, key=search_rnd_delay.__name__, ), dict( search_function=search_enum_return, - clear_on_submit=True, key=search_enum_return.__name__, label=search_enum_return.__name__, ), dict( search_function=search_empty_list, - clear_on_submit=True, key=search_empty_list.__name__, label=search_empty_list.__name__, ),