#!/bin/bash
set -euo pipefail

# Load environment from .env.test if exists
if [ -f .env.test ]; then
    set -a
    source .env.test
    set +a
fi

# Configuration
# Default to production docker-compose file if not specified
COMPOSE_FILE="docker-compose.production.yml"

echo "🔥 Starting VEZA Full Smoke Test..."

# 0. Ensure Stack is Up (with env file)
echo "Checking if stack is running..."
if [ -f .env.test ]; then
    docker compose --env-file .env.test -f $COMPOSE_FILE up -d
else
    docker compose -f $COMPOSE_FILE up -d
fi

# 1. Health Check
echo ""
./scripts/smoke_health.sh

# 2. User A Scenario
echo ""
./scripts/smoke_user_a.sh

# 3. User B & Chat Setup
echo ""
./scripts/smoke_user_b_chat.sh

echo ""
echo "══════════════════════════════════════════════"
echo "✅ ALL AUTOMATED SMOKE TESTS PASSED"
echo "══════════════════════════════════════════════"
echo "Next steps:"
echo "1. Run manual WebSocket tests: cat docs/CHAT_WEBSOCKET_TEST.md"
echo "2. Run manual UI tests: cat docs/SMOKE_UI_CHECKLIST.md"
