127 lines
4.0 KiB
Bash
Executable File
127 lines
4.0 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Test script for Banatie Prompt Enhancement API endpoints
|
|
BASE_URL="http://localhost:3000"
|
|
|
|
echo "🧪 Testing Banatie Prompt Enhancement API"
|
|
echo "========================================="
|
|
|
|
# Test 1: Health check first
|
|
echo "1. Testing health endpoint..."
|
|
curl -s "$BASE_URL/health" | jq '.status' || echo "Health endpoint failed"
|
|
echo -e "\n"
|
|
|
|
# Test 2: API info (should now include enhance endpoint)
|
|
echo "2. Testing API info endpoint..."
|
|
curl -s "$BASE_URL/api/info" | jq '.endpoints' || echo "API info endpoint failed"
|
|
echo -e "\n"
|
|
|
|
# Test 3: Basic prompt enhancement
|
|
echo "3. Testing basic prompt enhancement..."
|
|
curl -s -X POST "$BASE_URL/api/enhance" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{
|
|
"prompt": "cat"
|
|
}' | jq '.' || echo "Basic enhancement test failed"
|
|
echo -e "\n"
|
|
|
|
# Test 4: Prompt enhancement with options
|
|
echo "4. Testing prompt enhancement with options..."
|
|
curl -s -X POST "$BASE_URL/api/enhance" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{
|
|
"prompt": "beautiful sunset",
|
|
"options": {
|
|
"imageStyle": "photorealistic",
|
|
"aspectRatio": "landscape",
|
|
"mood": "serene",
|
|
"lighting": "golden hour"
|
|
}
|
|
}' | jq '.' || echo "Enhancement with options test failed"
|
|
echo -e "\n"
|
|
|
|
# Test 5: Multilingual prompt enhancement (Spanish)
|
|
echo "5. Testing Spanish prompt enhancement..."
|
|
curl -s -X POST "$BASE_URL/api/enhance" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{
|
|
"prompt": "un gato hermoso con ojos azules",
|
|
"options": {
|
|
"imageStyle": "illustration"
|
|
}
|
|
}' | jq '.' || echo "Spanish enhancement test failed"
|
|
echo -e "\n"
|
|
|
|
# Test 6: Multilingual prompt enhancement (Chinese)
|
|
echo "6. Testing Chinese prompt enhancement..."
|
|
curl -s -X POST "$BASE_URL/api/enhance" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{
|
|
"prompt": "美丽的山景",
|
|
"options": {
|
|
"imageStyle": "minimalist"
|
|
}
|
|
}' | jq '.' || echo "Chinese enhancement test failed"
|
|
echo -e "\n"
|
|
|
|
# Test 7: Sticker style prompt
|
|
echo "7. Testing sticker style enhancement..."
|
|
curl -s -X POST "$BASE_URL/api/enhance" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{
|
|
"prompt": "happy panda",
|
|
"options": {
|
|
"imageStyle": "sticker",
|
|
"negativePrompts": ["dark", "scary"]
|
|
}
|
|
}' | jq '.' || echo "Sticker style test failed"
|
|
echo -e "\n"
|
|
|
|
# Test 8: Validation error test (empty prompt)
|
|
echo "8. Testing validation error (empty prompt)..."
|
|
curl -s -X POST "$BASE_URL/api/enhance" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{
|
|
"prompt": ""
|
|
}' | jq '.' || echo "Validation error test failed"
|
|
echo -e "\n"
|
|
|
|
# Test 9: Validation error test (invalid image style)
|
|
echo "9. Testing validation error (invalid style)..."
|
|
curl -s -X POST "$BASE_URL/api/enhance" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{
|
|
"prompt": "test",
|
|
"options": {
|
|
"imageStyle": "invalid_style"
|
|
}
|
|
}' | jq '.' || echo "Invalid style test failed"
|
|
echo -e "\n"
|
|
|
|
# Test 10: Auto-enhancement in generate endpoint
|
|
echo "10. Testing auto-enhancement in generate endpoint..."
|
|
curl -s -X POST "$BASE_URL/api/generate" \
|
|
-F "prompt=gato bonito" \
|
|
-F "filename=test_autoenhance" \
|
|
-F "autoEnhance=true" \
|
|
-F "enhancementOptions[imageStyle]=photorealistic" | jq '.' || echo "Auto-enhancement test failed"
|
|
echo -e "\n"
|
|
|
|
# Test 11: Generate without auto-enhancement (normal behavior)
|
|
echo "11. Testing generate without auto-enhancement..."
|
|
curl -s -X POST "$BASE_URL/api/generate" \
|
|
-F "prompt=a simple cat" \
|
|
-F "filename=test_normal" | jq '.' || echo "Normal generate test failed"
|
|
echo -e "\n"
|
|
|
|
echo "✅ Enhancement API tests completed!"
|
|
echo ""
|
|
echo "📋 Test Summary:"
|
|
echo "- Basic enhancement functionality"
|
|
echo "- Enhancement with styling options"
|
|
echo "- Multilingual support (Spanish, Chinese)"
|
|
echo "- Different image styles (photorealistic, illustration, minimalist, sticker)"
|
|
echo "- Validation error handling"
|
|
echo "- Auto-enhancement integration with generate endpoint"
|
|
echo ""
|
|
echo "💡 To run with API key, ensure GEMINI_API_KEY is set in your environment" |