Skip to content

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

fix(e2e): replace jq|head -1 with jq first to prevent SIGPIPE

Boschdbc37a978af4
diff --git a/tests/e2e/scenarios-cli/common.sh b/tests/e2e/scenarios-cli/common.sh
index 0f773e41..20d56d82 100755
--- a/tests/e2e/scenarios-cli/common.sh
+++ b/tests/e2e/scenarios-cli/common.sh
@@ -220,13 +220,13 @@ assert_json_field_contains() {
find_ref_by_role() {
local role="$1"
local json="${2:-$PT_OUT}"
- echo "$json" | jq -r ".nodes[] | select(.role == \"$role\") | .ref" | head -1
+ echo "$json" | jq -r "[.nodes[] | select(.role == \"$role\") | .ref] | first // empty"
}
find_ref_by_name() {
local name="$1"
local json="${2:-$PT_OUT}"
- echo "$json" | jq -r ".nodes[] | select(.name == \"$name\") | .ref" | head -1
+ echo "$json" | jq -r "[.nodes[] | select(.name == \"$name\") | .ref] | first // empty"
}
assert_ref_found() {
diff --git a/tests/e2e/scenarios/common.sh b/tests/e2e/scenarios/common.sh
index b9f587b7..91263857 100755
--- a/tests/e2e/scenarios/common.sh
+++ b/tests/e2e/scenarios/common.sh
@@ -457,7 +457,7 @@ assert_not_ok() {
click_button() {
local name="$1"
local ref
- ref=$(echo "$RESULT" | jq -r ".nodes[] | select(.name == \"$name\") | .ref" | head -1)
+ ref=$(echo "$RESULT" | jq -r "[.nodes[] | select(.name == \"$name\") | .ref] | first // empty")
if [ -n "$ref" ] && [ "$ref" != "null" ]; then
pt_post /action "{\"kind\":\"click\",\"ref\":\"${ref}\"}" > /dev/null
@@ -474,11 +474,11 @@ type_into() {
local name="$1"
local text="$2"
local ref
- ref=$(echo "$RESULT" | jq -r ".nodes[] | select(.name == \"$name\") | .ref" | head -1)
+ ref=$(echo "$RESULT" | jq -r "[.nodes[] | select(.name == \"$name\") | .ref] | first // empty")
# Fallback to textbox role if name not found
if [ -z "$ref" ] || [ "$ref" = "null" ]; then
- ref=$(echo "$RESULT" | jq -r '.nodes[] | select(.role == "textbox") | .ref' | head -1)
+ ref=$(echo "$RESULT" | jq -r '[.nodes[] | select(.role == "textbox") | .ref] | first // empty')
fi
if [ -n "$ref" ] && [ "$ref" != "null" ]; then
@@ -590,7 +590,7 @@ assert_tab_closed() {
find_ref_by_role() {
local role="$1"
local json="${2:-$RESULT}"
- echo "$json" | jq -r ".nodes[] | select(.role == \"$role\") | .ref" | head -1
+ echo "$json" | jq -r "[.nodes[] | select(.role == \"$role\") | .ref] | first // empty"
}
# Find first ref by name from RESULT or PT_OUT
@@ -598,7 +598,7 @@ find_ref_by_role() {
find_ref_by_name() {
local name="$1"
local json="${2:-$RESULT}"
- echo "$json" | jq -r ".nodes[] | select(.name == \"$name\") | .ref" | head -1
+ echo "$json" | jq -r "[.nodes[] | select(.name == \"$name\") | .ref] | first // empty"
}
# Assert ref was found, with readable error