#!/bin/bash

# BDD Test Runner Script
# Runs all BDD tests and fails if there are undefined, pending, or skipped steps

set -e

echo "🧪 Running BDD Tests..."
cd /Users/gabrielradureau/Work/Vibe/DanceLessonsCoach

# Run the BDD tests
test_output=$(go test ./features/... -v 2>&1)
test_exit_code=$?

echo "$test_output"

# Check for undefined steps
if echo "$test_output" | grep -q "undefined"; then
    echo "❌ FAILED: Found undefined steps"
    exit 1
fi

# Check for pending steps
if echo "$test_output" | grep -q "pending"; then
    echo "❌ FAILED: Found pending steps"
    exit 1
fi

# Check for skipped steps
if echo "$test_output" | grep -q "skipped"; then
    echo "❌ FAILED: Found skipped steps"
    exit 1
fi

# Check if tests passed
if [ $test_exit_code -eq 0 ]; then
    echo "✅ All BDD tests passed successfully!"
    exit 0
else
    echo "❌ BDD tests failed"
    exit 1
fi
