#!/bin/bash

# Test script for TradingView automation in Docker using Docker Compose v2
echo "Testing TradingView automation in Docker container..."

# Check if container is running
if ! docker compose ps app | grep -q "Up"; then
    echo "Starting Docker container with Docker Compose v2..."
    docker compose up -d --build
    sleep 10  # Wait for container to be fully ready
fi

# Test 1: Health check
echo "1. Testing health check..."
curl -X GET http://localhost:3000/api/trading/automated-analysis

echo -e "\n\n2. Testing automated analysis (you'll need to provide credentials)..."
echo "Example curl command:"
echo 'curl -X POST http://localhost:3000/api/trading/automated-analysis \
  -H "Content-Type: application/json" \
  -d "{
    \"symbol\": \"SOLUSD\",
    \"timeframe\": \"5\",
    \"credentials\": {
      \"email\": \"your-email@example.com\",
      \"password\": \"your-password\"
    }
  }"'

echo -e "\n\nNote: Replace the credentials with your actual TradingView login details."
echo "The automation will:"
echo "- Login to TradingView"
echo "- Navigate to the specified chart"
echo "- Take a screenshot"
echo "- Analyze it with AI"
echo "- Return the analysis results"

echo -e "\n\nTo view logs: docker compose logs -f app"
echo "To stop container: docker compose down"
