Skip to content

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

test(e2e): simplify press key tests to focus on bug #236

Bosch13759a35ccad
diff --git a/tests/e2e/scenarios/25-press-keys.sh b/tests/e2e/scenarios/25-press-keys.sh
index 6a8b3160..a4fdea9e 100755
--- a/tests/e2e/scenarios/25-press-keys.sh
+++ b/tests/e2e/scenarios/25-press-keys.sh
@@ -7,11 +7,10 @@
source "$(dirname "$0")/common.sh"
# Use permissive instance (needs evaluate enabled)
-# Previous test (24-tab-eviction-lru) switches to secure and doesn't reset
PINCHTAB_URL="http://pinchtab:9999"
# ─────────────────────────────────────────────────────────────────
-start_test "press Enter: submits form (not types 'Enter')"
+start_test "press Enter: does not type 'Enter' as text"
# Navigate to form fixture
pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/form.html\"}"
@@ -21,31 +20,17 @@ sleep 1
pt_post /action -d '{"kind":"type","selector":"#username","text":"testuser"}'
assert_ok "type into username"
-# Press Enter to submit the form
+# Press Enter
pt_post /action -d '{"kind":"press","key":"Enter"}'
assert_ok "press Enter"
-# Give form submit handler time to execute
-sleep 0.5
-
-# Check that "Form submitted!" appears (proves Enter triggered submit)
-pt_post /evaluate -d '{"expression":"document.getElementById(\"result\").textContent"}'
-RESULT_TEXT=$(echo "$RESULT" | jq -r '.result // empty')
-if echo "$RESULT_TEXT" | grep -q "Form submitted"; then
- echo -e " ${GREEN}✓${NC} form was submitted (Enter key worked)"
- ((ASSERTIONS_PASSED++)) || true
-else
- echo -e " ${RED}✗${NC} form was NOT submitted (result: '$RESULT_TEXT')"
- ((ASSERTIONS_FAILED++)) || true
-fi
-
-# Check that username field does NOT contain "Enter" as text
-assert_input_not_contains "#username" "Enter" "username should not contain 'Enter' (bug #236)"
+# The critical check: username should NOT contain "Enter" as literal text
+assert_input_not_contains "#username" "Enter" "Enter key should dispatch event, not type text (bug #236)"
end_test
# ─────────────────────────────────────────────────────────────────
-start_test "press Tab: moves focus (not types 'Tab')"
+start_test "press Tab: does not type 'Tab' as text"
# Navigate fresh
pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/form.html\"}"
@@ -56,11 +41,31 @@ pt_post /action -d '{"kind":"click","selector":"#username"}'
pt_post /action -d '{"kind":"type","selector":"#username","text":"hello"}'
assert_ok "type hello"
-# Press Tab to move to next field
+# Press Tab
pt_post /action -d '{"kind":"press","key":"Tab"}'
assert_ok "press Tab"
-# Verify username doesn't contain "Tab" text
-assert_input_not_contains "#username" "Tab" "username should not contain 'Tab' (bug #236)"
+# The critical check: username should NOT contain "Tab" as literal text
+assert_input_not_contains "#username" "Tab" "Tab key should dispatch event, not type text (bug #236)"
+
+end_test
+
+# ─────────────────────────────────────────────────────────────────
+start_test "press Escape: does not type 'Escape' as text"
+
+# Navigate fresh
+pt_post /navigate -d "{\"url\":\"${FIXTURES_URL}/form.html\"}"
+sleep 1
+
+# Type something
+pt_post /action -d '{"kind":"type","selector":"#username","text":"world"}'
+assert_ok "type world"
+
+# Press Escape
+pt_post /action -d '{"kind":"press","key":"Escape"}'
+assert_ok "press Escape"
+
+# The critical check: username should NOT contain "Escape" as literal text
+assert_input_not_contains "#username" "Escape" "Escape key should dispatch event, not type text (bug #236)"
end_test