feat(tests): Migrate manual launchers to live_gui fixture and consolidate visual tests
This commit is contained in:
71
tests/test_visual_mma.py
Normal file
71
tests/test_visual_mma.py
Normal file
@@ -0,0 +1,71 @@
|
||||
import pytest
|
||||
import time
|
||||
from api_hook_client import ApiHookClient
|
||||
|
||||
def test_visual_mma_components(live_gui):
|
||||
"""
|
||||
Refactored visual MMA verification using the live_gui fixture.
|
||||
Ensures the MMA dashboard and tickets are correctly rendered.
|
||||
"""
|
||||
# live_gui is a tuple (process, script_name)
|
||||
_, gui_script = live_gui
|
||||
print(f"Testing visual MMA components on {gui_script}...")
|
||||
|
||||
# 1. Initialize ApiHookClient
|
||||
# The fixture ensures the server is already ready
|
||||
client = ApiHookClient()
|
||||
print("ApiHookClient initialized successfully.")
|
||||
|
||||
# 2. Setup MMA data
|
||||
track_data = {
|
||||
"id": "visual_test_track",
|
||||
"title": "Visual Verification Track",
|
||||
"description": "A track to verify MMA UI components"
|
||||
}
|
||||
tickets_data = [
|
||||
{"id": "TICKET-001", "target_file": "core.py", "status": "todo"},
|
||||
{"id": "TICKET-002", "target_file": "utils.py", "status": "running"},
|
||||
{"id": "TICKET-003", "target_file": "tests.py", "status": "complete"},
|
||||
{"id": "TICKET-004", "target_file": "api.py", "status": "blocked"},
|
||||
{"id": "TICKET-005", "target_file": "gui.py", "status": "paused"},
|
||||
]
|
||||
|
||||
print("\nPushing MMA state update...")
|
||||
payload = {
|
||||
"status": "running",
|
||||
"active_tier": "Tier 3",
|
||||
"track": track_data,
|
||||
"tickets": tickets_data
|
||||
}
|
||||
client.push_event("mma_state_update", payload)
|
||||
print(" - MMA state update pushed.")
|
||||
|
||||
# Use ApiHookClient.wait_for_event if we had a specific event to wait for,
|
||||
# but here we just want to verify state.
|
||||
time.sleep(1) # Small sleep for UI to catch up with event queue
|
||||
|
||||
# 3. Trigger HITL modal
|
||||
print("Pushing 'mma_step_approval' event to trigger HITL modal...")
|
||||
approval_payload = {
|
||||
"ticket_id": "TICKET-002",
|
||||
"payload": "powershell -Command \"Write-Host 'Hello from Tier 3'\""
|
||||
}
|
||||
client.push_event("mma_step_approval", approval_payload)
|
||||
print("mma_step_approval event pushed successfully.")
|
||||
|
||||
# 4. Assertions
|
||||
# We can verify internal state via get_value if hooks are available
|
||||
# For now, we verify the push was successful (it would raise if not)
|
||||
# and we can check some values that should have changed.
|
||||
active_tier = client.get_value("mma_active_tier")
|
||||
assert active_tier == "Tier 3"
|
||||
|
||||
# Verify ticket count if possible
|
||||
# mma_tickets might be a complex object, we'll see if get_value handles it
|
||||
tickets = client.get_value("mma_tickets")
|
||||
if tickets:
|
||||
assert len(tickets) == 5
|
||||
assert tickets[1]['id'] == "TICKET-002"
|
||||
assert tickets[1]['status'] == "running"
|
||||
|
||||
print("Visual MMA component verification PASSED.")
|
||||
Reference in New Issue
Block a user