-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathweb-ui-smoke.sh
More file actions
executable file
·89 lines (77 loc) · 2.59 KB
/
Copy pathweb-ui-smoke.sh
File metadata and controls
executable file
·89 lines (77 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env bash
# Backend smoke probes for the web UI — boot the app, hit every
# route a human reviewer would click, assert expected status, exit
# non-zero on any failure.
#
# Usage: bash tests/web-ui-smoke.sh
# Env: WORKSPACE_PATH, CLI_CHATS_PATH inherited from the calling shell.
set -u
PORT="${CLAW_QA_PORT:-3001}" # use 3001 so a running 3000 instance isn't disturbed
BASE="http://127.0.0.1:${PORT}"
LOG=$(mktemp)
trap "rm -f $LOG" EXIT
cd "$(dirname "$0")/.." || exit 1
# Boot the app in the background on the chosen port.
python3 app.py --port "$PORT" > "$LOG" 2>&1 &
APP_PID=$!
trap "kill $APP_PID 2>/dev/null; rm -f $LOG" EXIT
# Wait up to 15s for /api/workspaces to respond.
for i in $(seq 1 30); do
if curl -sf -o /dev/null "$BASE/api/workspaces"; then break; fi
sleep 0.5
done
if ! curl -sf -o /dev/null "$BASE/api/workspaces"; then
echo "[FAIL] app never became responsive on $PORT"
echo "--- boot log ---"; cat "$LOG"
exit 1
fi
fail=0
probe() {
local label="$1" url="$2" expect="$3"
local code
code=$(curl -s -o /dev/null -w "%{http_code}" "$BASE$url")
if [ "$code" = "$expect" ]; then
printf " [pass] %-44s %s (expected %s)\n" "$label" "$code" "$expect"
else
printf " [FAIL] %-44s %s (expected %s)\n" "$label" "$code" "$expect"
fail=$((fail + 1))
fi
}
echo "=== Page routes ==="
probe "/" "/" 200
probe "/search" "/search" 200
probe "/config" "/config" 200
echo ""
echo "=== JSON API ==="
probe "/api/workspaces" "/api/workspaces" 200
probe "/api/composers" "/api/composers" 200
probe "/api/detect-environment" "/api/detect-environment" 200
probe "/api/search?q=foo" "/api/search?q=foo" 200
probe "/api/search (no q -> 400)" "/api/search" 400
WS_ID=$(curl -s "$BASE/api/workspaces" | python3 -c "
import sys, json
data = json.load(sys.stdin)
for w in data:
if w.get('id') and w['id'] != 'global':
print(w['id'])
break
" 2>/dev/null)
if [ -n "$WS_ID" ]; then
echo ""
echo "=== Workspace-scoped routes (WS=$WS_ID) ==="
probe "/workspace/<id>" "/workspace/$WS_ID" 200
probe "/api/workspaces/<id>" "/api/workspaces/$WS_ID" 200
probe "/api/workspaces/<id>/tabs" "/api/workspaces/$WS_ID/tabs" 200
else
echo ""
echo "[skip] no non-global workspace found; workspace-scoped probes skipped"
fi
echo ""
if [ "$fail" -eq 0 ]; then
echo "all smoke probes pass"
exit 0
else
echo "$fail probe(s) failed — see /tmp boot log for context"
echo "--- boot log tail ---"; tail -20 "$LOG"
exit 1
fi