Skip to content

High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.

fix: use same wait_for_instance_ready as curl-based tests

Bosch3ef806629497
diff --git a/tests/e2e/scenarios-cli/common.sh b/tests/e2e/scenarios-cli/common.sh
index 4aab83fc..07655456 100755
--- a/tests/e2e/scenarios-cli/common.sh
+++ b/tests/e2e/scenarios-cli/common.sh
@@ -22,8 +22,34 @@ ASSERTIONS_PASSED=0
ASSERTIONS_FAILED=0
CURRENT_TEST=""
-# Extract host:port from URL for CLI
-PINCHTAB_HOST=$(echo "$PINCHTAB_URL" | sed 's|http://||' | cut -d'/' -f1)
+# ─────────────────────────────────────────────────────────────────
+# Wait for instance ready (same as curl-based tests)
+# ─────────────────────────────────────────────────────────────────
+
+wait_for_instance_ready() {
+ local base_url="$1"
+ local timeout_sec="${2:-60}"
+ local started_at
+ started_at=$(date +%s)
+
+ while true; do
+ local now
+ now=$(date +%s)
+ if [ $((now - started_at)) -ge "$timeout_sec" ]; then
+ echo -e " ${RED}✗${NC} instance at ${base_url} did not reach running within ${timeout_sec}s"
+ return 1
+ fi
+
+ local inst_status
+ inst_status=$(curl -sf "${base_url}/health" 2>/dev/null | jq -r '.defaultInstance.status // empty' 2>/dev/null || true)
+ if [ "$inst_status" = "running" ]; then
+ echo -e " ${GREEN}✓${NC} instance ready at ${base_url}"
+ return 0
+ fi
+
+ sleep 1
+ done
+}
# ─────────────────────────────────────────────────────────────────
# Test lifecycle
diff --git a/tests/e2e/scenarios-cli/run-all.sh b/tests/e2e/scenarios-cli/run-all.sh
index 87e61435..52451dc1 100755
--- a/tests/e2e/scenarios-cli/run-all.sh
+++ b/tests/e2e/scenarios-cli/run-all.sh
@@ -16,26 +16,8 @@ echo " Server: $PINCHTAB_URL"
echo " Fixtures: $FIXTURES_URL"
echo ""
-# Wait for server AND instance to be ready
-echo "Waiting for pinchtab server..."
-for i in $(seq 1 30); do
- if curl -s "$PINCHTAB_URL/health" > /dev/null 2>&1; then
- echo "Server responding..."
- break
- fi
- sleep 1
-done
-
-echo "Waiting for Chrome instance to be ready..."
-for i in $(seq 1 60); do
- # Try a simple snapshot - if it works, Chrome is ready
- if PINCHTAB_URL="$PINCHTAB_URL" pinchtab health 2>/dev/null | grep -q '"ready":true'; then
- echo "Instance ready!"
- break
- fi
- echo " waiting... ($i/60)"
- sleep 2
-done
+# Wait for instance to be ready (same as curl-based tests)
+wait_for_instance_ready "$PINCHTAB_URL"
# Verify pinchtab CLI is available
if ! command -v pinchtab &> /dev/null; then