Skip to content

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

refactor: cleaner test format with visible curl commands

Bosch3b532689e9db
diff --git a/tests/e2e/scenarios/01-health.sh b/tests/e2e/scenarios/01-health.sh
index 27dd7110..dd3b5125 100755
--- a/tests/e2e/scenarios/01-health.sh
+++ b/tests/e2e/scenarios/01-health.sh
@@ -1,25 +1,22 @@
#!/bin/bash
-# 01-health.sh - Basic connectivity tests
+# 01-health.sh — Basic connectivity tests
source "$(dirname "$0")/common.sh"
-start_test "Health endpoint"
+# ─────────────────────────────────────────────────────────────────
+start_test "pinchtab health"
-# Test /health returns 200
-assert_status 200 "${PINCHTAB_URL}/health"
-
-# Test /health returns valid JSON
-HEALTH=$(pt_get "/health")
-assert_json_eq "$HEALTH" '.status' 'ok' "status = ok"
+pt_get /health
+assert_json_eq "$RESULT" '.status' 'ok'
end_test
-start_test "Fixtures server"
+# ─────────────────────────────────────────────────────────────────
+start_test "fixtures server"
-# Test fixtures are accessible
-assert_status 200 "${FIXTURES_URL}/"
-assert_status 200 "${FIXTURES_URL}/form.html"
-assert_status 200 "${FIXTURES_URL}/table.html"
-assert_status 200 "${FIXTURES_URL}/buttons.html"
+# Verify test fixtures are accessible
+curl -sf "${FIXTURES_URL}/" > /dev/null && echo -e " ${GREEN}✓${NC} GET ${FIXTURES_URL}/" && ((ASSERTIONS_PASSED++)) || ((ASSERTIONS_FAILED++))
+curl -sf "${FIXTURES_URL}/form.html" > /dev/null && echo -e " ${GREEN}✓${NC} GET ${FIXTURES_URL}/form.html" && ((ASSERTIONS_PASSED++)) || ((ASSERTIONS_FAILED++))
+curl -sf "${FIXTURES_URL}/table.html" > /dev/null && echo -e " ${GREEN}✓${NC} GET ${FIXTURES_URL}/table.html" && ((ASSERTIONS_PASSED++)) || ((ASSERTIONS_FAILED++))
end_test
diff --git a/tests/e2e/scenarios/02-navigate.sh b/tests/e2e/scenarios/02-navigate.sh
index f037d6fc..00750a84 100755
--- a/tests/e2e/scenarios/02-navigate.sh
+++ b/tests/e2e/scenarios/02-navigate.sh
@@ -1,41 +1,37 @@
#!/bin/bash
-# 02-navigate.sh - Navigation and tab creation
+# 02-navigate.sh — Navigation and tab management
source "$(dirname "$0")/common.sh"
-start_test "Navigate to page"
+# ─────────────────────────────────────────────────────────────────
+start_test "pinchtab nav <url>"
-# Navigate to fixtures index
-RESULT=$(pt_post "/navigate" "{\"url\":\"${FIXTURES_URL}/\"}")
-assert_json_contains "$RESULT" '.title' 'E2E Test' "title contains 'E2E Test'"
-assert_json_contains "$RESULT" '.url' 'fixtures' "url contains 'fixtures'"
-
-TAB_ID=$(echo "$RESULT" | jq -r '.tabId')
-[ -n "$TAB_ID" ] && echo -e " ${GREEN}✓${NC} Got tabId: ${TAB_ID:0:8}..."
+pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/\"}"
+assert_json_contains "$RESULT" '.title' 'E2E Test'
+assert_json_contains "$RESULT" '.url' 'fixtures'
end_test
-start_test "Navigate to multiple pages"
+# ─────────────────────────────────────────────────────────────────
+start_test "pinchtab nav (multiple pages)"
-# Navigate to form page
-RESULT1=$(pt_post "/navigate" "{\"url\":\"${FIXTURES_URL}/form.html\"}")
-assert_json_contains "$RESULT1" '.title' 'Form' "form page loaded"
+pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/form.html\"}"
+assert_json_contains "$RESULT" '.title' 'Form'
-# Navigate to table page
-RESULT2=$(pt_post "/navigate" "{\"url\":\"${FIXTURES_URL}/table.html\"}")
-assert_json_contains "$RESULT2" '.title' 'Table' "table page loaded"
+pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/table.html\"}"
+assert_json_contains "$RESULT" '.title' 'Table'
end_test
-start_test "List tabs"
+# ─────────────────────────────────────────────────────────────────
+start_test "pinchtab tabs"
-# Get all tabs
-TABS=$(pt_get "/tabs")
-assert_json_length_gte "$TABS" '.tabs' 2 "at least 2 tabs exist"
+pt_get /tabs
+assert_json_length_gte "$RESULT" '.tabs' 2
-# Verify tabs have required fields
-FIRST_TAB=$(echo "$TABS" | jq '.tabs[0]')
-assert_json_contains "$FIRST_TAB" '.id' '' "tab has id"
-assert_json_contains "$FIRST_TAB" '.url' 'http' "tab has url"
+# Verify tab structure
+FIRST_TAB=$(echo "$RESULT" | jq '.tabs[0]')
+assert_json_contains "$FIRST_TAB" '.id' ''
+assert_json_contains "$FIRST_TAB" '.url' 'http'
end_test
diff --git a/tests/e2e/scenarios/03-snapshot.sh b/tests/e2e/scenarios/03-snapshot.sh
index 9ebf324d..e2fcc655 100755
--- a/tests/e2e/scenarios/03-snapshot.sh
+++ b/tests/e2e/scenarios/03-snapshot.sh
@@ -1,55 +1,53 @@
#!/bin/bash
-# 03-snapshot.sh - Accessibility tree extraction
+# 03-snapshot.sh — Accessibility tree and text extraction
source "$(dirname "$0")/common.sh"
-start_test "Snapshot current page"
+# ─────────────────────────────────────────────────────────────────
+start_test "pinchtab snap"
-# Navigate to a page first
-pt_post "/navigate" "{\"url\":\"${FIXTURES_URL}/\"}" >/dev/null
+pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/\"}"
-# Get snapshot
-SNAP=$(pt_get "/snapshot")
-assert_json_length_gte "$SNAP" '.nodes' 1 "snapshot has nodes"
-assert_json_contains "$SNAP" '.title' 'E2E Test' "snapshot has title"
-assert_json_contains "$SNAP" '.url' 'fixtures' "snapshot has url"
+pt_get /snapshot
+assert_json_length_gte "$RESULT" '.nodes' 1
+assert_json_contains "$RESULT" '.title' 'E2E Test'
+assert_json_contains "$RESULT" '.url' 'fixtures'
# Check node structure
-FIRST_NODE=$(echo "$SNAP" | jq '.nodes[0]')
-assert_json_contains "$FIRST_NODE" '.ref' 'e' "node has ref"
-assert_json_contains "$FIRST_NODE" '.role' '' "node has role"
+FIRST_NODE=$(echo "$RESULT" | jq '.nodes[0]')
+assert_json_contains "$FIRST_NODE" '.ref' 'e'
+assert_json_contains "$FIRST_NODE" '.role' ''
end_test
-start_test "Snapshot with elements"
+# ─────────────────────────────────────────────────────────────────
+start_test "pinchtab snap (interactive elements)"
-# Navigate to buttons page (has interactive elements)
-pt_post "/navigate" "{\"url\":\"${FIXTURES_URL}/buttons.html\"}" >/dev/null
+pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/buttons.html\"}"
sleep 1
-SNAP=$(pt_get "/snapshot")
+pt_get /snapshot
# Should find buttons
-BUTTON_COUNT=$(echo "$SNAP" | jq '[.nodes[] | select(.role == "button")] | length')
+BUTTON_COUNT=$(echo "$RESULT" | jq '[.nodes[] | select(.role == "button")] | length')
if [ "$BUTTON_COUNT" -ge 3 ]; then
echo -e " ${GREEN}✓${NC} Found $BUTTON_COUNT buttons"
- ((ASSERTIONS_PASSED++))
+ ((ASSERTIONS_PASSED++)) || true
else
echo -e " ${RED}✗${NC} Expected >=3 buttons, found $BUTTON_COUNT"
- ((ASSERTIONS_FAILED++))
+ ((ASSERTIONS_FAILED++)) || true
fi
end_test
-start_test "Text extraction"
+# ─────────────────────────────────────────────────────────────────
+start_test "pinchtab text"
-# Navigate to table page
-pt_post "/navigate" "{\"url\":\"${FIXTURES_URL}/table.html\"}" >/dev/null
+pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/table.html\"}"
sleep 1
-# Get text content
-TEXT=$(pt_get "/text")
-assert_json_contains "$TEXT" '.text' 'Alice Johnson' "text contains 'Alice Johnson'"
-assert_json_contains "$TEXT" '.text' '[email protected]' "text contains '[email protected]'"
+pt_get /text
+assert_json_contains "$RESULT" '.text' 'Alice Johnson'
+assert_json_contains "$RESULT" '.text' '[email protected]'
end_test
diff --git a/tests/e2e/scenarios/04-tabs-api.sh b/tests/e2e/scenarios/04-tabs-api.sh
index cd266360..7dfc9f01 100755
--- a/tests/e2e/scenarios/04-tabs-api.sh
+++ b/tests/e2e/scenarios/04-tabs-api.sh
@@ -1,33 +1,32 @@
#!/bin/bash
-# 04-tabs-api.sh - Tab-scoped API tests (regression test for #207)
+# 04-tabs-api.sh — Tab-scoped API tests (regression test for #207)
source "$(dirname "$0")/common.sh"
-start_test "Tab-scoped snapshot (regression #207)"
+# ─────────────────────────────────────────────────────────────────
+start_test "pinchtab snap --tab <id> (regression #207)"
-# Navigate to create a tab
-RESULT=$(pt_post "/navigate" "{\"url\":\"${FIXTURES_URL}/index.html\"}")
+# Create a tab
+pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/index.html\"}"
CREATED_TAB=$(echo "$RESULT" | jq -r '.tabId')
echo -e " Created tab: ${CREATED_TAB:0:12}..."
# Get tab ID from /tabs endpoint
-TABS=$(pt_get "/tabs")
-LISTED_TAB=$(echo "$TABS" | jq -r '.tabs[-1].id')
+pt_get /tabs
+LISTED_TAB=$(echo "$RESULT" | jq -r '.tabs[-1].id')
echo -e " Listed tab: ${LISTED_TAB:0:12}..."
-# Test: /tabs/{id}/snapshot should work
+# Test: /tabs/{id}/snapshot should work (was broken in #207)
+pt_get "/tabs/${LISTED_TAB}/snapshot"
assert_status 200 "${PINCHTAB_URL}/tabs/${LISTED_TAB}/snapshot"
-
-# Verify snapshot content
-SNAP=$(pt_get "/tabs/${LISTED_TAB}/snapshot")
-assert_json_contains "$SNAP" '.title' 'E2E Test' "snapshot has correct title"
+assert_json_contains "$RESULT" '.title' 'E2E Test'
end_test
-start_test "Tab-scoped operations"
+# ─────────────────────────────────────────────────────────────────
+start_test "pinchtab text/screenshot --tab <id>"
-# Navigate to form page
-RESULT=$(pt_post "/navigate" "{\"url\":\"${FIXTURES_URL}/form.html\"}")
+pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/form.html\"}"
TAB_ID=$(echo "$RESULT" | jq -r '.tabId')
# Test /tabs/{id}/text
@@ -38,27 +37,29 @@ assert_status 200 "${PINCHTAB_URL}/tabs/${TAB_ID}/screenshot"
end_test
-start_test "Tab close"
+# ─────────────────────────────────────────────────────────────────
+start_test "pinchtab tab close"
-# Get current tabs
-BEFORE=$(pt_get "/tabs" | jq '.tabs | length')
+pt_get /tabs
+BEFORE=$(echo "$RESULT" | jq '.tabs | length')
-# Navigate to create a new tab
-RESULT=$(pt_post "/navigate" "{\"url\":\"${FIXTURES_URL}/buttons.html\"}")
+# Create and close a tab
+pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/buttons.html\"}"
TAB_ID=$(echo "$RESULT" | jq -r '.tabId')
-# Close the tab via /tabs/{id}/close
assert_status 200 "${PINCHTAB_URL}/tabs/${TAB_ID}/close" "POST"
-# Verify tab count decreased or stayed same (close removes tab)
+# Verify tab count
sleep 1
-AFTER=$(pt_get "/tabs" | jq '.tabs | length')
+pt_get /tabs
+AFTER=$(echo "$RESULT" | jq '.tabs | length')
+
if [ "$AFTER" -le "$BEFORE" ]; then
- echo -e " ${GREEN}✓${NC} Tab closed successfully (before: $BEFORE, after: $AFTER)"
- ((ASSERTIONS_PASSED++))
+ echo -e " ${GREEN}✓${NC} Tab closed (before: $BEFORE, after: $AFTER)"
+ ((ASSERTIONS_PASSED++)) || true
else
echo -e " ${RED}✗${NC} Tab not closed (before: $BEFORE, after: $AFTER)"
- ((ASSERTIONS_FAILED++))
+ ((ASSERTIONS_FAILED++)) || true
fi
end_test
diff --git a/tests/e2e/scenarios/05-actions.sh b/tests/e2e/scenarios/05-actions.sh
index 81981c63..d7e97b1c 100755
--- a/tests/e2e/scenarios/05-actions.sh
+++ b/tests/e2e/scenarios/05-actions.sh
@@ -1,58 +1,53 @@
#!/bin/bash
-# 05-actions.sh - Browser actions (click, type, etc.)
+# 05-actions.sh — Browser actions (click, type, press)
source "$(dirname "$0")/common.sh"
-start_test "Click action"
+# ─────────────────────────────────────────────────────────────────
+start_test "pinchtab click <ref>"
-# Navigate to buttons page
-pt_post "/navigate" "{\"url\":\"${FIXTURES_URL}/buttons.html\"}" >/dev/null
+pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/buttons.html\"}"
sleep 2
# Get snapshot and find increment button
-SNAP=$(pt_get "/snapshot")
-INCREMENT_REF=$(echo "$SNAP" | jq -r '.nodes[] | select(.name == "Increment") | .ref' | head -1)
+pt_get /snapshot
+INCREMENT_REF=$(echo "$RESULT" | jq -r '.nodes[] | select(.name == "Increment") | .ref' | head -1)
if [ -n "$INCREMENT_REF" ] && [ "$INCREMENT_REF" != "null" ]; then
- # Click the button
- CLICK_RESULT=$(pt_post "/action" "{\"kind\":\"click\",\"ref\":\"${INCREMENT_REF}\"}")
- echo -e " ${GREEN}✓${NC} Clicked increment button (ref: $INCREMENT_REF)"
+ pt_post /action -d "{\"kind\":\"click\",\"ref\":\"${INCREMENT_REF}\"}"
+ echo -e " ${GREEN}✓${NC} Clicked button (ref: $INCREMENT_REF)"
((ASSERTIONS_PASSED++)) || true
else
- echo -e " ${YELLOW}⚠${NC} Could not find increment button (non-critical)"
+ echo -e " ${YELLOW}⚠${NC} Could not find increment button"
((ASSERTIONS_PASSED++)) || true
fi
end_test
-start_test "Type action"
+# ─────────────────────────────────────────────────────────────────
+start_test "pinchtab type <ref> <text>"
-# Navigate to form page
-pt_post "/navigate" "{\"url\":\"${FIXTURES_URL}/form.html\"}" >/dev/null
+pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/form.html\"}"
sleep 1
-# Get snapshot to find input field
-SNAP=$(pt_get "/snapshot")
+pt_get /snapshot
+USERNAME_REF=$(echo "$RESULT" | jq -r '.nodes[] | select(.role == "textbox") | .ref' | head -1)
-# Find username input
-USERNAME_REF=$(echo "$SNAP" | jq -r '.nodes[] | select(.role == "textbox" and (.name | contains("Username") or .name == "")) | .ref' | head -1)
-
-if [ -n "$USERNAME_REF" ]; then
- # Type into the field
- TYPE_RESULT=$(pt_post "/action" "{\"kind\":\"type\",\"ref\":\"${USERNAME_REF}\",\"text\":\"testuser123\"}")
- echo -e " ${GREEN}✓${NC} Typed into username field (ref: $USERNAME_REF)"
- ((ASSERTIONS_PASSED++))
+if [ -n "$USERNAME_REF" ] && [ "$USERNAME_REF" != "null" ]; then
+ pt_post /action -d "{\"kind\":\"type\",\"ref\":\"${USERNAME_REF}\",\"text\":\"testuser123\"}"
+ echo -e " ${GREEN}✓${NC} Typed into field (ref: $USERNAME_REF)"
+ ((ASSERTIONS_PASSED++)) || true
else
- echo -e " ${YELLOW}⚠${NC} Could not find username input field"
- ((ASSERTIONS_PASSED++)) # Non-critical
+ echo -e " ${YELLOW}⚠${NC} Could not find input field"
+ ((ASSERTIONS_PASSED++)) || true
fi
end_test
-start_test "Press key action"
+# ─────────────────────────────────────────────────────────────────
+start_test "pinchtab press <key>"
-# Press Enter key
-RESULT=$(pt_post "/action" "{\"kind\":\"press\",\"key\":\"Enter\"}")
+pt_post /action -d '{"kind":"press","key":"Escape"}'
assert_status 200 "${PINCHTAB_URL}/action" "POST" '{"kind":"press","key":"Escape"}'
end_test
diff --git a/tests/e2e/scenarios/06-screenshot-pdf.sh b/tests/e2e/scenarios/06-screenshot-pdf.sh
index 61952b73..cf86229d 100755
--- a/tests/e2e/scenarios/06-screenshot-pdf.sh
+++ b/tests/e2e/scenarios/06-screenshot-pdf.sh
@@ -1,60 +1,49 @@
#!/bin/bash
-# 06-screenshot-pdf.sh - Screenshot and PDF export
+# 06-screenshot-pdf.sh — Screenshot and PDF export
source "$(dirname "$0")/common.sh"
-start_test "Screenshot"
+# ─────────────────────────────────────────────────────────────────
+start_test "pinchtab screenshot"
-# Navigate to a page
-pt_post "/navigate" "{\"url\":\"${FIXTURES_URL}/table.html\"}" >/dev/null
+pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/table.html\"}"
sleep 1
-# Get screenshot
-SCREENSHOT=$(curl -s -w '\n%{http_code}' "${PINCHTAB_URL}/screenshot")
-HTTP_CODE=$(echo "$SCREENSHOT" | tail -1)
-
-if [ "$HTTP_CODE" = "200" ]; then
- # Check it's actually image data (starts with PNG magic or JPEG)
- HEADER=$(echo "$SCREENSHOT" | head -c 10 | xxd -p 2>/dev/null || echo "")
- if [[ "$HEADER" == 89504e47* ]] || [[ "$HEADER" == ffd8ff* ]]; then
- echo -e " ${GREEN}✓${NC} Screenshot returned valid image data"
- ((ASSERTIONS_PASSED++))
- else
- echo -e " ${GREEN}✓${NC} Screenshot returned 200 (content not verified)"
- ((ASSERTIONS_PASSED++))
- fi
+pt_get /screenshot
+if [ "$HTTP_STATUS" = "200" ]; then
+ echo -e " ${GREEN}✓${NC} Screenshot returned 200"
+ ((ASSERTIONS_PASSED++)) || true
else
- echo -e " ${RED}✗${NC} Screenshot failed with status $HTTP_CODE"
- ((ASSERTIONS_FAILED++))
+ echo -e " ${RED}✗${NC} Screenshot failed (status: $HTTP_STATUS)"
+ ((ASSERTIONS_FAILED++)) || true
fi
end_test
-start_test "PDF export (shorthand)"
+# ─────────────────────────────────────────────────────────────────
+start_test "pinchtab pdf (shorthand)"
-# Note: /pdf shorthand is not available in server mode (uses tab-scoped route)
-# This test is skipped - use tab-scoped PDF test instead
-echo -e " ${YELLOW}⚠${NC} Skipped: /pdf shorthand not available in server mode"
+# Note: /pdf shorthand not available in server mode — skipped
+echo -e " ${YELLOW}⚠${NC} Skipped: /pdf shorthand not in server mode"
((ASSERTIONS_PASSED++)) || true
end_test
-start_test "Tab-scoped screenshot"
+# ─────────────────────────────────────────────────────────────────
+start_test "pinchtab screenshot --tab <id>"
-# Get a tab ID
-TABS=$(pt_get "/tabs")
-TAB_ID=$(echo "$TABS" | jq -r '.tabs[0].id')
+pt_get /tabs
+TAB_ID=$(echo "$RESULT" | jq -r '.tabs[0].id')
-# Get screenshot for specific tab
assert_status 200 "${PINCHTAB_URL}/tabs/${TAB_ID}/screenshot"
end_test
-start_test "Tab-scoped PDF"
+# ─────────────────────────────────────────────────────────────────
+start_test "pinchtab pdf --tab <id>"
-# Get PDF for specific tab
-TABS=$(pt_get "/tabs")
-TAB_ID=$(echo "$TABS" | jq -r '.tabs[0].id')
+pt_get /tabs
+TAB_ID=$(echo "$RESULT" | jq -r '.tabs[0].id')
assert_status 200 "${PINCHTAB_URL}/tabs/${TAB_ID}/pdf"
diff --git a/tests/e2e/scenarios/common.sh b/tests/e2e/scenarios/common.sh
index 073afdd0..7e6f5317 100755
--- a/tests/e2e/scenarios/common.sh
+++ b/tests/e2e/scenarios/common.sh
@@ -187,15 +187,38 @@ assert_json_length_gte() {
fi
}
-# HTTP helpers
-pt_get() {
- curl -s "${PINCHTAB_URL}$1"
-}
+# ================================================================
+# Visible curl wrapper — shows exact command when running
+# ================================================================
+
+RESULT=""
+HTTP_STATUS=""
+
+pinchtab() {
+ local method="$1"
+ local path="$2"
+ shift 2
-pt_post() {
- curl -s -X POST -H "Content-Type: application/json" -d "$2" "${PINCHTAB_URL}$1"
+ # Print the curl command in cyan so you see what's executed
+ echo -e "${BLUE}→ curl -X $method ${PINCHTAB_URL}$path $@${NC}" >&2
+
+ # Execute and capture response + status
+ local response
+ response=$(curl -s -w "\n%{http_code}" \
+ -X "$method" \
+ "${PINCHTAB_URL}$path" \
+ -H "Content-Type: application/json" \
+ "$@")
+
+ RESULT=$(echo "$response" | head -n -1)
+ HTTP_STATUS=$(echo "$response" | tail -n 1)
}
+# Aliases for cleaner test files
+pt() { pinchtab "$@"; }
+pt_get() { pinchtab GET "$1"; echo "$RESULT"; }
+pt_post() { pinchtab POST "$1" -d "$2"; echo "$RESULT"; }
+
# Print summary
print_summary() {
local total=$((TESTS_PASSED + TESTS_FAILED))