website-htmx-rustelo-code/scripts/nav-test/test-single-route.nu

58 lines
1.9 KiB
Text
Raw Normal View History

2026-07-10 03:44:13 +01:00
#!/usr/bin/env nu
# Test single route navigation
#
# Usage: nu test-single-route.nu <path>
# Example: nu test-single-route.nu /services
def main [route_path: string = "/"] {
let base_url = $env.BASE_URL? | default "http://localhost:3030"
print $"🧭 Testing navigation to: ($route_path)"
print $"🌐 Base URL: ($base_url)"
# 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 route resolution
print "🔍 Testing route resolution..."
let response = try {
http get $"($base_url)/api/nav-test/resolve?path=($route_path)"
} catch { |e|
print $"❌ Route test failed: ($e.msg)"
exit 1
}
print "✅ Route test successful"
# Display route information
print "📊 Route Information:"
print $" Path: ($response.path)"
print $" Component: ($response.component | default 'None')"
print $" Language: ($response.language)"
print $" Valid: ($response.valid)"
print $" Resolution Time: ($response.resolution_time_ms)ms"
if ($response.metadata | is-not-empty) {
print " Metadata:"
print $" Title Key: ($response.metadata.title_key | default 'None')"
print $" Description Key: ($response.metadata.description_key | default 'None')"
print $" Is Multilingual: ($response.metadata.is_multilingual)"
if ($response.metadata.parameters | is-not-empty) {
print $" Parameters: ($response.metadata.parameters | to json)"
}
}
# Check if route is valid
if not $response.valid {
print "⚠️ Warning: Route is not valid"
exit 1
}
print "🎉 Navigation test completed successfully"
}