tests: flexible TUI handshake test (v[0-9] not v0.x), true agent round-trip with ⬇ marker
Some checks failed
Deploy (Gitea) / deploy (push) Failing after 3s
Some checks failed
Deploy (Gitea) / deploy (push) Failing after 3s
This commit is contained in:
@@ -330,10 +330,36 @@ tmux new-session -d -s tui-test "passepartout tui 2>&1 | tee $TUI_LOG"
|
|||||||
sleep 4
|
sleep 4
|
||||||
|
|
||||||
# ---- Tests ----
|
# ---- Tests ----
|
||||||
test_renders_input() {
|
|
||||||
tmux send-keys -t tui-test "hello world" Enter
|
test_handshake() {
|
||||||
sleep 2
|
# The TUI receives a handshake from the daemon on connect
|
||||||
grep -q 'hello world' "$TUI_LOG"
|
# and renders "Connected v<version>" in the log/chat area.
|
||||||
|
grep -q 'Connected v[0-9]' "$TUI_LOG"
|
||||||
|
}
|
||||||
|
|
||||||
|
test_agent_responds() {
|
||||||
|
# Send text to the TUI and wait for an agent (⬇) response.
|
||||||
|
# This proves the full round-trip: TUI → daemon → pipeline → TUI.
|
||||||
|
# The response may be a cascade failure message (no API key)
|
||||||
|
# or a real LLM reply — either way, ⬇ proves the daemon responded.
|
||||||
|
local before_ts
|
||||||
|
before_ts=$(date +%s)
|
||||||
|
|
||||||
|
tmux send-keys -t tui-test "hello" Enter
|
||||||
|
|
||||||
|
# Wait up to 20 seconds for ⬇ to appear
|
||||||
|
while true; do
|
||||||
|
if grep -q '⬇.*[a-zA-Z]\{3,\}' "$TUI_LOG"; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
local now_ts
|
||||||
|
now_ts=$(date +%s)
|
||||||
|
if (( now_ts - before_ts > 20 )); then
|
||||||
|
echo "TIMEOUT: no agent response in log" >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
test_eval_command() {
|
test_eval_command() {
|
||||||
@@ -354,9 +380,10 @@ test_connection_drop() {
|
|||||||
grep -qi 'connection.*lost\|ERROR.*Connection' "$TUI_LOG"
|
grep -qi 'connection.*lost\|ERROR.*Connection' "$TUI_LOG"
|
||||||
}
|
}
|
||||||
|
|
||||||
run_test "renders-input" test_renders_input
|
run_test "handshake" test_handshake
|
||||||
run_test "eval-command" test_eval_command
|
run_test "agent-responds" test_agent_responds
|
||||||
run_test "status-bar" test_status_bar
|
run_test "eval-command" test_eval_command
|
||||||
|
run_test "status-bar" test_status_bar
|
||||||
run_test "connection-drop" test_connection_drop
|
run_test "connection-drop" test_connection_drop
|
||||||
|
|
||||||
# ---- Summary ----
|
# ---- Summary ----
|
||||||
|
|||||||
@@ -35,10 +35,36 @@ tmux new-session -d -s tui-test "passepartout tui 2>&1 | tee $TUI_LOG"
|
|||||||
sleep 4
|
sleep 4
|
||||||
|
|
||||||
# ---- Tests ----
|
# ---- Tests ----
|
||||||
test_renders_input() {
|
|
||||||
tmux send-keys -t tui-test "hello world" Enter
|
test_handshake() {
|
||||||
sleep 2
|
# The TUI receives a handshake from the daemon on connect
|
||||||
grep -q 'hello world' "$TUI_LOG"
|
# and renders "Connected v<version>" in the log/chat area.
|
||||||
|
grep -q 'Connected v[0-9]' "$TUI_LOG"
|
||||||
|
}
|
||||||
|
|
||||||
|
test_agent_responds() {
|
||||||
|
# Send text to the TUI and wait for an agent (⬇) response.
|
||||||
|
# This proves the full round-trip: TUI → daemon → pipeline → TUI.
|
||||||
|
# The response may be a cascade failure message (no API key)
|
||||||
|
# or a real LLM reply — either way, ⬇ proves the daemon responded.
|
||||||
|
local before_ts
|
||||||
|
before_ts=$(date +%s)
|
||||||
|
|
||||||
|
tmux send-keys -t tui-test "hello" Enter
|
||||||
|
|
||||||
|
# Wait up to 20 seconds for ⬇ to appear
|
||||||
|
while true; do
|
||||||
|
if grep -q '⬇.*[a-zA-Z]\{3,\}' "$TUI_LOG"; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
local now_ts
|
||||||
|
now_ts=$(date +%s)
|
||||||
|
if (( now_ts - before_ts > 20 )); then
|
||||||
|
echo "TIMEOUT: no agent response in log" >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
test_eval_command() {
|
test_eval_command() {
|
||||||
@@ -59,9 +85,10 @@ test_connection_drop() {
|
|||||||
grep -qi 'connection.*lost\|ERROR.*Connection' "$TUI_LOG"
|
grep -qi 'connection.*lost\|ERROR.*Connection' "$TUI_LOG"
|
||||||
}
|
}
|
||||||
|
|
||||||
run_test "renders-input" test_renders_input
|
run_test "handshake" test_handshake
|
||||||
run_test "eval-command" test_eval_command
|
run_test "agent-responds" test_agent_responds
|
||||||
run_test "status-bar" test_status_bar
|
run_test "eval-command" test_eval_command
|
||||||
|
run_test "status-bar" test_status_bar
|
||||||
run_test "connection-drop" test_connection_drop
|
run_test "connection-drop" test_connection_drop
|
||||||
|
|
||||||
# ---- Summary ----
|
# ---- Summary ----
|
||||||
|
|||||||
Reference in New Issue
Block a user