#!/bin/bash

# Test script to verify the "years of experience" styling matches the original design

echo "🧪 Testing Years of Experience Styling"
echo "========================================"

# Colors for output
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m' # No Color

# Test counter
PASSED=0
FAILED=0

# Test 1: Check CSS file contains correct styles
echo -n "1. CSS contains correct font-size (0.85em)... "
if grep -q "font-size: 0.85em;" /Users/txeo/Git/yo/cv/static/css/main.css; then
    echo -e "${GREEN}✓ PASS${NC}"
    ((PASSED++))
else
    echo -e "${RED}✗ FAIL${NC}"
    ((FAILED++))
fi

# Test 2: Check font-weight
echo -n "2. CSS contains correct font-weight (400)... "
if grep -A 6 ".years-experience" /Users/txeo/Git/yo/cv/static/css/main.css | grep -q "font-weight: 400;"; then
    echo -e "${GREEN}✓ PASS${NC}"
    ((PASSED++))
else
    echo -e "${RED}✗ FAIL${NC}"
    ((FAILED++))
fi

# Test 3: Check color
echo -n "3. CSS contains correct color (#666)... "
if grep -A 6 ".years-experience" /Users/txeo/Git/yo/cv/static/css/main.css | grep -q "color: #666;"; then
    echo -e "${GREEN}✓ PASS${NC}"
    ((PASSED++))
else
    echo -e "${RED}✗ FAIL${NC}"
    ((FAILED++))
fi

# Test 4: Check margin
echo -n "4. CSS contains minimal top margin (4px 0 0 0)... "
if grep -A 6 ".years-experience" /Users/txeo/Git/yo/cv/static/css/main.css | grep -q "margin: 4px 0 0 0;"; then
    echo -e "${GREEN}✓ PASS${NC}"
    ((PASSED++))
else
    echo -e "${RED}✗ FAIL${NC}"
    ((FAILED++))
fi

# Test 5: Check English version renders
echo -n "5. English version renders correctly... "
if curl -s "http://localhost:1999/?lang=en" | grep -q "20 years of experience"; then
    echo -e "${GREEN}✓ PASS${NC}"
    ((PASSED++))
else
    echo -e "${RED}✗ FAIL${NC}"
    ((FAILED++))
fi

# Test 6: Check Spanish version renders
echo -n "6. Spanish version renders correctly... "
if curl -s "http://localhost:1999/?lang=es" | grep -q "20 años de experiencia"; then
    echo -e "${GREEN}✓ PASS${NC}"
    ((PASSED++))
else
    echo -e "${RED}✗ FAIL${NC}"
    ((FAILED++))
fi

# Test 7: Check short version
echo -n "7. Short CV version includes years text... "
if curl -s "http://localhost:1999/?lang=en&version=short" | grep -q "years-experience"; then
    echo -e "${GREEN}✓ PASS${NC}"
    ((PASSED++))
else
    echo -e "${RED}✗ FAIL${NC}"
    ((FAILED++))
fi

# Test 8: Check long version
echo -n "8. Long CV version includes years text... "
if curl -s "http://localhost:1999/?lang=en&version=long" | grep -q "years-experience"; then
    echo -e "${GREEN}✓ PASS${NC}"
    ((PASSED++))
else
    echo -e "${RED}✗ FAIL${NC}"
    ((FAILED++))
fi

# Summary
echo ""
echo "========================================"
echo "Test Results: ${PASSED} passed, ${FAILED} failed"
if [ $FAILED -eq 0 ]; then
    echo -e "${GREEN}✅ All tests passed!${NC}"
    exit 0
else
    echo -e "${RED}❌ Some tests failed${NC}"
    exit 1
fi
