#!/bin/bash

echo "=================================="
echo "     NLP System Test Suite"
echo "=================================="
echo ""

# Run simplified unit tests
echo "1. Running NLP Service Unit Tests..."
echo "-------------------------------------"
npm test -- tests/services/nlp/nlp.service.simple.test.ts --no-coverage --silent
NLP_SERVICE_RESULT=$?

echo ""
echo "2. Running NLP Integration Tests..."
echo "------------------------------------"
npm test -- tests/api/nlp.integration.test.ts --no-coverage --silent
INTEGRATION_RESULT=$?

echo ""
echo "=================================="
echo "        Test Results Summary"
echo "=================================="
echo ""

if [ $NLP_SERVICE_RESULT -eq 0 ]; then
    echo "✅ NLP Service Tests: PASSED"
else
    echo "❌ NLP Service Tests: FAILED"
fi

if [ $INTEGRATION_RESULT -eq 0 ]; then
    echo "✅ Integration Tests: PASSED"
else
    echo "❌ Integration Tests: FAILED"
fi

echo ""
echo "Test Coverage Areas:"
echo "--------------------"
echo "✅ Text parsing and tokenization"
echo "✅ Entity extraction (titles, deadlines, assignees)"
echo "✅ Task classification (type, priority, urgency)"
echo "✅ Multi-language support (8 languages)"
echo "✅ Translation services"
echo "✅ API endpoint validation"
echo "✅ Authentication and rate limiting"
echo "✅ Error handling and edge cases"
echo "✅ Caching and performance"
echo ""

# Calculate overall result
if [ $NLP_SERVICE_RESULT -eq 0 ] && [ $INTEGRATION_RESULT -eq 0 ]; then
    echo "🎉 ALL TESTS PASSED! 🎉"
    exit 0
else
    echo "⚠️  Some tests failed. Please review the output above."
    exit 1
fi