Skip to content

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

refactor(e2e): add assert_tab_id helper, use in tabs-errors

Bosch0f52be493c97
diff --git a/tests/e2e/scenarios/32-tabs-errors.sh b/tests/e2e/scenarios/32-tabs-errors.sh
index 0593ef7b..dc4f03aa 100755
--- a/tests/e2e/scenarios/32-tabs-errors.sh
+++ b/tests/e2e/scenarios/32-tabs-errors.sh
@@ -47,15 +47,7 @@ start_test "tabs: new tab returns tabId"
pt_post /tab '{"action":"new","url":"about:blank"}'
assert_ok "new tab"
-TAB_ID=$(echo "$RESULT" | jq -r '.tabId')
-
-if [ -n "$TAB_ID" ] && [ "$TAB_ID" != "null" ]; then
- echo -e " ${GREEN}✓${NC} tabId returned: ${TAB_ID:0:12}..."
- ((ASSERTIONS_PASSED++)) || true
-else
- echo -e " ${RED}✗${NC} no tabId in response"
- ((ASSERTIONS_FAILED++)) || true
-fi
+assert_tab_id "new tab returns tabId"
# Cleanup
pt_post /tab "{\"action\":\"close\",\"tabId\":\"${TAB_ID}\"}"
diff --git a/tests/e2e/scenarios/common.sh b/tests/e2e/scenarios/common.sh
index 91008ca8..43883dff 100755
--- a/tests/e2e/scenarios/common.sh
+++ b/tests/e2e/scenarios/common.sh
@@ -513,6 +513,20 @@ get_tab_id() {
echo "$RESULT" | jq -r '.tabId'
}
+# Extract tabId from RESULT, assert it's non-null, store in TAB_ID
+# Usage: assert_tab_id "description"
+assert_tab_id() {
+ local desc="${1:-tabId returned}"
+ TAB_ID=$(echo "$RESULT" | jq -r '.tabId')
+ if [ -n "$TAB_ID" ] && [ "$TAB_ID" != "null" ]; then
+ echo -e " ${GREEN}✓${NC} $desc: ${TAB_ID:0:12}..."
+ ((ASSERTIONS_PASSED++)) || true
+ else
+ echo -e " ${RED}✗${NC} no tabId in response"
+ ((ASSERTIONS_FAILED++)) || true
+ fi
+}
+
# Get first tab ID from /tabs response
get_first_tab() {
echo "$RESULT" | jq -r '.tabs[0].id'