version: 1
kind: action
name: Test
description: Comprehensive testing execution with detailed analysis and reporting
prompt: |
  Execute comprehensive testing with detailed analysis and quality validation.
  Run complete test suites including unit, integration, and end-to-end tests.
  Ensure proper environment setup and failure analysis.
  Provide detailed reporting for continuous improvement and team visibility.
enhanced-prompt: |-
  # 🧪 Testing Workflow

  ## Environment Setup
  ```bash
  # Check test environment
  [ -f "package.json" ] || { echo "❌ No package.json"; exit 1; }

  # Install dependencies
  npm ci || npm install

  # Check test configuration
  [ -f "jest.config.js" ] && echo "✅ Jest config found" || echo "⚠️ No Jest config"
  ```

  ## Test Execution
  ```bash
  # Run unit tests
  echo "🧪 Running unit tests..."
  npm run test:unit 2>/dev/null || npm test

  # Run smoke tests
  echo "💨 Running smoke tests..."
  npm run test:smoke 2>/dev/null || echo "⚠️ No smoke tests"
  ```

  ## Coverage Analysis
  ```bash
  # Generate coverage report
  npm run test:coverage 2>/dev/null || npm test -- --coverage

  # Check coverage threshold
  COVERAGE=$(grep -o '"lines":{"pct":[0-9.]*' coverage/coverage-summary.json 2>/dev/null | cut -d: -f3 || echo "0")

  if [ $(echo "$COVERAGE >= 80" | bc -l 2>/dev/null || echo "0") -eq 1 ]; then
    echo "✅ Coverage: ${COVERAGE}% (meets 80% threshold)"
  else
    echo "⚠️ Coverage: ${COVERAGE}% (below 80% threshold)"
  fi
  ```

  ## Results Analysis
  ```bash
  # Test summary
  echo "📊 Test Results Summary:"
  echo "- Unit tests: $(npm test 2>&1 | grep -o '[0-9]* passing' || echo 'Unknown')"
  echo "- Coverage: ${COVERAGE}%"
  echo "- Status: $([ $? -eq 0 ] && echo '✅ All tests passed' || echo '❌ Some tests failed')"
  ```

  **🎯 Result:** Comprehensive test validation with quality metrics and detailed reporting
