#!/usr/bin/env nu # Run complete navigation test suite # # Usage: nu full-test-suite.nu def main [] { let base_url = $env.BASE_URL? | default "http://localhost:3030" let script_dir = $env.FILE_PWD print "๐Ÿงญ Running complete navigation test suite..." print $"๐ŸŒ Base URL: ($base_url)" print "" # Check if server is running let health_check = try { http get $"($base_url)/health" } catch { null } if ($health_check | is-empty) { print "โŒ Server not running at ($base_url)" print "๐Ÿ’ก Start server with: just dev::with-nav-test" exit 1 } # Test tracking mut tests_passed = 0 mut tests_failed = 0 mut total_tests = 0 # Function to run test and track results def run_test [test_name: string, test_command: closure] { print $"๐Ÿงช Running: ($test_name)" $total_tests += 1 let result = try { do $test_command true } catch { false } if $result { $tests_passed += 1 print $"โœ… PASSED: ($test_name)" } else { $tests_failed += 1 print $"โŒ FAILED: ($test_name)" } print "" } # 1. Validate all routes first run_test "Route Validation" { nu ($script_dir + "/validate-all-routes.nu") } # 2. Test individual route resolution print "๐Ÿ“‹ Testing individual routes..." run_test "Home Route (/)" { nu ($script_dir + "/test-single-route.nu") "/" } run_test "Services Route (/services)" { nu ($script_dir + "/test-single-route.nu") "/services" } # Check if Spanish routes exist let spanish_check = try { let resp = http get $"($base_url)/api/nav-test/resolve?path=/es" $resp.valid } catch { false } if $spanish_check { run_test "Spanish Home (/es)" { nu ($script_dir + "/test-single-route.nu") "/es" } run_test "Spanish Contact (/es/contactar)" { nu ($script_dir + "/test-single-route.nu") "/es/contactar" } } # 3. Test navigation sequences print "๐Ÿ“‹ Testing navigation sequences..." run_test "Home to Services" { nu ($script_dir + "/test-navigation-sequence.nu") "/" "/services" } run_test "Services to Contact" { nu ($script_dir + "/test-navigation-sequence.nu") "/services" "/contact" } # Test cross-language navigation if Spanish routes exist if $spanish_check { run_test "English to Spanish" { nu ($script_dir + "/test-navigation-sequence.nu") "/" "/es" } } # 4. Performance benchmarks print "๐Ÿ“‹ Running performance benchmarks..." run_test "Home Route Benchmark" { nu ($script_dir + "/benchmark-route.nu") "/" 100 } let services_check = try { let resp = http get $"($base_url)/api/nav-test/resolve?path=/services" $resp.valid } catch { false } if $services_check { run_test "Services Route Benchmark" { nu ($script_dir + "/benchmark-route.nu") "/services" 100 } } # 5. Final summary print "================================" print "๐Ÿงญ Navigation Test Suite Results" print "================================" print $"Total Tests: ($total_tests)" print $"Passed: ($tests_passed)" print $"Failed: ($tests_failed)" if $tests_failed == 0 { print "๐ŸŽ‰ All tests passed!" exit 0 } else { print $"โŒ ($tests_failed) tests failed" print "" print "๐Ÿ’ก Check individual test output above for details" print "๐Ÿ’ก Verify your route configuration in site/config/routes/" exit 1 } }