High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.
fix: e2e test changes due to tab id
Bosch1322f48015b3
diff --git a/tests/e2e/helpers/cli.sh b/tests/e2e/helpers/cli.shindex c40a863d..c7685f76 100644--- a/tests/e2e/helpers/cli.sh+++ b/tests/e2e/helpers/cli.sh@@ -194,6 +194,24 @@ assert_config_version_one_of() {return 1}+# Assert PT_OUT is a bare tab ID. When stdout is redirected to a file (as+# in this harness), `pinchtab nav|goto|navigate` auto-switches to+# machine-friendly output: just the tab ID on stdout (no JSON envelope).+# See stdoutIsPipe() in internal/cli/actions/actions_navigate.go.+assert_tab_id() {+ local desc="${1:-returns tab ID}"+ local trimmed+ trimmed=$(echo "$PT_OUT" | tr -d '[:space:]')+ if [[ "$trimmed" =~ ^[A-Fa-f0-9]{16,64}$ ]]; then+ echo -e " ${GREEN}✓${NC} $desc"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${RED}✗${NC} $desc"+ echo -e " ${RED} output was: $PT_OUT${NC}"+ ((ASSERTIONS_FAILED++)) || true+ fi+}+assert_output_not_contains() {local forbidden="$1"local desc="${2:-output does not contain '$forbidden'}"diff --git a/tests/e2e/scenarios/cli/browser-basic.sh b/tests/e2e/scenarios/cli/browser-basic.shindex d581a69f..1ec9448c 100644--- a/tests/e2e/scenarios/cli/browser-basic.sh+++ b/tests/e2e/scenarios/cli/browser-basic.sh@@ -35,9 +35,7 @@ end_teststart_test "pinchtab nav <url>"pt_ok nav "${FIXTURES_URL}/index.html"-assert_output_json-assert_output_contains "tabId" "returns tab ID"-assert_output_contains "title" "returns page title"+assert_tab_id "returns tab ID"end_test@@ -66,9 +64,19 @@ end_teststart_test "pinchtab nav --tab <tabId> <url>"pt_ok nav "${FIXTURES_URL}/index.html"-TAB_ID=$(echo "$PT_OUT" | jq -r '.tabId')+TAB_ID=$(echo "$PT_OUT" | tr -d '[:space:]')pt_ok nav "${FIXTURES_URL}/form.html" --tab "$TAB_ID"+# nav emits bare tab ID on piped stdout; verify --tab reused the same tab.+if [ "$(echo "$PT_OUT" | tr -d '[:space:]')" = "$TAB_ID" ]; then+ echo -e " ${GREEN}✓${NC} navigated in same tab"+ ((ASSERTIONS_PASSED++)) || true+else+ echo -e " ${RED}✗${NC} expected tab $TAB_ID, got $PT_OUT"+ ((ASSERTIONS_FAILED++)) || true+fi+# Follow up with a tab-scoped eval to confirm the URL actually changed.+pt_ok eval "location.pathname" --tab "$TAB_ID"assert_output_contains "form.html" "navigated to form.html"end_test@@ -115,7 +123,7 @@ end_teststart_test "pinchtab eval --tab <tabId> <expression>"pt_ok nav "${FIXTURES_URL}/buttons.html"-TAB_ID=$(echo "$PT_OUT" | jq -r '.tabId')+TAB_ID=$(echo "$PT_OUT" | tr -d '[:space:]')pt_ok eval "document.title" --tab "$TAB_ID"assert_output_contains "Button" "evaluates in correct tab"diff --git a/tests/e2e/scenarios/cli/browser-extended.sh b/tests/e2e/scenarios/cli/browser-extended.shindex ae609fd0..48391867 100644--- a/tests/e2e/scenarios/cli/browser-extended.sh+++ b/tests/e2e/scenarios/cli/browser-extended.sh@@ -57,16 +57,16 @@ start_test "auto-https: goto without protocol adds https://"pt goto "fixtures:80/index.html"-if echo "$PT_OUT" | grep -qiE "chrome-error|err_|error|refused|failed|ssl"; then- echo -e " ${GREEN}✓${NC} CLI added https:// prefix (Chrome shows error page)"- ((ASSERTIONS_PASSED++)) || true-elif [ "$PT_CODE" -ne 0 ]; then+# goto emits bare tab ID on piped stdout, so inspect the resolved URL via+# a follow-up snap. CLI adding https:// means Chrome either loads an+# https page or shows an error page (chrome-error://) — both are fine.+if [ "$PT_CODE" -ne 0 ]; thenecho -e " ${GREEN}✓${NC} CLI added https:// prefix (navigation failed as expected)"((ASSERTIONS_PASSED++)) || trueelse- # Check if the URL in response starts with https://- if echo "$PT_OUT" | grep -q '"url".*https://'; then- echo -e " ${GREEN}✓${NC} CLI added https:// prefix (URL in response shows https)"+ pt_ok snap+ if echo "$PT_OUT" | grep -qiE 'https://|chrome-error'; then+ echo -e " ${GREEN}✓${NC} CLI added https:// prefix (snap URL shows https or chrome-error)"((ASSERTIONS_PASSED++)) || trueelseecho -e " ${RED}✗${NC} Expected https:// URL or error, got: $PT_OUT"@@ -80,8 +80,9 @@ end_teststart_test "auto-https: explicit http:// is preserved"pt_ok goto "http://fixtures:80/index.html"--if echo "$PT_OUT" | grep -q '"url".*http://'; then+# goto emits bare tab ID; inspect the resolved URL via snap.+pt_ok snap+if echo "$PT_OUT" | grep -q 'http://fixtures'; thenecho -e " ${GREEN}✓${NC} Response URL is http://"((ASSERTIONS_PASSED++)) || trueelse@@ -96,15 +97,18 @@ start_test "auto-https: explicit https:// is preserved"pt goto "https://fixtures:80/index.html"-if echo "$PT_OUT" | grep -qiE "chrome-error|err_|error|refused|failed"; then- echo -e " ${GREEN}✓${NC} Explicit https:// preserved (Chrome shows error)"- ((ASSERTIONS_PASSED++)) || true-elif echo "$PT_OUT" | grep -q '"url".*https://'; then- echo -e " ${GREEN}✓${NC} Explicit https:// preserved (URL shows https)"+if [ "$PT_CODE" -ne 0 ]; then+ echo -e " ${GREEN}✓${NC} Explicit https:// preserved (navigation failed as expected)"((ASSERTIONS_PASSED++)) || trueelse- echo -e " ${RED}✗${NC} Expected https:// URL or error, got: $PT_OUT"- ((ASSERTIONS_FAILED++)) || true+ pt_ok snap+ if echo "$PT_OUT" | grep -qiE 'https://fixtures|chrome-error'; then+ echo -e " ${GREEN}✓${NC} Explicit https:// preserved (snap URL shows https or chrome-error)"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${RED}✗${NC} Expected https:// URL or error, got: $PT_OUT"+ ((ASSERTIONS_FAILED++)) || true+ fifiend_test@@ -244,8 +248,7 @@ end_teststart_test "pinchtab nav <url>"pt_ok nav "${FIXTURES_URL}/index.html"-assert_output_json-assert_output_contains "tabId" "returns tab ID"+assert_tab_id "returns tab ID"end_test@@ -253,8 +256,7 @@ end_teststart_test "pinchtab nav --new-tab <url>"pt_ok nav --new-tab "${FIXTURES_URL}/form.html"-assert_output_json-assert_output_contains "tabId" "opens in new tab"+assert_tab_id "opens in new tab"end_test@@ -262,8 +264,7 @@ end_teststart_test "pinchtab goto <url> (alias for nav)"pt_ok goto "${FIXTURES_URL}/index.html"-assert_output_json-assert_output_contains "tabId" "goto works as alias"+assert_tab_id "goto works as alias"end_test@@ -271,7 +272,6 @@ end_teststart_test "pinchtab navigate <url> (alias for nav)"pt_ok navigate "${FIXTURES_URL}/index.html"-assert_output_json-assert_output_contains "tabId" "navigate works as alias"+assert_tab_id "navigate works as alias"end_testdiff --git a/tests/e2e/scenarios/cli/console-basic.sh b/tests/e2e/scenarios/cli/console-basic.shindex e0d6844a..84337741 100755--- a/tests/e2e/scenarios/cli/console-basic.sh+++ b/tests/e2e/scenarios/cli/console-basic.sh@@ -63,7 +63,7 @@ end_teststart_test "pinchtab console --tab <tabId>"pt_ok nav "${FIXTURES_URL}/index.html"-TAB_ID=$(echo "$PT_OUT" | jq -r '.tabId')+TAB_ID=$(echo "$PT_OUT" | tr -d '[:space:]')pt_ok console --tab "$TAB_ID"diff --git a/tests/e2e/scenarios/cli/system-basic.sh b/tests/e2e/scenarios/cli/system-basic.shindex 1b3b6c40..18398097 100644--- a/tests/e2e/scenarios/cli/system-basic.sh+++ b/tests/e2e/scenarios/cli/system-basic.sh@@ -247,7 +247,7 @@ end_teststart_test "pinchtab activity"pt_ok nav "${FIXTURES_URL}/buttons.html"-TAB_ID=$(echo "$PT_OUT" | jq -r '.tabId')+TAB_ID=$(echo "$PT_OUT" | tr -d '[:space:]')pt_ok snap --tab "$TAB_ID"assert_output_json "snapshot output is valid JSON"diff --git a/tests/e2e/scenarios/cli/tabs-basic.sh b/tests/e2e/scenarios/cli/tabs-basic.shindex 85e4b954..7ded090c 100644--- a/tests/e2e/scenarios/cli/tabs-basic.sh+++ b/tests/e2e/scenarios/cli/tabs-basic.sh@@ -19,7 +19,7 @@ end_teststart_test "pinchtab tab close <id>"pt_ok nav "${FIXTURES_URL}/form.html"-TAB_ID=$(echo "$PT_OUT" | jq -r '.tabId')+TAB_ID=$(echo "$PT_OUT" | tr -d '[:space:]')pt_ok tab close "$TAB_ID"@@ -79,7 +79,7 @@ end_teststart_test "pinchtab tab close <id> (close by tab ID)"pt nav "${FIXTURES_URL}/form.html"-CLOSE_ID=$(echo "$PT_OUT" | jq -r '.tabId // empty')+CLOSE_ID=$(echo "$PT_OUT" | tr -d '[:space:]')if [ -n "$CLOSE_ID" ] && [ "$CLOSE_ID" != "null" ]; thenecho -e " ${MUTED}closing tab: ${CLOSE_ID:0:12}...${NC}"diff --git a/tests/e2e/scenarios/cli/tabs-extended.sh b/tests/e2e/scenarios/cli/tabs-extended.shindex afb7d819..748aa526 100644--- a/tests/e2e/scenarios/cli/tabs-extended.sh+++ b/tests/e2e/scenarios/cli/tabs-extended.sh@@ -18,11 +18,9 @@ end_teststart_test "pinchtab back (navigate two pages then back)"pt_ok nav "${FIXTURES_URL}/index.html"-TAB_ID=$(echo "$PT_OUT" | jq -r '.tabId')-URL_A=$(echo "$PT_OUT" | jq -r '.url')+TAB_ID=$(echo "$PT_OUT" | tr -d '[:space:]')pt_ok nav "${FIXTURES_URL}/form.html" --tab "$TAB_ID"-URL_B=$(echo "$PT_OUT" | jq -r '.url')pt_ok back --tab "$TAB_ID"assert_output_json "back returns JSON"@@ -73,8 +71,7 @@ end_teststart_test "pinchtab tab new + close roundtrip"pt_ok nav "${FIXTURES_URL}/index.html"-assert_output_json-TAB_ID=$(echo "$PT_OUT" | jq -r '.tabId')+TAB_ID=$(echo "$PT_OUT" | tr -d '[:space:]')pt_ok tab close "$TAB_ID"@@ -105,7 +102,7 @@ start_test "tab eviction: open tabs up to limit"TAB_IDS=()for i in $(seq 1 $MAX_TABS); dopt_ok nav "${FIXTURES_URL}/index.html?t=$i"- TAB_IDS+=($(echo "$PT_OUT" | jq -r '.tabId'))+ TAB_IDS+=($(echo "$PT_OUT" | tr -d '[:space:]'))donept_ok tab