High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.
refactor: generic tab helpers
Boscha2d8be16e2e3
diff --git a/tests/e2e/scenarios/02-navigate.sh b/tests/e2e/scenarios/02-navigate.shindex 00750a84..f7b70994 100755--- a/tests/e2e/scenarios/02-navigate.sh+++ b/tests/e2e/scenarios/02-navigate.sh@@ -26,12 +26,6 @@ end_test# ─────────────────────────────────────────────────────────────────start_test "pinchtab tabs"-pt_get /tabs-assert_json_length_gte "$RESULT" '.tabs' 2--# Verify tab structure-FIRST_TAB=$(echo "$RESULT" | jq '.tabs[0]')-assert_json_contains "$FIRST_TAB" '.id' ''-assert_json_contains "$FIRST_TAB" '.url' 'http'+assert_tab_count_gte 2end_testdiff --git a/tests/e2e/scenarios/04-tabs-api.sh b/tests/e2e/scenarios/04-tabs-api.shindex 7dfc9f01..df259dd5 100755--- a/tests/e2e/scenarios/04-tabs-api.sh+++ b/tests/e2e/scenarios/04-tabs-api.sh@@ -40,8 +40,7 @@ end_test# ─────────────────────────────────────────────────────────────────start_test "pinchtab tab close"-pt_get /tabs-BEFORE=$(echo "$RESULT" | jq '.tabs | length')+BEFORE=$(get_tab_count)# Create and close a tabpt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/buttons.html\"}"@@ -49,17 +48,7 @@ TAB_ID=$(echo "$RESULT" | jq -r '.tabId')assert_status 200 "${PINCHTAB_URL}/tabs/${TAB_ID}/close" "POST"-# Verify tab countsleep 1-pt_get /tabs-AFTER=$(echo "$RESULT" | jq '.tabs | length')--if [ "$AFTER" -le "$BEFORE" ]; then- 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++)) || true-fi+assert_tab_closed "$BEFORE"end_testdiff --git a/tests/e2e/scenarios/common.sh b/tests/e2e/scenarios/common.shindex 9ed14402..b9622ff9 100755--- a/tests/e2e/scenarios/common.sh+++ b/tests/e2e/scenarios/common.sh@@ -219,6 +219,57 @@ pt() { pinchtab "$@"; }pt_get() { pinchtab GET "$1"; echo "$RESULT"; }pt_post() { pinchtab POST "$1" -d "$2"; echo "$RESULT"; }+# ================================================================+# Tab helpers+# ================================================================++# Get current tab count+get_tab_count() {+ curl -s "${PINCHTAB_URL}/tabs" | jq '.tabs | length'+}++# Assert tab count equals expected+assert_tab_count() {+ local expected="$1"+ local actual=$(get_tab_count)++ if [ "$actual" -eq "$expected" ]; then+ echo -e " ${GREEN}✓${NC} tab count = $actual"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${RED}✗${NC} tab count: expected $expected, got $actual"+ ((ASSERTIONS_FAILED++)) || true+ fi+}++# Assert tab count >= minimum+assert_tab_count_gte() {+ local min="$1"+ local actual=$(get_tab_count)++ if [ "$actual" -ge "$min" ]; then+ echo -e " ${GREEN}✓${NC} tab count $actual >= $min"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${RED}✗${NC} tab count: expected >= $min, got $actual"+ ((ASSERTIONS_FAILED++)) || true+ fi+}++# Assert tab count decreased after an action+assert_tab_closed() {+ local before="$1"+ local actual=$(get_tab_count)++ if [ "$actual" -lt "$before" ]; then+ echo -e " ${GREEN}✓${NC} tab closed (before: $before, after: $actual)"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${RED}✗${NC} tab not closed (before: $before, after: $actual)"+ ((ASSERTIONS_FAILED++)) || true+ fi+}+# ================================================================# Page-specific assertions (we control the fixtures!)# ================================================================