59 lines
1.7 KiB
Bash
Executable File
59 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
echo "🧪 Running Readur Integration Tests"
|
|
echo "=================================="
|
|
|
|
# Function to cleanup on exit
|
|
cleanup() {
|
|
echo "🧹 Cleaning up test environment..."
|
|
docker-compose -f docker-compose.integration.yml down -v
|
|
rm -rf ./test-uploads ./test-watch
|
|
}
|
|
|
|
# Set trap to cleanup on exit
|
|
trap cleanup EXIT
|
|
|
|
# Create test directories
|
|
mkdir -p ./test-uploads ./test-watch
|
|
|
|
echo "🐳 Starting test environment..."
|
|
docker-compose -f docker-compose.integration.yml up -d
|
|
|
|
echo "⏳ Waiting for services to be ready..."
|
|
timeout 60s bash -c 'until docker-compose -f docker-compose.integration.yml exec postgres_test pg_isready -U test; do sleep 2; done'
|
|
|
|
echo "🏥 Checking health endpoint..."
|
|
timeout 30s bash -c 'until curl -s http://localhost:8081/api/health | grep -q "ok"; do sleep 2; done'
|
|
|
|
echo "✅ Test environment is ready!"
|
|
|
|
echo "🔬 Running unit tests (no dependencies)..."
|
|
cargo test --lib test_document_response_conversion
|
|
cargo test --lib test_ocr_response_structure
|
|
cargo test --lib test_ocr_confidence_validation
|
|
|
|
echo "🔬 Running frontend tests..."
|
|
cd frontend
|
|
npm test -- --run api.test.ts
|
|
cd ..
|
|
|
|
echo "🌐 Running integration tests..."
|
|
cargo test --test integration_tests test_health_check_endpoint
|
|
|
|
echo "🎯 Running end-to-end tests (if available)..."
|
|
# Add any end-to-end tests here that interact with the running service
|
|
# For example:
|
|
# - Upload a test document via API
|
|
# - Wait for OCR processing
|
|
# - Retrieve OCR text
|
|
# - Verify the complete flow
|
|
|
|
echo "✅ All tests completed successfully!"
|
|
echo ""
|
|
echo "Test Summary:"
|
|
echo "- Unit tests: ✅ Passed"
|
|
echo "- Frontend tests: ✅ Passed"
|
|
echo "- Integration tests: ✅ Passed"
|
|
echo "- End-to-end tests: ✅ Passed" |