diff --git a/tests/test_undo_redo_sim.py b/tests/test_undo_redo_sim.py index ceacfeac..b497a0e0 100644 --- a/tests/test_undo_redo_sim.py +++ b/tests/test_undo_redo_sim.py @@ -7,7 +7,7 @@ def test_undo_redo_lifecycle(live_gui): client = ApiHookClient() client.click("btn_reset") time.sleep(2) - + assert client.wait_for_server(timeout=15), "Hook server did not start" # 1. Set initial state @@ -15,16 +15,22 @@ def test_undo_redo_lifecycle(live_gui): client.set_value('temperature', 0.5) client.set_value('ai_input', "Initial Input") - # Wait for settle and first push (S_init -> S0) - time.sleep(3.0) + # Wait for settle and first push (S_init -> S0). + # The render loop's snapshot debounce is 1.5s, but in a shared + # live_gui subprocess the render loop runs much slower due to other + # tests' API calls contending for the main thread. The 8s wait below + # is generous enough to handle batch contention (was 3s; bumped + # after batch run showed undo applied the wrong snapshot, indicating + # the push hadn't fired yet when undo was clicked). + time.sleep(8.0) # 2. Change state print("Modifying state...") client.set_value('temperature', 1.5) client.set_value('ai_input', "Modified Input") - # Wait for settle and second push (S0 -> S1) - time.sleep(3.0) + # Wait for settle and second push (S0 -> S1). Same rationale as above. + time.sleep(8.0) # Verify current state temp = client.get_value('temperature') @@ -36,16 +42,16 @@ def test_undo_redo_lifecycle(live_gui): # 3. Undo (S1 -> S0) print("Sending Undo...") client.click('btn_undo') - time.sleep(2.0) - + time.sleep(4.0) + assert client.get_value('ai_input') == "Initial Input" assert client.get_value('temperature') == 0.5 # 4. Redo (S0 -> S1) print("Sending Redo...") client.click('btn_redo') - time.sleep(2.0) - + time.sleep(4.0) + assert client.get_value('ai_input') == "Modified Input" assert client.get_value('temperature') == 1.5