← back to Watches

test-seo.sh

160 lines

#!/bin/bash

# SEO Testing Script for Omega Watch Price History
# Tests all critical SEO elements

echo "========================================"
echo "SEO AUDIT - Omega Watch Price History"
echo "========================================"
echo ""

BASE_URL="http://45.61.58.125:7600"

# Function to check HTTP response
check_url() {
    local url=$1
    local name=$2
    local response=$(curl -s -w "\n%{http_code}" "$url")
    local body=$(echo "$response" | head -n -1)
    local code=$(echo "$response" | tail -n 1)

    if [ "$code" = "200" ]; then
        echo "✓ $name: OK (200)"
        return 0
    else
        echo "✗ $name: FAILED ($code)"
        return 1
    fi
}

# Function to check for text in response
check_content() {
    local url=$1
    local pattern=$2
    local name=$3
    local content=$(curl -s "$url")

    if echo "$content" | grep -q "$pattern"; then
        echo "✓ $name: Found"
        return 0
    else
        echo "✗ $name: Not found"
        return 1
    fi
}

echo "1. BASIC CONNECTIVITY TESTS"
echo "----------------------------"
check_url "$BASE_URL/" "Homepage"
check_url "$BASE_URL/robots.txt" "Robots.txt"
check_url "$BASE_URL/sitemap.xml" "Sitemap"
check_url "$BASE_URL/api/watches" "API Watches"
check_url "$BASE_URL/api/statistics" "API Statistics"
echo ""

echo "2. META TAG TESTS"
echo "-----------------"
check_content "$BASE_URL/" "<meta name=\"description\"" "Meta Description"
check_content "$BASE_URL/" "<meta property=\"og:title\"" "Open Graph Title"
check_content "$BASE_URL/" "<meta name=\"twitter:card\"" "Twitter Card"
check_content "$BASE_URL/" "\"@context\": \"https://schema.org\"" "Structured Data"
check_content "$BASE_URL/" "<link rel=\"canonical\"" "Canonical Tag"
echo ""

echo "3. STRUCTURED DATA TESTS"
echo "------------------------"
check_content "$BASE_URL/" "\"@type\": \"Organization\"" "Organization Schema"
check_content "$BASE_URL/" "\"@type\": \"WebSite\"" "WebSite Schema"
check_content "$BASE_URL/" "\"@type\": \"Product\"" "Product Schema"
check_content "$BASE_URL/" "\"@type\": \"BreadcrumbList\"" "Breadcrumb Schema"
check_content "$BASE_URL/" "\"@type\": \"FAQPage\"" "FAQ Schema"
echo ""

echo "4. SEMANTIC HTML TESTS"
echo "----------------------"
check_content "$BASE_URL/" "<header role=\"banner\"" "Semantic Header"
check_content "$BASE_URL/" "<main id=\"main-content\" role=\"main\"" "Semantic Main"
check_content "$BASE_URL/" "<footer role=\"contentinfo\"" "Semantic Footer"
check_content "$BASE_URL/" "<nav aria-label=" "ARIA Navigation"
echo ""

echo "5. PERFORMANCE TESTS"
echo "--------------------"
check_content "$BASE_URL/" "<link rel=\"preconnect\"" "Preconnect Hint"
check_content "$BASE_URL/" "<link rel=\"dns-prefetch\"" "DNS Prefetch"

# Check response time
echo -n "Response Time: "
TIME=$(curl -o /dev/null -s -w '%{time_total}' "$BASE_URL/")
echo "${TIME}s"
if (( $(echo "$TIME < 1.0" | bc -l) )); then
    echo "✓ Response time under 1 second"
else
    echo "⚠️  Response time over 1 second"
fi
echo ""

echo "6. ROBOTS.TXT VALIDATION"
echo "------------------------"
curl -s "$BASE_URL/robots.txt" | head -10
echo ""

echo "7. SITEMAP VALIDATION"
echo "---------------------"
URLS=$(curl -s "$BASE_URL/sitemap.xml" | grep -o "<loc>.*</loc>" | wc -l)
echo "Total URLs in sitemap: $URLS"
if [ "$URLS" -gt 30 ]; then
    echo "✓ Sitemap contains adequate URLs"
else
    echo "⚠️  Sitemap may be incomplete"
fi
echo ""

echo "8. SAMPLE WATCH PAGE TEST"
echo "-------------------------"
WATCH_URL="$BASE_URL/?watch=speedmaster-moonwatch-1957"
check_url "$WATCH_URL" "Sample Watch Page"
echo ""

echo "9. API ENDPOINT TESTS"
echo "---------------------"
check_url "$BASE_URL/api/collections" "Collections API"
check_url "$BASE_URL/api/watches/trending" "Trending API"
check_url "$BASE_URL/sitemap-dynamic.xml" "Dynamic Sitemap"
echo ""

echo "10. SECURITY HEADERS TEST"
echo "-------------------------"
HEADERS=$(curl -s -I "$BASE_URL/")
if echo "$HEADERS" | grep -q "X-Content-Type-Options"; then
    echo "✓ X-Content-Type-Options header present"
else
    echo "✗ X-Content-Type-Options header missing"
fi
if echo "$HEADERS" | grep -q "X-Frame-Options"; then
    echo "✓ X-Frame-Options header present"
else
    echo "✗ X-Frame-Options header missing"
fi
echo ""

echo "========================================"
echo "SEO AUDIT COMPLETE"
echo "========================================"
echo ""
echo "Tools for Further Testing:"
echo "1. Google Rich Results Test: https://search.google.com/test/rich-results"
echo "2. Schema Validator: https://validator.schema.org/"
echo "3. Facebook Debugger: https://developers.facebook.com/tools/debug/"
echo "4. Twitter Card Validator: https://cards-dev.twitter.com/validator"
echo "5. Google PageSpeed Insights: https://pagespeed.web.dev/"
echo "6. Mobile-Friendly Test: https://search.google.com/test/mobile-friendly"
echo ""
echo "Recommended Next Actions:"
echo "1. Submit sitemap to Google Search Console"
echo "2. Submit sitemap to Bing Webmaster Tools"
echo "3. Create and upload social media images (og-image.png)"
echo "4. Set up Google Analytics"
echo "5. Monitor search rankings"
echo ""