Skip to content

Commit 299b312

Browse files
committed
test(e2e): address review feedback on dashboard reachability
Poll port-bound check (TC-DASH-01) since `openshell forward start --background` forks and returns before the port is bound. Soften body-marker check (TC-DASH-03) to WARN+pass on missing marker so SPA shells don't trip the assertion while still hard-failing on non-HTML responses. Remove dead TIMEOUT_CMD detection. Signed-off-by: Evan Takahashi <evan10takahashi@gmail.com>
1 parent 4e4a05d commit 299b312

1 file changed

Lines changed: 20 additions & 24 deletions

File tree

test/e2e/test-dashboard-reachability.sh

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,6 @@ POLL_ATTEMPTS=30
3333
POLL_INTERVAL=1
3434
LOG_FILE="test-dashboard-reachability-$(date +%Y%m%d-%H%M%S).log"
3535

36-
# macOS uses gtimeout (from coreutils); Linux uses timeout
37-
if command -v gtimeout &>/dev/null; then
38-
TIMEOUT_CMD="gtimeout"
39-
elif command -v timeout &>/dev/null; then
40-
TIMEOUT_CMD="timeout"
41-
else
42-
echo "ERROR: Neither timeout nor gtimeout found. Install coreutils: brew install coreutils"
43-
exit 1
44-
fi
45-
4636
RED='\033[0;31m'
4737
GREEN='\033[0;32m'
4838
YELLOW='\033[1;33m'
@@ -171,7 +161,6 @@ preflight() {
171161
log "nemoclaw: $(nemoclaw --version 2>/dev/null || echo 'unknown')"
172162
log "openshell: $(openshell --version 2>&1 | head -1 || echo 'unknown')"
173163
log "dashboard port: $DASHBOARD_PORT"
174-
log "timeout: $TIMEOUT_CMD"
175164

176165
if [[ -f "$HOME/.nemoclaw/onboard.lock" ]]; then
177166
log "Removing stale onboard lock"
@@ -216,15 +205,24 @@ setup_sandbox() {
216205
# Confirms the port-forward exists before we try HTTP. Separating this from
217206
# the HTTP check gives a clearer failure signal: if the port is not bound at
218207
# all, it's a forward-layer problem, not a gateway-process problem.
208+
#
209+
# Polls because `openshell forward start --background` forks and returns
210+
# before the child has actually bound the port (see src/lib/onboard.ts,
211+
# ensureDashboardForward).
219212
test_dash_01_port_bound() {
220213
log "=== TC-DASH-01: Dashboard port bound on host ==="
221214

222-
if lsof -iTCP:"$DASHBOARD_PORT" -sTCP:LISTEN >/dev/null 2>&1; then
223-
pass "TC-DASH-01: Port $DASHBOARD_PORT is bound"
224-
else
225-
fail "TC-DASH-01: Dashboard port bound" \
226-
"Nothing listening on $DASHBOARD_PORT — port-forward not established"
227-
fi
215+
local i
216+
for i in $(seq 1 "$POLL_ATTEMPTS"); do
217+
if lsof -iTCP:"$DASHBOARD_PORT" -sTCP:LISTEN >/dev/null 2>&1; then
218+
pass "TC-DASH-01: Port $DASHBOARD_PORT is bound (after ${i}s)"
219+
return
220+
fi
221+
sleep "$POLL_INTERVAL"
222+
done
223+
224+
fail "TC-DASH-01: Dashboard port bound" \
225+
"Nothing listening on $DASHBOARD_PORT after ${POLL_ATTEMPTS}s — port-forward not established"
228226
}
229227

230228
# ── TC-DASH-02: Dashboard returns HTTP 200 ──────────────────────────────────
@@ -251,9 +249,9 @@ test_dash_02_http_200() {
251249
}
252250

253251
# ── TC-DASH-03: Response body signature ─────────────────────────────────────
254-
# Guards against an unrelated process binding the dashboard port. The real
255-
# OpenClaw dashboard is an HTML page identifying itself in the body; any
256-
# other service returning 200 would not match.
252+
# Guards against an unrelated process binding the dashboard port. The
253+
# structural HTML check is the fail gate; the marker check is soft because
254+
# the dashboard may be an SPA whose raw HTML has no visible branding.
257255
test_dash_03_body_signature() {
258256
log "=== TC-DASH-03: Response body signature ==="
259257

@@ -265,19 +263,17 @@ test_dash_03_body_signature() {
265263
return
266264
fi
267265

268-
# Primary: looks like HTML.
269266
if ! echo "$body" | grep -qiE '<html|<!doctype'; then
270267
fail "TC-DASH-03: Body signature" \
271268
"Response is not HTML — something else is bound to $DASHBOARD_PORT"
272269
return
273270
fi
274271

275-
# Secondary: body or <title> contains an OpenClaw / Control UI marker.
276272
if echo "$body" | grep -qiE 'openclaw|control[- ]?ui|nemoclaw'; then
277273
pass "TC-DASH-03: Response body identifies as OpenClaw dashboard"
278274
else
279-
fail "TC-DASH-03: Body signature" \
280-
"HTML served but no OpenClaw/Control-UI marker in body"
275+
log " ${YELLOW}WARN${NC} No OpenClaw/Control-UI marker in HTML body (may be SPA shell)"
276+
pass "TC-DASH-03: HTML served on $DASHBOARD_PORT"
281277
fi
282278
}
283279

0 commit comments

Comments
 (0)