test(ui): Wait for Brain to boot before launching TUI
Some checks failed
Deploy-Agent-V15-Stdin / JOB-V15-STDIN (push) Failing after 2s

This commit is contained in:
2026-04-19 19:16:58 -04:00
parent 7bd58d7089
commit f296d1ca1c

59
tests/ui_tui_test.py Normal file
View File

@@ -0,0 +1,59 @@
import sys
import os
import time
# Add scripts directory to path to import ui_driver
sys.path.append(os.path.join(os.getcwd(), 'scripts'))
from ui_driver import run_test
def wait_for_brain():
print("[UI TEST] Waiting for Brain to wake up...")
for i in range(60):
if os.path.exists('brain.log'):
with open('brain.log', 'r') as f:
if 'Boot Complete' in f.read():
print("[UI TEST] Brain is Green.")
return True
time.sleep(2)
return False
def test_tui_boot_and_input():
if not wait_for_brain():
print("FAIL: Brain failed to boot within timeout.")
return
print("[UI TEST] Launching TUI and sending 'Hi'...")
# We run the TUI script via bash
command = ["bash", "opencortex.sh", "tui"]
vt = run_test(command, "Hi\r", wait_time=15)
screen = vt.get_screen()
# 1. Verify Prompt
if "> Hi" in screen:
print("PASS: Local Echo found in chat history.")
elif ">" in screen:
print("PASS: Input prompt found.")
else:
print("FAIL: No input prompt found.")
# 2. Verify Status Bar
if "[Scribe:" in screen and "Gardener:" in screen:
print("PASS: Status bar rendered correctly.")
else:
print("FAIL: Status bar missing.")
# 3. Verify Cursor Position (should be at the end of the empty prompt after Enter)
# The prompt is line 23 (h-1), col 2 (after "> ")
if vt.cursor_y == 23 and vt.cursor_x == 2:
print(f"PASS: Cursor is correctly pinned to prompt at ({vt.cursor_y}, {vt.cursor_x}).")
else:
print(f"WARN: Cursor at unexpected position ({vt.cursor_y}, {vt.cursor_x}).")
print("\n--- FINAL SCREEN SNAPSHOT ---")
print(screen)
if __name__ == "__main__":
test_tui_boot_and_input()