High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.
test(e2e): delete soft_pass_assert and make the scenarios that leaned on it able to fail
Luigi Agosti8f6f9c924827
diff --git a/TESTING.md b/TESTING.mdindex 96190f68..dfceeb26 100644--- a/TESTING.md+++ b/TESTING.md@@ -214,6 +214,40 @@ start_test "tab focus"end_test```+### Assertions Must Be Able to Fail++Every branch of a scenario ends in `pass_assert`, `fail_assert`, or a named skip+(`skip_assert` / `skip_test`) — never in a pass that stands in for a failure. A+helper that reports "the thing I was checking is not there" as a pass makes the+scenario green for every input, which is indistinguishable in the report from+working code. Use a skip only when the property genuinely cannot be observed on+this server or provider, and say in the message which condition is missing.++### Waiting++Do not `sleep` for state to arrive. `wait_until <predicate> [timeout] [interval]`+(in `helpers/base.sh`) polls the predicate, returns as soon as it holds, and+fails the current test loudly if the timeout passes — so a wait is bounded on a+slow machine and costs nothing on a fast one:++```bash+BEFORE_TS=$(newest_activity_event /navigate | jq -r '.timestamp // empty')+pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/buttons.html\"}"+assert_ok "navigate"++if wait_until "activity_event_landed /navigate '$BEFORE_TS'" 10; then+ assert_json_eq "$ACTIVITY_EVENT" '.status' "200" "activity event status=200"+fi+```++`wait_for_instance_ready` stays separate: it gates a suite before any test is+running, so it reports a readiness failure to its caller instead of failing a+test that has not started.++To drive a second server in the stack (a provider instance, the bridge), wrap+the call in `pt_on <base_url> <token> <pt_command...>`; it retargets `E2E_SERVER`+and the token together and restores both afterwards.+## CoverageGenerate coverage for unit tests:diff --git a/tests/e2e/helpers/api-assertions.sh b/tests/e2e/helpers/api-assertions.shindex e2c0405d..e0c3293d 100644--- a/tests/e2e/helpers/api-assertions.sh+++ b/tests/e2e/helpers/api-assertions.sh@@ -171,18 +171,25 @@ assert_input_not_contains() {return 0}+# assert_http_error checks the RESPONSE status, not a `.status` field in the+# body — PinchTab error bodies are {"code","error"} and never carry one, so the+# old body lookup was empty for every call and the assertion rested entirely on+# its pattern. error_pattern is an extended regex matched against the body; pass+# "" to assert the status alone.assert_http_error() {local expected_status="$1"- local error_pattern="${2:-error}"+ local error_pattern="${2:-}"local desc="${3:-HTTP $expected_status error}"- local actual_status- actual_status=$(echo "$RESULT" | jq -r '.status // empty')- if [ "$actual_status" = "$expected_status" ] || grep -q "$error_pattern" <<< "$RESULT"; then- pass_assert "$desc"- else- soft_pass_assert "$desc (got: $actual_status)"+ if [ "$HTTP_STATUS" != "$expected_status" ]; then+ fail_assert "$desc (want HTTP $expected_status, got $HTTP_STATUS: $RESULT)"+ return+ fi+ if [ -n "$error_pattern" ] && ! grep -qE "$error_pattern" <<< "$RESULT"; then+ fail_assert "$desc (HTTP $expected_status but no match for /$error_pattern/ in: $RESULT)"+ returnfi+ pass_assert "$desc"}assert_contains_any() {@@ -193,7 +200,7 @@ assert_contains_any() {if echo "$haystack" | grep -qE "$patterns"; thenpass_assert "$desc"else- soft_pass_assert "$desc (not found)"+ fail_assert "$desc (no match for /$patterns/ in: $haystack)"fi}diff --git a/tests/e2e/helpers/autosolver.sh b/tests/e2e/helpers/autosolver.shindex 69a797b4..95101664 100644--- a/tests/e2e/helpers/autosolver.sh+++ b/tests/e2e/helpers/autosolver.sh@@ -358,7 +358,7 @@ autosolver_run_retry_case() {if [ "$settled_passed" = "true" ]; thenpass_assert "retry: page settled to passed state within ${poll_attempts} polls"else- soft_pass_assert "retry: page loaded but score not 100% passed (critical: ${settled_critical}/${settled_total})"+ skip_assert "retry: page loaded but score not 100% passed (critical: ${settled_critical}/${settled_total})"fiif [ "$poll_attempts" -le "$max_poll" ]; thendiff --git a/tests/e2e/helpers/base.sh b/tests/e2e/helpers/base.shindex 91bc451a..d46fa487 100644--- a/tests/e2e/helpers/base.sh+++ b/tests/e2e/helpers/base.sh@@ -99,6 +99,45 @@ wait_for_instance_ready() {done}+# wait_until polls a predicate until it holds, and fails the current test when+# it never does. The predicate is a shell command string; anything it prints is+# discarded. Bounded and loud by construction: a scenario cannot wait forever,+# and it cannot mistake a timeout for a pass.+wait_until() {+ local predicate="$1"+ local timeout_sec="${2:-10}"+ local interval="${3:-0.2}"+ local deadline+ deadline=$(($(get_time_ms) + timeout_sec * 1000))++ while true; do+ if eval "$predicate" >/dev/null 2>&1; then+ return 0+ fi+ if [ "$(get_time_ms)" -ge "$deadline" ]; then+ fail_assert "timed out after ${timeout_sec}s waiting for: ${predicate}"+ return 1+ fi+ sleep "$interval"+ done+}++# pt_on runs a pt_* call against another PinchTab in the stack — a second+# provider instance, the bridge — and restores the caller's target afterwards.+# The base URL and token move together: a second server usually has its own.+pt_on() {+ local base_url="$1" token="$2"+ shift 2+ local prev_url="$E2E_SERVER" prev_token="${E2E_SERVER_TOKEN:-}"+ E2E_SERVER="$base_url"+ E2E_SERVER_TOKEN="$token"+ "$@"+ local rc=$?+ E2E_SERVER="$prev_url"+ E2E_SERVER_TOKEN="$prev_token"+ return $rc+}+start_test() {ASSERTIONS_PASSED=0ASSERTIONS_FAILED=0@@ -155,11 +194,6 @@ skip_test() {((ASSERTIONS_SKIPPED++)) || true}-soft_pass_assert() {- echo -e " ${YELLOW}~${NC} ${1:-}"- ((ASSERTIONS_PASSED++)) || true-}-_e2e_default_ref_json() {local ref_var="${E2E_REF_JSON_VAR:-RESULT}"printf '%s' "${!ref_var-}"diff --git a/tests/e2e/scenarios/api/browser-activity-basic.sh b/tests/e2e/scenarios/api/browser-activity-basic.shindex f21e376c..e15f6a6a 100755--- a/tests/e2e/scenarios/api/browser-activity-basic.sh+++ b/tests/e2e/scenarios/api/browser-activity-basic.sh@@ -1,49 +1,120 @@#!/bin/bash-# browser-activity-basic.sh — Activity log browser metadata assertions.-# Covers: /api/activity route fields: requestedBrowser, usedBrowser, attempts,-# escalation, and reason.+# browser-activity-basic.sh — what the activity log records about a routed+# request. Route metadata is built inside the instance, so it reaches+# /api/activity only where the recorder shares the instance's request context:+# that is bridge mode. Through the orchestrator front door the same metadata+# comes back on the response instead, and both surfaces are asserted here.GROUP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"source "${GROUP_DIR}/../../helpers/api.sh"EXPECTED_BROWSER="${PINCHTAB_E2E_BROWSER:-chrome}"--# ─────────────────────────────────────────────────────────────────-start_test "activity metadata: navigate with browser param records route"--pt_post "/navigate?browser=${EXPECTED_BROWSER}" -d "{\"url\":\"${FIXTURES_URL}/buttons.html\"}"-assert_ok "navigate with browser=${EXPECTED_BROWSER}"--sleep 1--pt_get "/api/activity?limit=5"-assert_ok "get recent activity"--ROUTE_EVENT=$(echo "$RESULT" | jq '[.events[] | select(.path == "/navigate" and .route != null)] | first // empty' 2>/dev/null)-if [ -z "$ROUTE_EVENT" ] || [ "$ROUTE_EVENT" = "null" ] || [ "$ROUTE_EVENT" = "" ]; then- soft_pass_assert "no navigate event with route in recent activity (may need more events)"-else- REQ_BROWSER=$(echo "$ROUTE_EVENT" | jq -r '.route.requestedProvider // empty')- USED_BROWSER=$(echo "$ROUTE_EVENT" | jq -r '.route.usedProvider // empty')- ESCALATED=$(echo "$ROUTE_EVENT" | jq -r '.route.escalated // empty')-- if [ "$REQ_BROWSER" = "${EXPECTED_BROWSER}" ]; then- pass_assert "activity route.requestedProvider=${EXPECTED_BROWSER}"+ACTIVITY_TIMEOUT="${E2E_ACTIVITY_TIMEOUT:-10}"++# assert_route_metadata holds route metadata to the shape routeMetadataFor+# builds for every provider: a provider served the request, the attempts trail+# ends on an accepted one, and escalation shows as an extra attempt rather than+# as a silently different answer. Measured across chrome and ghost-chrome:+# usedProvider is NOT always the trail's last provider (a static-first navigate+# that escalates keeps the requested provider in usedProvider), so the trail is+# checked on acceptance rather than on identity.+assert_route_metadata() {+ local route="$1" label="$2"+ local used escalated attempts_len last_accepted++ used=$(echo "$route" | jq -r '.usedProvider // empty')+ escalated=$(echo "$route" | jq -r 'if has("escalated") then .escalated else "missing" end')+ attempts_len=$(echo "$route" | jq '.attempts | length' 2>/dev/null || echo "0")+ last_accepted=$(echo "$route" | jq -r '.attempts[-1].accepted' 2>/dev/null)++ if [ -n "$used" ]; then+ pass_assert "$label route.usedProvider=$used"else- soft_pass_assert "requestedProvider=$REQ_BROWSER (expected ${EXPECTED_BROWSER})"+ fail_assert "$label route.usedProvider is empty — no provider recorded as serving the request: $route"fi- if [ -n "$USED_BROWSER" ] && [ "$USED_BROWSER" != "null" ]; then- pass_assert "activity route.usedProvider=$USED_BROWSER"+ if [ "$attempts_len" -ge 1 ] && [ "$last_accepted" = "true" ]; then+ pass_assert "$label route.attempts ends on an accepted provider ($attempts_len attempt(s))"else- soft_pass_assert "usedProvider not set in activity"+ fail_assert "$label route.attempts=$attempts_len with last accepted='$last_accepted', want a trail ending on an accepted provider: $route"fi- if [ "$ESCALATED" = "false" ] || [ "$ESCALATED" = "" ] || [ "$ESCALATED" = "null" ]; then- pass_assert "activity route.escalated=false (no escalation needed)"+ case "$escalated" in+ false)+ if [ "$attempts_len" -eq 1 ]; then+ pass_assert "$label not escalated: one attempt"+ else+ fail_assert "$label escalated=false but records $attempts_len attempts: $route"+ fi+ ;;+ true)+ if [ "$attempts_len" -ge 2 ]; then+ pass_assert "$label escalated after $attempts_len attempts"+ else+ fail_assert "$label escalated=true but records only $attempts_len attempt: $route"+ fi+ ;;+ *)+ fail_assert "$label route.escalated is '$escalated', want true or false"+ ;;+ esac+}++# assert_requested_provider is asserted on RESPONSES only. The route recorded on+# an activity event can be a later phase of the same request (measured: a+# ghost-chrome navigate logs the post-escalation route), so pinning the caller's+# browser there would fail for a reason that is not about the activity log.+assert_requested_provider() {+ local route="$1" label="$2"+ local requested+ requested=$(echo "$route" | jq -r '.requestedProvider // empty')+ if [ "$requested" = "$EXPECTED_BROWSER" ]; then+ pass_assert "$label route.requestedProvider=$EXPECTED_BROWSER"else- soft_pass_assert "escalated=$ESCALATED (may be expected)"+ fail_assert "$label route.requestedProvider=$requested, want $EXPECTED_BROWSER"fi+}++# newest_activity_event prints the newest activity event for a path, or nothing+# when the log has not caught up yet. Events come back oldest→newest.+newest_activity_event() {+ local path="$1"+ # pt_get echoes the response body on stdout, and this function's own stdout is+ # what the caller captures — so the fetch is silenced and only the selected+ # event is printed.+ pt_get "/api/activity?limit=25" >/dev/null 2>&1+ echo "$RESULT" | jq -c --arg path "$path" '[.events[] | select(.path == $path)] | last // empty'+}++# activity_event_landed succeeds once an event for this path is newer than the+# timestamp captured before the request, so the wait tracks THIS request rather+# than a leftover from an earlier scenario. It publishes the event in+# ACTIVITY_EVENT for the assertions that follow.+activity_event_landed() {+ local path="$1" before="$2"+ ACTIVITY_EVENT=$(newest_activity_event "$path")+ [ -n "$ACTIVITY_EVENT" ] || return 1+ [ "$(echo "$ACTIVITY_EVENT" | jq -r '.timestamp')" != "$before" ]+}++# ─────────────────────────────────────────────────────────────────+start_test "activity metadata: navigate with browser param records route"++BEFORE_TS=$(newest_activity_event /navigate | jq -r '.timestamp // empty')++pt_post "/navigate?browser=${EXPECTED_BROWSER}" -d "{\"url\":\"${FIXTURES_URL}/buttons.html\"}"+assert_ok "navigate with browser=${EXPECTED_BROWSER}"+NAV_ROUTE=$(echo "$RESULT" | jq -c '.route')+assert_requested_provider "$NAV_ROUTE" "navigate response"+assert_route_metadata "$NAV_ROUTE" "navigate response"+NAV_TAB=$(echo "$RESULT" | jq -r '.tabId // empty')++if wait_until "activity_event_landed /navigate '$BEFORE_TS'" "$ACTIVITY_TIMEOUT"; then+ assert_json_eq "$ACTIVITY_EVENT" '.method' "POST" "activity event method=POST"+ assert_json_eq "$ACTIVITY_EVENT" '.action' "navigate" "activity event action=navigate"+ assert_json_eq "$ACTIVITY_EVENT" '.status' "200" "activity event status=200"+ assert_json_eq "$ACTIVITY_EVENT" '.tabId' "$NAV_TAB" "activity event carries the navigated tab"+ assert_json_contains "$ACTIVITY_EVENT" '.url' "buttons.html" "activity event carries the navigated URL"fiend_test@@ -53,25 +124,20 @@ start_test "activity metadata: text request records browser in activity"pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/form.html\"}"assert_ok "navigate to form"+TEXT_TAB=$(echo "$RESULT" | jq -r '.tabId // empty')-pt_get "/text?browser=${EXPECTED_BROWSER}"-assert_ok "text with browser=${EXPECTED_BROWSER}"--sleep 1--pt_get "/api/activity?limit=10"-assert_ok "get activity after text request"+BEFORE_TS=$(newest_activity_event /text | jq -r '.timestamp // empty')-TEXT_EVENT=$(echo "$RESULT" | jq '[.events[] | select(.path == "/text" and .route != null)] | first // empty' 2>/dev/null)-if [ -z "$TEXT_EVENT" ] || [ "$TEXT_EVENT" = "null" ] || [ "$TEXT_EVENT" = "" ]; then- soft_pass_assert "no text event with route in activity (provider may not record route for text)"-else- REQ=$(echo "$TEXT_EVENT" | jq -r '.route.requestedProvider // empty')- if [ "$REQ" = "$EXPECTED_BROWSER" ]; then- pass_assert "text activity route.requestedProvider=${EXPECTED_BROWSER}"- else- soft_pass_assert "text requestedProvider=$REQ (expected ${EXPECTED_BROWSER})"- fi+pt_get "/text?browser=${EXPECTED_BROWSER}&tabId=${TEXT_TAB}"+assert_ok "text with browser=${EXPECTED_BROWSER}"+TEXT_ROUTE=$(echo "$RESULT" | jq -c '.route')+assert_requested_provider "$TEXT_ROUTE" "text response"+assert_route_metadata "$TEXT_ROUTE" "text response"++if wait_until "activity_event_landed /text '$BEFORE_TS'" "$ACTIVITY_TIMEOUT"; then+ assert_json_eq "$ACTIVITY_EVENT" '.action' "text" "activity event action=text"+ assert_json_eq "$ACTIVITY_EVENT" '.status' "200" "activity event status=200"+ assert_json_eq "$ACTIVITY_EVENT" '.tabId' "$TEXT_TAB" "activity event carries the read tab"fiend_test@@ -79,51 +145,38 @@ end_test# ─────────────────────────────────────────────────────────────────start_test "activity metadata: activity events have required fields"-pt_get "/api/activity?limit=3"+pt_get "/api/activity?limit=25"assert_ok "get activity"-assert_json_exists "$RESULT" '.events' "has events array"assert_json_exists "$RESULT" '.count' "has count field"--FIRST_EVENT=$(echo "$RESULT" | jq '.events[0] // empty' 2>/dev/null)-if [ -n "$FIRST_EVENT" ] && [ "$FIRST_EVENT" != "null" ] && [ "$FIRST_EVENT" != "" ]; then- assert_json_exists "$FIRST_EVENT" '.method' "event has method"- assert_json_exists "$FIRST_EVENT" '.path' "event has path"- assert_json_exists "$FIRST_EVENT" '.status' "event has status"-else- soft_pass_assert "no events to validate (empty activity log)"-fi+assert_json_jq "$RESULT" '.events | length >= 1' \+ "activity log is not empty after the requests above" \+ "activity log is empty after two requests that must have been recorded"+assert_json_jq "$RESULT" '.events | all(has("method") and has("path") and has("status"))' \+ "every event has method, path and status" \+ "an activity event is missing method, path or status"end_test# ─────────────────────────────────────────────────────────────────-start_test "activity metadata: route attempts array present when routed"--pt_post "/navigate?browser=${EXPECTED_BROWSER}" -d "{\"url\":\"${FIXTURES_URL}/index.html\"}"-assert_ok "navigate with explicit browser"+start_test "activity metadata: bridge records route metadata on the event"-sleep 1--pt_get "/api/activity?limit=5"-assert_ok "get activity"--ROUTE_EVENT=$(echo "$RESULT" | jq '[.events[] | select(.path == "/navigate" and .route != null)] | first // empty' 2>/dev/null)-if [ -n "$ROUTE_EVENT" ] && [ "$ROUTE_EVENT" != "null" ] && [ "$ROUTE_EVENT" != "" ]; then- HAS_ATTEMPTS=$(echo "$ROUTE_EVENT" | jq 'has("route") and (.route | has("attempts"))' 2>/dev/null || echo "false")- if [ "$HAS_ATTEMPTS" = "true" ]; then- ATTEMPTS_LEN=$(echo "$ROUTE_EVENT" | jq '.route.attempts | length' 2>/dev/null || echo "0")- pass_assert "route has attempts array (length=$ATTEMPTS_LEN)"- else- soft_pass_assert "route present but no attempts array (single-browser route)"- fi-- HAS_REASON=$(echo "$ROUTE_EVENT" | jq '.route.reason // empty' 2>/dev/null || echo "")- if [ -n "$HAS_REASON" ] && [ "$HAS_REASON" != "null" ]; then- pass_assert "route has reason: $HAS_REASON"- else- soft_pass_assert "route has no reason field (direct match)"- fi+if [ -z "${E2E_BRIDGE_URL:-}" ]; then+ skip_test "E2E_BRIDGE_URL is not set; route metadata lands on the activity event only in bridge mode"else- soft_pass_assert "no routed navigate event in recent activity"+ BRIDGE_TOKEN="${E2E_BRIDGE_TOKEN:-}"+ BEFORE_TS=$(pt_on "$E2E_BRIDGE_URL" "$BRIDGE_TOKEN" newest_activity_event /navigate | jq -r '.timestamp // empty')++ pt_on "$E2E_BRIDGE_URL" "$BRIDGE_TOKEN" pt_post "/navigate?browser=${EXPECTED_BROWSER}" -d "{\"url\":\"${FIXTURES_URL}/index.html\"}"+ assert_ok "bridge navigate with browser=${EXPECTED_BROWSER}"++ if pt_on "$E2E_BRIDGE_URL" "$BRIDGE_TOKEN" wait_until "activity_event_landed /navigate '$BEFORE_TS'" "$ACTIVITY_TIMEOUT"; then+ ROUTE=$(echo "$ACTIVITY_EVENT" | jq -c '.route // empty')+ if [ -n "$ROUTE" ]; then+ assert_route_metadata "$ROUTE" "bridge activity event"+ else+ fail_assert "bridge activity event has no route metadata: $ACTIVITY_EVENT"+ fi+ fifiend_testdiff --git a/tests/e2e/scenarios/api/browser-extended.sh b/tests/e2e/scenarios/api/browser-extended.shindex b5a01924..03dce4f4 100644--- a/tests/e2e/scenarios/api/browser-extended.sh+++ b/tests/e2e/scenarios/api/browser-extended.sh@@ -10,24 +10,24 @@ pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/buttons.html\"}"TAB_ID=$(get_tab_id)show_tab "created" "$TAB_ID"-pt_post /action -d '{"action":"click","selector":"[invalid:::selector]"}'-assert_http_error 400 "invalid|selector|syntax" "invalid selector rejected"+pt_post /action -d '{"kind":"click","selector":"[invalid:::selector]"}'+assert_http_error 404 "matched no element" "invalid selector rejected"end_test# ─────────────────────────────────────────────────────────────────start_test "error handling: element not found"-pt_post /action -d '{"action":"click","selector":"#this-element-does-not-exist"}'-assert_contains_any "$RESULT" "not found|no element|404|400" "missing element error"+pt_post /action -d '{"kind":"click","selector":"#this-element-does-not-exist"}'+assert_contains_any "$RESULT" "not found|no element" "missing element error"end_test# ─────────────────────────────────────────────────────────────────start_test "error handling: action on missing field"-pt_post /action -d '{"action":"fill","selector":"#nonexistent-input","text":"test"}'-assert_contains_any "$RESULT" "not found|missing|404|400" "action on missing field rejected"+pt_post /action -d '{"kind":"fill","selector":"#nonexistent-input","text":"test"}'+assert_contains_any "$RESULT" "not found|no element" "action on missing field rejected"end_testdiff --git a/tests/e2e/scenarios/api/browser-selection-basic.sh b/tests/e2e/scenarios/api/browser-selection-basic.shindex 0b773190..5052b3ac 100755--- a/tests/e2e/scenarios/api/browser-selection-basic.sh+++ b/tests/e2e/scenarios/api/browser-selection-basic.sh@@ -11,12 +11,11 @@ start_test "browser selection: unknown browser name → structured error"pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/index.html\",\"browser\":\"nonexistent_xyz\"}"assert_not_ok "navigate with unknown browser rejects"-# The response should contain a structured error code.ERROR_CODE=$(echo "$RESULT" | jq -r '.code // empty' 2>/dev/null || echo "")-if [ -n "$ERROR_CODE" ] && [ "$ERROR_CODE" != "null" ]; then+if [ -n "$ERROR_CODE" ]; thenpass_assert "error has structured code: $ERROR_CODE"else- soft_pass_assert "no structured error code in response (server may use plain message)"+ fail_assert "rejection carries no structured .code, so a caller cannot tell an unknown browser from any other 4xx: $RESULT"fiend_test@@ -79,10 +78,12 @@ TEXT_EXPLICIT="$RESULT"DEFAULT_TEXT=$(echo "$TEXT_DEFAULT" | jq -r '.text // empty' 2>/dev/null | head -c 200)EXPLICIT_TEXT=$(echo "$TEXT_EXPLICIT" | jq -r '.text // empty' 2>/dev/null | head -c 200)-if [ -n "$DEFAULT_TEXT" ] && [ "$DEFAULT_TEXT" = "$EXPLICIT_TEXT" ]; then+if [ -z "$DEFAULT_TEXT" ]; then+ fail_assert "the default-provider read returned no text, so there is nothing to compare the explicit provider against"+elif [ "$DEFAULT_TEXT" = "$EXPLICIT_TEXT" ]; thenpass_assert "explicit provider matches default text"else- soft_pass_assert "text content may differ slightly between calls"+ fail_assert "naming the default provider changed the text read from the same page: '$DEFAULT_TEXT' vs '$EXPLICIT_TEXT'"fiend_testdiff --git a/tests/e2e/scenarios/api/secrets-extended.sh b/tests/e2e/scenarios/api/secrets-extended.shindex d072dc07..77c9ea03 100644--- a/tests/e2e/scenarios/api/secrets-extended.sh+++ b/tests/e2e/scenarios/api/secrets-extended.sh@@ -118,4 +118,9 @@ assert_field_value "#new-password" "$SECRET" "new-password value persisted afterend_test-finish_suite+# Scenarios are SOURCED into one shell, and finish_suite exits when any earlier+# test has failed — unguarded, this file amputates every scenario after it as+# soon as something upstream goes red. Same guard the other scenarios use.+if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then+ finish_suite+fidiff --git a/tests/e2e/scenarios/api/tabs-extended.sh b/tests/e2e/scenarios/api/tabs-extended.shindex 0de19140..1b5482b9 100644--- a/tests/e2e/scenarios/api/tabs-extended.sh+++ b/tests/e2e/scenarios/api/tabs-extended.sh@@ -151,7 +151,7 @@ assert_ok "open tab 3 (triggers eviction)"echo -e " ${MUTED}tab3: ${TAB3:0:12}...${NC}"pt_get "/tabs/$TAB1/snapshot"-assert_http_error 404 "tab1 evicted (LRU)"+assert_http_error 404 "" "tab1 evicted (LRU)"pt_get "/tabs/$TAB2/snapshot" > /dev/nullassert_ok "tab2 survived (recently used)"@@ -173,7 +173,7 @@ TAB4=$(echo "$RESULT" | jq -r '.tabId')assert_ok "open tab 4 (triggers second eviction)"pt_get "/tabs/$TAB2/snapshot"-assert_http_error 404 "tab2 evicted (LRU)"+assert_http_error 404 "" "tab2 evicted (LRU)"pt_get "/tabs/$TAB3/snapshot" > /dev/nullassert_ok "tab3 survived"diff --git a/tests/e2e/scenarios/infra/browser-config-basic.sh b/tests/e2e/scenarios/infra/browser-config-basic.shindex 39519367..e2abb7d1 100755--- a/tests/e2e/scenarios/infra/browser-config-basic.sh+++ b/tests/e2e/scenarios/infra/browser-config-basic.sh@@ -6,6 +6,16 @@GROUP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"source "${GROUP_DIR}/../../helpers/api.sh"+# A config write either lands or it does not. Reporting a rejected PUT as a+# pass is how a broken dashboard write stayed green: 2xx or the test fails.+assert_config_write_ok() {+ if [ "$HTTP_STATUS" = "200" ] || [ "$HTTP_STATUS" = "204" ]; then+ pass_assert "$1"+ else+ fail_assert "$1 — PUT /api/config returned $HTTP_STATUS: $RESULT"+ fi+}+# ─────────────────────────────────────────────────────────────────start_test "config API: GET /api/config returns browser section"@@ -13,12 +23,14 @@ pt_get /api/configassert_ok "get config"assert_json_exists "$RESULT" '.config.browser' "config has browser section"-# The browser section should have a provider field.+# provider is omitted from the config file unless an operator sets it, so its+# absence is a real state of this server rather than a failure. What must hold+# either way is that the key, when present, names a provider rather than null.PROVIDER=$(echo "$RESULT" | jq -r '.config.browser.provider // empty' 2>/dev/null)-if [ -n "$PROVIDER" ] && [ "$PROVIDER" != "null" ]; then+if [ -n "$PROVIDER" ]; thenpass_assert "config browser.provider=$PROVIDER"else- soft_pass_assert "browser.provider not set (using default)"+ skip_assert "browser.provider is unset on this server, so there is no value to check"fiend_test@@ -35,7 +47,7 @@ if [ -n "$PROXY_SECTION" ] && [ "$PROXY_SECTION" != "null" ] && [ "$PROXY_SECTIOfail_assert "proxy password is exposed in config GET response: $PROXY_PASS"fielse- soft_pass_assert "no proxy section in config (none configured)"+ skip_assert "no proxy configured on this server, so redaction has nothing to redact"fi# Check per-target proxy passwords too@@ -59,31 +71,26 @@ ORIGINAL_CONFIG="$RESULT"# Extract the browser section and make a minor update.ORIGINAL_INNER=$(echo "$ORIGINAL_CONFIG" | jq '.config' 2>/dev/null)-UPDATED_INNER=$(echo "$ORIGINAL_INNER" | jq '.browser.blockImages = true' 2>/dev/null)+UPDATED_INNER=$(echo "$ORIGINAL_INNER" | jq -c '.browser.extraFlags = "--e2e-config-roundtrip"' 2>/dev/null)-if [ -n "$UPDATED_INNER" ] && [ "$UPDATED_INNER" != "null" ]; then- # PUT expects a bare FileConfig, not the envelope.- pt_post_raw /api/config "$UPDATED_INNER"-- if [ "$HTTP_STATUS" = "200" ] || [ "$HTTP_STATUS" = "204" ]; then- pass_assert "PUT config accepted"-- # Read back and verify the browser fields survived the round trip.- pt_get /api/config- assert_ok "get config after PUT"-- # Restore original config.- pt_post_raw /api/config "$ORIGINAL_INNER"- if [ "$HTTP_STATUS" = "200" ] || [ "$HTTP_STATUS" = "204" ]; then- pass_assert "config restored"- else- soft_pass_assert "could not restore config (status: $HTTP_STATUS)"- fi- else- soft_pass_assert "PUT config returned $HTTP_STATUS (dashboard auth may be required)"- fi+if [ -z "$UPDATED_INNER" ] || [ "$UPDATED_INNER" = "null" ]; then+ fail_assert "GET /api/config returned no .config object to update: $ORIGINAL_CONFIG"else- soft_pass_assert "could not construct updated config"+ # The endpoint is a PUT and it takes a bare FileConfig, not the envelope.+ pinchtab PUT /api/config -d "$UPDATED_INNER"+ assert_config_write_ok "PUT config accepted"++ pt_get /api/config+ assert_ok "get config after PUT"+ assert_json_eq "$RESULT" '.config.browser.extraFlags' "--e2e-config-roundtrip" "browser.extraFlags survived the round trip"++ pinchtab PUT /api/config -d "$ORIGINAL_INNER"+ assert_config_write_ok "config restored"++ pt_get /api/config+ assert_ok "get config after restore"+ assert_json_eq "$RESULT" '.config.browser.extraFlags' "$(echo "$ORIGINAL_INNER" | jq -r '.browser.extraFlags // ""')" \+ "browser.extraFlags is back to its original value"fiend_test@@ -94,11 +101,8 @@ start_test "config API: security.allowedDomains visible in config"pt_get /api/configassert_ok "get config"-ALLOWED=$(echo "$RESULT" | jq '.config.security.allowedDomains // empty' 2>/dev/null)-if [ -n "$ALLOWED" ] && [ "$ALLOWED" != "null" ]; then- pass_assert "security.allowedDomains present in config"-else- soft_pass_assert "allowedDomains not in config (may use defaults)"-fi+assert_json_jq "$RESULT" '.config.security.allowedDomains | type == "array" and length >= 1' \+ "security.allowedDomains is a non-empty array in the config the API serves" \+ "security.allowedDomains is missing or empty, so the domain policy this server runs under is invisible to the dashboard"end_testdiff --git a/tests/e2e/scenarios/infra/browser-routing-extended.sh b/tests/e2e/scenarios/infra/browser-routing-extended.shindex 830146e1..9e671f3e 100755--- a/tests/e2e/scenarios/infra/browser-routing-extended.sh+++ b/tests/e2e/scenarios/infra/browser-routing-extended.sh@@ -300,20 +300,13 @@ GC_TAB_ROUTE=$(echo "$RESULT" | jq -r '.tabId')ghostchrome_get "/text?tabId=${GC_TAB_ROUTE}"assert_ok "ghost-chrome text"-HAS_ROUTE=$(echo "$RESULT" | jq 'has("route")' 2>/dev/null || echo "false")-if [ "$HAS_ROUTE" = "true" ]; then- # /text bypasses the ghost-chrome adapter (uses readability.js directly),- # so route metadata reflects chrome, not ghost-chrome.- USED=$(echo "$RESULT" | jq -r '.route.usedProvider' 2>/dev/null)- if [ "$USED" = "ghost-chrome" ] || [ "$USED" = "chrome" ]; then- echo -e " ${GREEN}✓${NC} ghost-chrome text route.usedProvider=$USED (text handler may bypass adapter)"- ((ASSERTIONS_PASSED++)) || true- else- echo -e " ${RED}✗${NC} ghost-chrome text route.usedProvider unexpected: $USED"- ((ASSERTIONS_FAILED++)) || true- fi+# /text bypasses the ghost-chrome adapter (uses readability.js directly), so+# route metadata may name chrome as the provider that served it.+USED=$(echo "$RESULT" | jq -r '.route.usedProvider // empty' 2>/dev/null)+if [ "$USED" = "ghost-chrome" ] || [ "$USED" = "chrome" ]; then+ pass_assert "ghost-chrome text route.usedProvider=$USED (text handler may bypass adapter)"else- soft_pass_assert "route metadata not in ghost-chrome text response (format may be text)"+ fail_assert "ghost-chrome text route.usedProvider is '$USED', want ghost-chrome or chrome: $RESULT"fipt_post /navigate "{\"url\":\"${FIXTURES_URL}/form.html\"}"@@ -323,12 +316,7 @@ CHROME_TAB_ROUTE=$(echo "$RESULT" | jq -r '.tabId')pt_get "/text?tabId=${CHROME_TAB_ROUTE}"assert_ok "chrome text"-CHROME_HAS_ROUTE=$(echo "$RESULT" | jq 'has("route")' 2>/dev/null || echo "false")-if [ "$CHROME_HAS_ROUTE" = "true" ]; then- assert_json_eq "$RESULT" '.route.usedProvider' 'chrome' "chrome route.usedProvider=chrome"-else- soft_pass_assert "route metadata not in chrome text response (format may be text)"-fi+assert_json_eq "$RESULT" '.route.usedProvider' 'chrome' "chrome route.usedProvider=chrome"end_test@@ -354,12 +342,7 @@ else((ASSERTIONS_FAILED++)) || truefi-SNAP_HAS_ROUTE=$(echo "$RESULT" | jq 'has("route")' 2>/dev/null || echo "false")-if [ "$SNAP_HAS_ROUTE" = "true" ]; then- assert_json_contains "$RESULT" '.route.usedProvider' 'ghost-chrome' "ghost-chrome snapshot route.usedProvider contains ghost-chrome"-else- soft_pass_assert "route metadata not in ghost-chrome snapshot response"-fi+assert_json_contains "$RESULT" '.route.usedProvider' 'ghost-chrome' "ghost-chrome snapshot route.usedProvider contains ghost-chrome"end_testdiff --git a/tests/e2e/scenarios/infra/browser-routing-smoke.sh b/tests/e2e/scenarios/infra/browser-routing-smoke.shindex d97b6d97..8ffb30e8 100644--- a/tests/e2e/scenarios/infra/browser-routing-smoke.sh+++ b/tests/e2e/scenarios/infra/browser-routing-smoke.sh@@ -44,12 +44,7 @@ pt_post "/navigate" -d "{\"url\":\"${FIXTURES_URL}/buttons.html\",\"browser\":\"assert_ok "navigate with browser=${CONFIGURED}"assert_json_contains "$RESULT" '.url' 'buttons.html' "navigated to buttons page"-HAS_ROUTE=$(echo "$RESULT" | jq 'has("route")' 2>/dev/null || echo "false")-if [ "$HAS_ROUTE" = "true" ]; then- assert_json_eq "$RESULT" '.route.requestedProvider' "${CONFIGURED}" "route.requestedProvider=${CONFIGURED}"-else- soft_pass_assert "route metadata not in navigate response"-fi+assert_json_eq "$RESULT" '.route.requestedProvider' "${CONFIGURED}" "route.requestedProvider=${CONFIGURED}"end_testdiff --git a/tests/e2e/scenarios/manifest.json b/tests/e2e/scenarios/manifest.jsonindex 2e588778..ce45858e 100644--- a/tests/e2e/scenarios/manifest.json+++ b/tests/e2e/scenarios/manifest.json@@ -440,6 +440,15 @@]},"api/browser-activity-basic.sh": {+ "services": [+ "pinchtab",+ "pinchtab-bridge",+ "fixtures"+ ],+ "ready": [+ "E2E_SERVER",+ "E2E_BRIDGE_URL|60|E2E_BRIDGE_TOKEN"+ ],"tags": ["browser","activity",