#!/bin/bash
# Quick test script for StudioBridge

echo "=== AeThex StudioBridge Quick Test ==="
echo ""

# Check if engine binary exists
if [ ! -f "engine/bin/aethex.linuxbsd.editor.x86_64" ]; then
    echo "❌ Engine binary not found. Run: cd engine && scons platform=linuxbsd target=editor -j2"
    exit 1
fi

echo "✅ Engine binary found"
echo ""

# Test HTTP server with curl
echo "📡 Testing StudioBridge API..."
echo ""

echo "Test 1: Check if server is running (this will fail if engine isn't running)"
if curl -s -X POST http://localhost:6007/rpc \
    -H "Content-Type: application/json" \
    -d '{"method":"getAllNodeTypes","params":{}}' > /dev/null 2>&1; then
    echo "✅ Server is running!"
    echo ""
    
    echo "Test 2: Get all node types"
    curl -X POST http://localhost:6007/rpc \
        -H "Content-Type: application/json" \
        -d '{"method":"getAllNodeTypes","params":{}}' | head -c 500
    echo ""
    echo ""
    
    echo "Test 3: Get scene tree"
    curl -X POST http://localhost:6007/rpc \
        -H "Content-Type: application/json" \
        -d '{"method":"getSceneTree","params":{}}'
    echo ""
    echo ""
    
    echo "✅ All tests passed!"
else
    echo "⚠️  Server not responding"
    echo ""
    echo "To start the engine with bridge:"
    echo "1. cd engine"
    echo "2. ./bin/aethex.linuxbsd.editor.x86_64"
    echo "3. File → Open → test_bridge.gd"
    echo "4. Press F5 to run"
    echo "5. Then run this script again"
fi

echo ""
echo "=== Test Complete ==="
