#!/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"