use locat and navigate react odm router issue final fix
This commit is contained in:
139
test-uselocation-error.sh
Normal file
139
test-uselocation-error.sh
Normal file
@@ -0,0 +1,139 @@
|
||||
#!/bin/bash
|
||||
# Script to reproduce useLocation() error on demand
|
||||
# Run this to trigger conditions that cause the error
|
||||
# If error appears = bug exists, If no error = bug is fixed
|
||||
|
||||
set -e
|
||||
|
||||
echo "=========================================="
|
||||
echo "useLocation() Error Reproduction Script"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
echo "This script will trigger conditions known to cause:"
|
||||
echo "'useLocation() may be used only in the context of a <Router> component'"
|
||||
echo ""
|
||||
|
||||
# Function to check if error appears in browser console
|
||||
function wait_for_check() {
|
||||
echo ""
|
||||
echo "⚠️ NOW CHECK YOUR BROWSER:"
|
||||
echo " 1. Open: https://app.igny8.com/writer/tasks"
|
||||
echo " 2. Open Developer Console (F12)"
|
||||
echo " 3. Look for: 'useLocation() may be used only in the context of a <Router> component'"
|
||||
echo ""
|
||||
echo " ✅ NO ERROR = Bug is FIXED"
|
||||
echo " ❌ ERROR APPEARS = Bug still EXISTS"
|
||||
echo ""
|
||||
read -p "Press Enter after checking..."
|
||||
}
|
||||
|
||||
# Test 1: Clear Vite cache and restart frontend
|
||||
function test1_clear_cache_restart() {
|
||||
echo ""
|
||||
echo "=========================================="
|
||||
echo "TEST 1: Clear Vite Cache + Restart Frontend"
|
||||
echo "=========================================="
|
||||
echo "This simulates container operation that wipes cache..."
|
||||
|
||||
echo "Clearing Vite cache..."
|
||||
docker compose exec igny8_frontend rm -rf /app/node_modules/.vite || true
|
||||
|
||||
echo "Restarting frontend container..."
|
||||
docker compose restart igny8_frontend
|
||||
|
||||
echo "Waiting for frontend to start (30 seconds)..."
|
||||
sleep 30
|
||||
|
||||
wait_for_check
|
||||
}
|
||||
|
||||
# Test 2: Just restart frontend (no cache clear)
|
||||
function test2_restart_only() {
|
||||
echo ""
|
||||
echo "=========================================="
|
||||
echo "TEST 2: Restart Frontend Only (No Cache Clear)"
|
||||
echo "=========================================="
|
||||
|
||||
echo "Restarting frontend container..."
|
||||
docker compose restart igny8_frontend
|
||||
|
||||
echo "Waiting for frontend to start (30 seconds)..."
|
||||
sleep 30
|
||||
|
||||
wait_for_check
|
||||
}
|
||||
|
||||
# Test 3: Clear cache without restart
|
||||
function test3_cache_only() {
|
||||
echo ""
|
||||
echo "=========================================="
|
||||
echo "TEST 3: Clear Vite Cache Only (No Restart)"
|
||||
echo "=========================================="
|
||||
echo "Checking if HMR triggers the error..."
|
||||
|
||||
echo "Clearing Vite cache..."
|
||||
docker compose exec igny8_frontend rm -rf /app/node_modules/.vite
|
||||
|
||||
echo "Waiting for HMR rebuild (20 seconds)..."
|
||||
sleep 20
|
||||
|
||||
wait_for_check
|
||||
}
|
||||
|
||||
# Test 4: Multiple rapid restarts
|
||||
function test4_rapid_restarts() {
|
||||
echo ""
|
||||
echo "=========================================="
|
||||
echo "TEST 4: Rapid Container Restarts (Stress Test)"
|
||||
echo "=========================================="
|
||||
echo "This simulates multiple deployment cycles..."
|
||||
|
||||
for i in {1..3}; do
|
||||
echo "Restart $i/3..."
|
||||
docker compose restart igny8_frontend
|
||||
sleep 10
|
||||
done
|
||||
|
||||
echo "Waiting for final startup (30 seconds)..."
|
||||
sleep 30
|
||||
|
||||
wait_for_check
|
||||
}
|
||||
|
||||
# Main menu
|
||||
echo "Select test to run:"
|
||||
echo "1) Clear cache + restart (most likely to trigger bug)"
|
||||
echo "2) Restart only"
|
||||
echo "3) Clear cache only (HMR test)"
|
||||
echo "4) Rapid restarts (stress test)"
|
||||
echo "5) Run all tests"
|
||||
echo "q) Quit"
|
||||
echo ""
|
||||
read -p "Enter choice: " choice
|
||||
|
||||
case $choice in
|
||||
1) test1_clear_cache_restart ;;
|
||||
2) test2_restart_only ;;
|
||||
3) test3_cache_only ;;
|
||||
4) test4_rapid_restarts ;;
|
||||
5)
|
||||
test1_clear_cache_restart
|
||||
test2_restart_only
|
||||
test3_cache_only
|
||||
test4_rapid_restarts
|
||||
;;
|
||||
q) exit 0 ;;
|
||||
*) echo "Invalid choice"; exit 1 ;;
|
||||
esac
|
||||
|
||||
echo ""
|
||||
echo "=========================================="
|
||||
echo "Testing Complete"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
echo "If you saw the useLocation() error:"
|
||||
echo " → Bug still exists, needs investigation"
|
||||
echo ""
|
||||
echo "If NO error appeared in any test:"
|
||||
echo " → Bug is FIXED! ✅"
|
||||
echo ""
|
||||
Reference in New Issue
Block a user