#!/bin/bash
# Run all VHS e2e tests

set -e

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"

echo "Running lazygitclj VHS e2e tests..."
echo "================================="

# List of test tapes
TESTS=(
    "debug.tape"
    "navigation.tape"
    "staging.tape"
    "commit.tape"
    "commit-verify.tape"
    "branches.tape"
    "branch-operations.tape"
    "stash-operations.tape"
    "stash-menu.tape"
    "help-panel.tape"
    "reset-menu.tape"
    "commits-tabs.tape"
    "branches-tabs.tape"
    "undo-redo.tape"
)

PASSED=0
FAILED=0

for tape in "${TESTS[@]}"; do
    echo ""
    echo "Running: $tape"
    echo "---"

    if timeout 60 vhs "$tape" 2>&1; then
        echo "PASSED: $tape"
        ((PASSED++))
    else
        echo "FAILED: $tape"
        ((FAILED++))
    fi
done

echo ""
echo "================================="
echo "Results: $PASSED passed, $FAILED failed"
echo "================================="

if [ $FAILED -gt 0 ]; then
    exit 1
fi
