#!/bin/bash # WCAG 2.1 AA Accessibility Test Suite for CodePress CMS # Tests for web accessibility compliance BASE_URL="http://development.codepress.noorlander.info" TOTAL_TESTS=0 PASSED_TESTS=0 FAILED_TESTS=0 WARNINGS=0 # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' # No Color echo -e "${BLUE}========================================${NC}" echo -e "${BLUE}WCAG 2.1 AA ACCESSIBILITY TESTS${NC}" echo -e "${BLUE}Target: $BASE_URL${NC}" echo -e "${BLUE}========================================${NC}" # Function to run a test with minimum expected value run_test_min() { local test_name="$1" local test_command="$2" local min_expected="$3" echo -n "Testing: $test_name... " result=$(eval "$test_command" 2>/dev/null) if [ "$result" -ge "$min_expected" ] 2>/dev/null; then echo -e "${GREEN}[PASS]${NC} ✅ (got: $result, min: $min_expected)" ((PASSED_TESTS++)) else echo -e "${RED}[FAIL]${NC} ❌ (got: $result, expected min: $min_expected)" ((FAILED_TESTS++)) fi ((TOTAL_TESTS++)) } # Function to run a test with exact expected value run_test() { local test_name="$1" local test_command="$2" local expected="$3" echo -n "Testing: $test_name... " result=$(eval "$test_command" 2>/dev/null) if [ "$result" = "$expected" ]; then echo -e "${GREEN}[PASS]${NC} ✅" ((PASSED_TESTS++)) else echo -e "${RED}[FAIL]${NC} ❌ (expected: $expected, got: $result)" ((FAILED_TESTS++)) fi ((TOTAL_TESTS++)) } # Function to run a test with maximum expected value run_test_max() { local test_name="$1" local test_command="$2" local max_expected="$3" echo -n "Testing: $test_name... " result=$(eval "$test_command" 2>/dev/null) if [ "$result" -le "$max_expected" ] 2>/dev/null; then echo -e "${GREEN}[PASS]${NC} ✅ (got: $result, max: $max_expected)" ((PASSED_TESTS++)) else echo -e "${RED}[FAIL]${NC} ❌ (got: $result, expected max: $max_expected)" ((FAILED_TESTS++)) fi ((TOTAL_TESTS++)) } echo "" echo -e "${BLUE}1. PERCEIVABLE (Information must be presentable in ways users can perceive)${NC}" echo "" # Test 1.1 - Text alternatives run_test_min "Alt text for images" "curl -s '$BASE_URL/' | grep -cE 'alt='" "1" run_test_min "Semantic HTML structure" "curl -s '$BASE_URL/' | grep -cE ']*>'" "1" run_test_min "List markup usage" "curl -s '$BASE_URL/' | grep -cE ''" "1" # Test 1.4 - Distinguishable content run_test_min "Color contrast (basic check)" "curl -s '$BASE_URL/' | grep -cE 'color:|background:'" "1" run_test "Text resize capability" "curl -s '$BASE_URL/' | grep -c 'viewport'" "1" echo "" echo -e "${BLUE}2. OPERABLE (Interface components must be operable)${NC}" echo "" # Test 2.1 - Keyboard accessible run_test "No auto-focus without tabindex" "curl -s '$BASE_URL/' | grep -c 'autofocus'" "0" run_test_min "Focus indicators" "curl -s '$BASE_URL/' | grep -c ':focus\|outline'" "1" # Test 2.2 - Enough time run_test "No auto-updating content" "curl -s '$BASE_URL/' | grep -cE ''" "1" echo "" echo -e "${BLUE}3. UNDERSTANDABLE (Information and UI operation must be understandable)${NC}" echo "" # Test 3.1 - Readable run_test_min "Language attribute" "curl -s '$BASE_URL/' | grep -c 'lang='" "1" run_test "No invalid dir attribute" "curl -s '$BASE_URL/' | grep -c 'dir=' | head -1" "0" # Test 3.2 - Predictable run_test_min "Consistent navigation" "curl -s '$BASE_URL/' | grep -cE 'nav|navigation'" "1" # Test 3.3 - Input assistance run_test_min "Form labels" "curl -s '$BASE_URL/' | grep -cE '