High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.
test(e2e): storage get/delete and state save/show/load/delete take the key or name positionally, refuse it given twice, and a bare storage delete names storage clear and wipes nothing (PIN-430)
Luigi Agosti0c1f8f8ad6dc
diff --git a/tests/e2e/scenarios/cli/state-basic.sh b/tests/e2e/scenarios/cli/state-basic.shindex 44277e0f..5139f2cc 100644--- a/tests/e2e/scenarios/cli/state-basic.sh+++ b/tests/e2e/scenarios/cli/state-basic.sh@@ -116,3 +116,79 @@ elsefiend_test++# ═══════════════════════════════════════════════════════════════════+# Positional name shapes+# ═══════════════════════════════════════════════════════════════════++POS_STATE="cli-pos-state-$(date +%s)"++assert_err_contains() {+ local needle="$1" desc="$2"+ if grep -q -- "$needle" <<<"$PT_ERR"; then+ pass_assert "$desc"+ else+ fail_assert "$desc"+ echo -e " ${RED} stderr was: $PT_ERR${NC}"+ fi+}++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab state save/show/load/delete <name> round trip positionally"++pt navigate "${FIXTURES_URL}/index.html"+assert_cli_ok "navigate to fixture"++pt_cli state save "$POS_STATE"+assert_cli_ok "save positional"++pt_cli state list+assert_output_contains "$POS_STATE" "list shows the positionally saved state"++pt_cli state show "$POS_STATE"+assert_cli_ok "show positional"+assert_output_contains "$POS_STATE" "show prints the named state"++pt_cli state load "$POS_STATE"+assert_cli_ok "load positional"++pt_cli state delete "$POS_STATE"+assert_cli_ok "delete positional"++pt_fail state show "$POS_STATE"++pt_cli state list+assert_output_not_contains "$POS_STATE" "list no longer shows the deleted state"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab state verbs refuse a name given as argument and --name"++pt_cli state save "$POS_STATE"+assert_cli_ok "save for refusal checks"++for verb in save load show delete; do+ pt_fail state "$verb" "$POS_STATE" --name other-name+ assert_err_contains "twice" "state $verb refusal says the name was given twice"+done++pt_cli state show --name "$POS_STATE"+assert_cli_ok "state survives the refused delete (--name show)"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab state show/delete/load with no name are refused"++for verb in show delete load; do+ pt_fail state "$verb"+done++pt_cli state show "$POS_STATE"+assert_cli_ok "state survives the bare delete"++pt_cli state delete "$POS_STATE"+assert_cli_ok "cleanup positional state"++end_testdiff --git a/tests/e2e/scenarios/cli/storage-basic.sh b/tests/e2e/scenarios/cli/storage-basic.shindex 9f6f7cac..2dbbb019 100644--- a/tests/e2e/scenarios/cli/storage-basic.sh+++ b/tests/e2e/scenarios/cli/storage-basic.sh@@ -104,3 +104,88 @@ elsefiend_test++# ═══════════════════════════════════════════════════════════════════+# Positional key shapes+# ═══════════════════════════════════════════════════════════════════++assert_err_contains() {+ local needle="$1" desc="$2"+ if grep -q -- "$needle" <<<"$PT_ERR"; then+ pass_assert "$desc"+ else+ fail_assert "$desc"+ echo -e " ${RED} stderr was: $PT_ERR${NC}"+ fi+}++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab storage get <key> reads one item positionally"++pt navigate "${FIXTURES_URL}/index.html"+assert_cli_ok "navigate to fixture"+pt_cli storage set pos_k1 pos_v1 --type local+assert_cli_ok "set pos_k1"+pt_cli storage set pos_k2 pos_v2 --type local+assert_cli_ok "set pos_k2"++pt_cli storage get pos_k1 --type local+assert_cli_ok "get pos_k1 positionally"+assert_json_field '.local | length' '1' "positional get returns exactly one item"+assert_json_field '.local[0].key' 'pos_k1' "positional get returns the named key"+assert_json_field '.local[0].value' 'pos_v1' "positional get returns its value"++pt_cli storage get --key pos_k2 --type local+assert_cli_ok "get --key pos_k2 still works"+assert_json_field '.local[0].value' 'pos_v2' "--key get returns its value"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab storage get/delete refuse a key given as argument and --key"++pt_fail storage get pos_k1 --key pos_k2+assert_err_contains "pos_k1" "get refusal names the argument"+assert_err_contains "pos_k2" "get refusal names the flag value"++pt_fail storage delete pos_k1 --key pos_k2 --type local+assert_err_contains "twice" "delete refusal says the key was given twice"++pt_cli storage get --type local+assert_json_field '[.local[].key] | map(select(. == "pos_k1" or . == "pos_k2")) | length' '2' \+ "a refused delete removed nothing"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "bare pinchtab storage delete is refused, names storage clear, and wipes nothing"++pt_fail storage delete+assert_err_contains "storage clear" "refusal names storage clear"++pt_fail storage delete --key ""+assert_err_contains "storage clear" "empty --key refusal names storage clear"++pt_cli storage get --type local+assert_cli_ok "get after refused bare delete"+assert_json_field '[.local[].key] | map(select(. == "pos_k1" or . == "pos_k2")) | length' '2' \+ "both keys survive a bare storage delete"++end_test++# ─────────────────────────────────────────────────────────────────+start_test "pinchtab storage delete <key> removes only that key"++pt_cli storage delete pos_k1 --type local+assert_cli_ok "delete pos_k1 positionally"++pt_cli storage get --type local+assert_json_field '[.local[].key] | index("pos_k1")' 'null' "pos_k1 is gone"+assert_json_field '[.local[] | select(.key == "pos_k2") | .value][0]' 'pos_v2' "pos_k2 survives"++pt_cli storage delete --key pos_k2 --type local+assert_cli_ok "delete --key pos_k2 still works"+pt_cli storage get pos_k2 --type local+assert_json_field '.local | length' '0' "pos_k2 is gone after --key delete"++end_test