feat(tests): Migrate manual launchers to live_gui fixture and consolidate visual tests
This commit is contained in:
79
tests/test_visual_orchestration.py
Normal file
79
tests/test_visual_orchestration.py
Normal file
@@ -0,0 +1,79 @@
|
||||
import pytest
|
||||
import time
|
||||
import sys
|
||||
import os
|
||||
|
||||
# Ensure project root is in path
|
||||
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
|
||||
|
||||
from api_hook_client import ApiHookClient
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_mma_epic_lifecycle(live_gui) -> None:
|
||||
"""
|
||||
Integration test for the full MMA Epic lifecycle.
|
||||
1. Start App.
|
||||
2. Trigger 'New Epic' request.
|
||||
3. Verify Tier 1 generates tracks.
|
||||
4. Trigger 'Start Track' for one of the tracks.
|
||||
5. Verify Tier 2 generates tickets.
|
||||
6. Verify execution loop starts.
|
||||
"""
|
||||
client = ApiHookClient()
|
||||
assert client.wait_for_server(timeout=15), "API hook server failed to start."
|
||||
print("[Test] Initializing MMA Epic lifecycle test...")
|
||||
# 0. Setup: Ensure we have a project and are in a clean state
|
||||
client.click("btn_reset")
|
||||
time.sleep(1)
|
||||
# 1. Set Epic input
|
||||
epic_text = "Improve the logging system to include timestamps in all tool calls."
|
||||
print(f"[Test] Setting Epic input: {epic_text}")
|
||||
client.set_value("mma_epic_input", epic_text)
|
||||
# 2. Trigger 'New Epic' (Plan Epic)
|
||||
print("[Test] Clicking 'Plan Epic (Tier 1)'...")
|
||||
client.click("btn_mma_plan_epic")
|
||||
# 3. Verify that Tier 1 generates tracks
|
||||
print("[Test] Polling for Tier 1 tracks...")
|
||||
tracks_generated = False
|
||||
for i in range(120):
|
||||
status = client.get_value("ai_status")
|
||||
# Check if the proposal modal is shown or status changed
|
||||
if status and "Epic tracks generated" in str(status):
|
||||
tracks_generated = True
|
||||
print(f"[Test] Tracks generated after {i}s")
|
||||
break
|
||||
time.sleep(1)
|
||||
assert tracks_generated, "Tier 1 failed to generate tracks within 60 seconds."
|
||||
# 4. Trigger 'Start Track' for the first track
|
||||
print("[Test] Triggering 'Start Track' for track index 0...")
|
||||
client.click("btn_mma_start_track", user_data={"index": 0})
|
||||
# 5. Verify that Tier 2 generates tickets and starts execution
|
||||
print("[Test] Polling for Tier 2 ticket generation and execution start...")
|
||||
execution_started = False
|
||||
for i in range(60):
|
||||
mma_status = client.get_mma_status()
|
||||
status_str = mma_status.get("mma_status", "idle")
|
||||
active_tier = mma_status.get("active_tier", "")
|
||||
if status_str == "running" or "Tier 3" in str(active_tier):
|
||||
execution_started = True
|
||||
print(f"[Test] Execution started (Status: {status_str}, Tier: {active_tier}) after {i}s")
|
||||
break
|
||||
current_ai_status = client.get_value("ai_status")
|
||||
if i % 5 == 0:
|
||||
print(f" ... still waiting. Current AI Status: {current_ai_status}")
|
||||
time.sleep(1)
|
||||
assert execution_started, "Tier 2 failed to generate tickets or execution failed to start within 60 seconds."
|
||||
# 6. Final verification of MMA state
|
||||
final_mma = client.get_mma_status()
|
||||
print(f"[Test] Final MMA Status: {final_mma.get('mma_status')}")
|
||||
print(f"[Test] Active Tier: {final_mma.get('active_tier')}")
|
||||
print(f"[Test] Ticket Count: {len(final_mma.get('active_tickets', []))}")
|
||||
assert final_mma.get("mma_status") in ["running", "done", "blocked"]
|
||||
assert len(final_mma.get("active_tickets", [])) > 0
|
||||
print("[Test] MMA Epic lifecycle verification successful!")
|
||||
|
||||
if __name__ == "__main__":
|
||||
# If run directly, try to use pytest
|
||||
import subprocess
|
||||
# Using sys.executable to ensure we use the same environment
|
||||
subprocess.run([sys.executable, "-m", "pytest", "-v", __file__])
|
||||
Reference in New Issue
Block a user