High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.
feat: page-specific assertions for controlled fixtures
Boschc57ff0341a88
diff --git a/tests/e2e/scenarios/03-snapshot.sh b/tests/e2e/scenarios/03-snapshot.shindex e2fcc655..524dfb81 100755--- a/tests/e2e/scenarios/03-snapshot.sh+++ b/tests/e2e/scenarios/03-snapshot.sh@@ -9,45 +9,40 @@ start_test "pinchtab snap"pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/\"}"pt_get /snapshot+assert_index_page "$RESULT"assert_json_length_gte "$RESULT" '.nodes' 1-assert_json_contains "$RESULT" '.title' 'E2E Test'-assert_json_contains "$RESULT" '.url' 'fixtures'--# Check node structure-FIRST_NODE=$(echo "$RESULT" | jq '.nodes[0]')-assert_json_contains "$FIRST_NODE" '.ref' 'e'-assert_json_contains "$FIRST_NODE" '.role' ''end_test# ─────────────────────────────────────────────────────────────────-start_test "pinchtab snap (interactive elements)"+start_test "pinchtab snap (buttons.html)"pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/buttons.html\"}"sleep 1pt_get /snapshot+assert_buttons_page "$RESULT"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab snap (form.html)"++pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/form.html\"}"+sleep 1-# Should find buttons-BUTTON_COUNT=$(echo "$RESULT" | jq '[.nodes[] | select(.role == "button")] | length')-if [ "$BUTTON_COUNT" -ge 3 ]; then- echo -e " ${GREEN}✓${NC} Found $BUTTON_COUNT buttons"- ((ASSERTIONS_PASSED++)) || true-else- echo -e " ${RED}✗${NC} Expected >=3 buttons, found $BUTTON_COUNT"- ((ASSERTIONS_FAILED++)) || true-fi+pt_get /snapshot+assert_form_page "$RESULT"end_test# ─────────────────────────────────────────────────────────────────-start_test "pinchtab text"+start_test "pinchtab text (table.html)"pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/table.html\"}"sleep 1-pt_get /text-assert_json_contains "$RESULT" '.text' 'Alice Johnson'-assert_json_contains "$RESULT" '.text' '[email protected]'+TEXT_RESULT=$(curl -s "${PINCHTAB_URL}/text" | jq -r '.text')+assert_table_page "$TEXT_RESULT"end_testdiff --git a/tests/e2e/scenarios/common.sh b/tests/e2e/scenarios/common.shindex 7e6f5317..9ed14402 100755--- a/tests/e2e/scenarios/common.sh+++ b/tests/e2e/scenarios/common.sh@@ -219,6 +219,86 @@ pt() { pinchtab "$@"; }pt_get() { pinchtab GET "$1"; echo "$RESULT"; }pt_post() { pinchtab POST "$1" -d "$2"; echo "$RESULT"; }+# ================================================================+# Page-specific assertions (we control the fixtures!)+# ================================================================++# buttons.html: Increment, Decrement, Reset, Toggle visibility, Show Message+assert_buttons_page() {+ local snap="$1"+ local expected_buttons=("Increment" "Decrement" "Reset")+ local found=0++ for btn in "${expected_buttons[@]}"; do+ if echo "$snap" | jq -e ".nodes[] | select(.name == \"$btn\")" > /dev/null 2>&1; then+ ((found++))+ fi+ done++ if [ "$found" -ge 3 ]; then+ echo -e " ${GREEN}✓${NC} buttons.html: found $found/3 expected buttons"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${RED}✗${NC} buttons.html: found only $found/3 expected buttons"+ ((ASSERTIONS_FAILED++)) || true+ fi+}++# form.html: username, email, password fields + Submit button+assert_form_page() {+ local snap="$1"+ local checks=0++ # Check for textboxes (username, email)+ local textboxes=$(echo "$snap" | jq '[.nodes[] | select(.role == "textbox")] | length')+ [ "$textboxes" -ge 2 ] && ((checks++))++ # Check for Submit button+ echo "$snap" | jq -e '.nodes[] | select(.name == "Submit")' > /dev/null 2>&1 && ((checks++))++ # Check for combobox (country select)+ echo "$snap" | jq -e '.nodes[] | select(.role == "combobox")' > /dev/null 2>&1 && ((checks++))++ if [ "$checks" -ge 3 ]; then+ echo -e " ${GREEN}✓${NC} form.html: found inputs, submit button, and select"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${RED}✗${NC} form.html: missing expected elements ($checks/3)"+ ((ASSERTIONS_FAILED++)) || true+ fi+}++# table.html: Alice Johnson, [email protected], etc.+assert_table_page() {+ local text="$1"+ local checks=0++ echo "$text" | grep -q "Alice Johnson" && ((checks++))+ echo "$text" | grep -q "[email protected]" && ((checks++))+ echo "$text" | grep -q "Engineer" && ((checks++))++ if [ "$checks" -ge 3 ]; then+ echo -e " ${GREEN}✓${NC} table.html: found expected table data"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${RED}✗${NC} table.html: missing expected data ($checks/3)"+ ((ASSERTIONS_FAILED++)) || true+ fi+}++# index.html: Welcome header+assert_index_page() {+ local snap="$1"++ if echo "$snap" | jq -e '.title' | grep -q "E2E Test"; then+ echo -e " ${GREEN}✓${NC} index.html: correct title"+ ((ASSERTIONS_PASSED++)) || true+ else+ echo -e " ${RED}✗${NC} index.html: wrong title"+ ((ASSERTIONS_FAILED++)) || true+ fi+}+# Print summaryprint_summary() {local total=$((TESTS_PASSED + TESTS_FAILED))