diff --git a/tests/test_gui2_parity.py b/tests/test_gui2_parity.py index 9a0ecf94..483e4698 100644 --- a/tests/test_gui2_parity.py +++ b/tests/test_gui2_parity.py @@ -42,20 +42,30 @@ def test_gui2_set_value_hook_works(live_gui: Any) -> None: def test_gui2_click_hook_works(live_gui: Any) -> None: """ - - - Tests that the 'click' GUI hook for the 'Reset' button is implemented. + Tests that the 'click' GUI hook for the 'Reset' button is implemented. """ client = ApiHookClient() assert client.wait_for_server(timeout=10) # First, set some state that 'Reset' would clear. test_value = "This text should be cleared by the reset button." client.set_value('ai_input', test_value) - time.sleep(1.5) + # Poll for the set_value to propagate through the gui task queue + # (per workflow's race-condition anti-pattern guidance: time.sleep + assert + # is a guaranteed race in batched runs). + deadline = time.time() + 10.0 + while time.time() < deadline: + if client.get_value('ai_input') == test_value: + break + time.sleep(0.1) assert client.get_value('ai_input') == test_value # Now, trigger the click client.click('btn_reset') - time.sleep(1.5) + # Poll for the reset click to propagate (and verify the value clears). + deadline = time.time() + 10.0 + while time.time() < deadline: + if client.get_value('ai_input') == "": + break + time.sleep(0.1) # Verify it was reset assert client.get_value('ai_input') == "" def test_gui2_custom_callback_hook_works(live_gui: Any) -> None: