High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.
test(e2e): add lite engine E2E tests
Bosch017d72f98131
diff --git a/tests/e2e/config/pinchtab-lite.json b/tests/e2e/config/pinchtab-lite.jsonnew file mode 100644index 00000000..8d89de05--- /dev/null+++ b/tests/e2e/config/pinchtab-lite.json@@ -0,0 +1,12 @@+{+ "server": {+ "bind": "0.0.0.0",+ "port": "9999",+ "engine": "lite"+ },+ "security": {+ "allowEvaluate": false,+ "allowDownload": false,+ "allowUpload": false+ }+}diff --git a/tests/e2e/docker-compose.yml b/tests/e2e/docker-compose.ymlindex eed14405..c7446aac 100644--- a/tests/e2e/docker-compose.yml+++ b/tests/e2e/docker-compose.yml@@ -42,6 +42,24 @@ services:retries: 20start_period: 15s+ # Lite engine instance: no Chrome, DOM-only (bridge mode)+ pinchtab-lite:+ build:+ context: ../..+ dockerfile: Dockerfile+ environment:+ PINCHTAB_CONFIG: /config/pinchtab-lite.json+ PINCHTAB_PORT: "9999"+ ports:+ - "9997:9999"+ command: ["/usr/local/bin/pinchtab", "bridge"]+ healthcheck:+ test: ["CMD-SHELL", "wget -q -O /dev/null http://localhost:9999/health"]+ interval: 3s+ timeout: 10s+ retries: 20+ start_period: 15s+fixtures:image: nginx:alpinevolumes:@@ -60,11 +78,14 @@ services:condition: service_healthypinchtab-secure:condition: service_healthy+ pinchtab-lite:+ condition: service_healthyfixtures:condition: service_healthyenvironment:- PINCHTAB_URL=http://pinchtab:9999- PINCHTAB_SECURE_URL=http://pinchtab-secure:9999+ - PINCHTAB_LITE_URL=http://pinchtab-lite:9999- FIXTURES_URL=http://fixtures:80volumes:- ./scenarios:/scenarios:rodiff --git a/tests/e2e/scenarios/42-lite-engine.sh b/tests/e2e/scenarios/42-lite-engine.shnew file mode 100755index 00000000..923db72c--- /dev/null+++ b/tests/e2e/scenarios/42-lite-engine.sh@@ -0,0 +1,151 @@+#!/bin/bash+# Test: Lite engine (no Chrome, DOM-only)+# Tests against PINCHTAB_LITE_URL — a pinchtab instance with engine=lite in bridge mode+source "$(dirname "$0")/common.sh"++LITE_URL="${PINCHTAB_LITE_URL:-}"+if [ -z "$LITE_URL" ]; then+ echo " ⚠️ PINCHTAB_LITE_URL not set, skipping lite engine tests"+ return 0 2>/dev/null || exit 0+fi++# Helper: make requests against the lite instance (mirrors pinchtab() but different base URL)+lite() {+ local method="$1"+ local path="$2"+ shift 2+ echo -e "${BLUE}→ curl -X $method ${LITE_URL}$path $(printf "%q " "$@")${NC}" >&2+ local response+ response=$(curl -s -w "\n%{http_code}" \+ -X "$method" \+ "${LITE_URL}${path}" \+ -H "Content-Type: application/json" \+ "$@")+ HTTP_STATUS=$(echo "$response" | tail -1)+ RESULT=$(echo "$response" | sed '$d')+ _echo_truncated+}++lite_get() { lite GET "$1"; }+lite_post() { lite POST "$1" -d "$2"; }++# --- T1: Health check ---+start_test "Lite engine: health check"+lite_get /health+assert_ok "lite health"+end_test++# --- T2: Navigate returns tab ID ---+start_test "Lite engine: navigate returns tabId"+lite_post /navigate "{\"url\":\"${FIXTURES_URL}/index.html\"}"+assert_ok "lite navigate"+TAB_ID=$(echo "$RESULT" | jq -r '.tabId // empty')+if [ -n "$TAB_ID" ]; then+ echo -e " ${GREEN}✓${NC} navigate returned tabId=$TAB_ID"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${RED}✗${NC} navigate missing tabId"+ ((ASSERTIONS_FAILED++)) || true+fi+end_test++# --- T3: Snapshot returns nodes ---+start_test "Lite engine: snapshot returns DOM nodes"+lite_get "/snapshot?tabId=${TAB_ID}"+assert_ok "lite snapshot"+NODE_COUNT=$(echo "$RESULT" | jq '.nodes | length' 2>/dev/null || echo 0)+if [ "$NODE_COUNT" -gt 0 ]; then+ echo -e " ${GREEN}✓${NC} snapshot returned $NODE_COUNT nodes"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${RED}✗${NC} snapshot returned 0 nodes"+ ((ASSERTIONS_FAILED++)) || true+fi+end_test++# --- T4: Text extraction ---+start_test "Lite engine: text extraction"+lite_get "/text?tabId=${TAB_ID}&format=text"+assert_ok "lite text"+assert_contains "$RESULT" "E2E" "text contains page content"+end_test++# --- T5: Interactive filter ---+start_test "Lite engine: interactive filter"+lite_get "/snapshot?tabId=${TAB_ID}&filter=interactive"+assert_ok "lite snapshot interactive"+end_test++# --- T6: Click action routes through lite ---+start_test "Lite engine: click action"++# Get interactive snapshot to find a clickable ref+lite_get "/snapshot?tabId=${TAB_ID}&filter=interactive"+BUTTON_REF=$(echo "$RESULT" | jq -r '[.nodes[] | select(.role == "link" or .role == "button")] | first // empty | .ref // empty')++if [ -n "$BUTTON_REF" ]; then+ lite_post /action "{\"tabId\":\"${TAB_ID}\",\"kind\":\"click\",\"ref\":\"${BUTTON_REF}\"}"+ assert_ok "lite click"+else+ echo -e " ${RED}✗${NC} no interactive element found for click test"+ ((ASSERTIONS_FAILED++)) || true+fi+end_test++# --- T7: Type action routes through lite ---+start_test "Lite engine: type action"++# Navigate to form page which has textboxes+lite_post /navigate "{\"url\":\"${FIXTURES_URL}/form.html\"}"+assert_ok "navigate to form"+TYPE_TAB=$(echo "$RESULT" | jq -r '.tabId // empty')++lite_get "/snapshot?tabId=${TYPE_TAB}&filter=interactive"+INPUT_REF=$(echo "$RESULT" | jq -r '[.nodes[] | select(.role == "textbox")] | first // empty | .ref // empty')++if [ -n "$INPUT_REF" ]; then+ lite_post /action "{\"tabId\":\"${TYPE_TAB}\",\"kind\":\"type\",\"ref\":\"${INPUT_REF}\",\"text\":\"hello\"}"+ assert_ok "lite type"+else+ echo -e " ${RED}✗${NC} no textbox found on form.html"+ ((ASSERTIONS_FAILED++)) || true+fi+end_test++# --- T8: Unsupported action returns 501 ---+start_test "Lite engine: unsupported action returns 501"+lite_post /action "{\"tabId\":\"${TYPE_TAB}\",\"kind\":\"press\",\"ref\":\"e0\",\"key\":\"Enter\"}"+assert_http_status 501 "press returns 501 in lite mode"+end_test++# --- T9: Multi-tab isolation ---+start_test "Lite engine: multi-tab isolation"++lite_post /navigate "{\"url\":\"${FIXTURES_URL}/index.html\"}"+assert_ok "navigate page 1"+TAB_A=$(echo "$RESULT" | jq -r '.tabId // empty')++lite_post /navigate "{\"url\":\"${FIXTURES_URL}/form.html\"}"+assert_ok "navigate page 2"+TAB_B=$(echo "$RESULT" | jq -r '.tabId // empty')++# Verify different tab IDs+if [ "$TAB_A" != "$TAB_B" ]; then+ echo -e " ${GREEN}✓${NC} different tab IDs: $TAB_A vs $TAB_B"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${RED}✗${NC} tabs should have different IDs"+ ((ASSERTIONS_FAILED++)) || true+fi++# Verify tab A still returns page 1 content+lite_get "/text?tabId=${TAB_A}&format=text"+assert_ok "text for tab A"+assert_contains "$RESULT" "E2E Test Suite" "tab A returns index.html content"++# Verify tab B returns page 2 content+lite_get "/text?tabId=${TAB_B}&format=text"+assert_ok "text for tab B"+assert_contains "$RESULT" "Form" "tab B returns form.html content"++end_testdiff --git a/tests/e2e/scenarios/run-recent.sh b/tests/e2e/scenarios/run-recent.shindex ee7a7ede..7494cd0e 100755--- a/tests/e2e/scenarios/run-recent.sh+++ b/tests/e2e/scenarios/run-recent.sh@@ -18,12 +18,16 @@ echo ""echo "Waiting for instances to become ready..."wait_for_instance_ready "${PINCHTAB_URL}"wait_for_instance_ready "${PINCHTAB_SECURE_URL}"+if [ -n "${PINCHTAB_LITE_URL:-}" ]; then+ wait_for_instance_ready "${PINCHTAB_LITE_URL}"+fiecho ""# Recent test files — add new scenarios here for fast CI feedback.# Move to the full suite (run-all.sh) once stable.RECENT_TESTS=("41-extensions.sh"+ "42-lite-engine.sh")for name in "${RECENT_TESTS[@]}"; do