#!/usr/bin/env nu # Test navigation sequence between two routes # # Usage: nu test-navigation-sequence.nu # Example: nu test-navigation-sequence.nu / /services def main [from_path: string = "/", to_path: string = "/services"] { let base_url = $env.BASE_URL? | default "http://localhost:3030" print $"🧭 Testing navigation sequence: ($from_path) → ($to_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 navigation sequence print "🔍 Testing navigation transition..." let request_body = { from: $from_path, to: $to_path } let response = try { http post $"($base_url)/api/nav-test/navigate" $request_body } catch { |e| print $"❌ Navigation test failed: ($e.msg)" exit 1 } print "✅ Navigation test successful" # Display navigation information print "📊 Navigation Information:" print $" From: ($response.from) → ($response.to)" print $" Transition: ($response.transition)" print $" From Component: ($response.from_component | default 'None')" print $" To Component: ($response.to_component | default 'None')" print $" Language: ($response.language)" print $" Valid: ($response.valid)" # Show warnings if any if ($response.warnings | length) > 0 { print $" Warnings: ($response.warnings | str join ', ')" } # Check if navigation is valid if not $response.valid { print "⚠️ Warning: Navigation target is not valid" exit 1 } # Check for warnings if ($response.warnings | length) > 0 { print "⚠️ Navigation completed with warnings" } print "🎉 Navigation sequence test completed successfully" }