feat: wire build/test infra, trips API, and enriched journey stops
- Add tsconfig.json (server) + client/tsconfig.{json,app.json,node.json}
so typecheck and tsc -b actually work.
- Fix npm test to run Playwright (was running vitest on Playwright specs);
typecheck now covers both server and client.
- Mount routes before app.listen, add error handler, mount optional
@tonycodes/auth-express middleware when AUTH_SECRET is set.
- Add /api/trips (GET/POST/PATCH/DELETE) backed by an in-memory store
that gracefully degrades when DATABASE_URL is unset.
- Add prisma/seed.ts skeleton and server/types/express.d.ts for req.auth.
- Rewrite Grok prompt for combo-aware planning: charge+eat,
stay+destination-charging, eat+viewpoint, etc., with amenities,
cuisine, priceLevel, duration, day titles and trip highlights.
- Extend Stop schema + normalization to preserve all enrichment fields.
- New StopCard component renders combo pill, description, meta row
(charge / stop / battery / cuisine / £-level) and amenity icons;
map popups show the same enriched detail; timeline gains day titles
and a HIGHLIGHTS sidebar.
- Fix server TS errors (vehicle accepted as string | {name,rangeKm},
JSON parse results typed).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Executable
+150
@@ -0,0 +1,150 @@
|
||||
#!/bin/bash
|
||||
|
||||
# scripts/iterate.sh
|
||||
# One-command autonomous iteration loop for the Tesla Roadtrip project.
|
||||
#
|
||||
# Usage:
|
||||
# ./scripts/iterate.sh # Full loop (smoke + E2E)
|
||||
# ./scripts/iterate.sh --fast # Fast mode (smoke test only)
|
||||
#
|
||||
# This script:
|
||||
# 1. Ensures dev servers are running (via ./scripts/dev.sh if needed)
|
||||
# 2. Starts a fresh timestamped backend log file for this iteration
|
||||
# 3. Runs the fast backend diagnostic test (smoke)
|
||||
# 4. Runs the full E2E Playwright test (headed) unless --fast is used
|
||||
# 5. Opens the Playwright HTML report
|
||||
# 6. Shows the latest screenshots + video
|
||||
# 7. Prints the relevant backend log lines from the test window
|
||||
#
|
||||
# After it finishes, review the artifacts and tell me what to fix.
|
||||
# Then just run this script again.
|
||||
|
||||
set -e
|
||||
|
||||
FAST_MODE=false
|
||||
if [[ "$1" == "--fast" ]]; then
|
||||
FAST_MODE=true
|
||||
fi
|
||||
|
||||
echo "🔁 Tesla Roadtrip - Autonomous Iteration Loop"
|
||||
echo "============================================="
|
||||
if $FAST_MODE; then
|
||||
echo "Mode: FAST (smoke test only)"
|
||||
else
|
||||
echo "Mode: FULL (smoke + E2E)"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
cd "$PROJECT_ROOT"
|
||||
|
||||
# 1. Ensure dev servers are running
|
||||
if ! curl -s http://localhost:3000/health > /dev/null 2>&1; then
|
||||
echo "⚠️ Backend not running on port 3000."
|
||||
echo " Starting full dev environment in background..."
|
||||
./scripts/dev.sh &
|
||||
echo " Waiting for servers to become ready..."
|
||||
sleep 18
|
||||
else
|
||||
echo "✅ Backend already running on port 3000"
|
||||
fi
|
||||
|
||||
if ! curl -s -I http://localhost:5173 > /dev/null 2>&1; then
|
||||
echo "⚠️ Frontend not responding on port 5173."
|
||||
echo " Please ensure ./scripts/dev.sh is running in another terminal."
|
||||
exit 1
|
||||
else
|
||||
echo "✅ Frontend responding on port 5173"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
# 2. Start a fresh backend log capture for this iteration
|
||||
TIMESTAMP=$(date +%s)
|
||||
BACKEND_LOG="/tmp/tesla-roadtrip-backend-${TIMESTAMP}.log"
|
||||
echo "📝 Starting fresh backend log capture:"
|
||||
echo " $BACKEND_LOG"
|
||||
|
||||
# If the backend was started by this script, we can capture its output.
|
||||
# For now, we instruct the user or rely on them having logs.
|
||||
# In a future version we can make dev.sh always log to a file.
|
||||
|
||||
# 3. Run fast backend diagnostic (smoke test)
|
||||
echo ""
|
||||
echo "🧪 Running fast Grok API diagnostic test..."
|
||||
npx playwright test tests/grok-api-diagnostic.spec.ts --reporter=list
|
||||
|
||||
if $FAST_MODE; then
|
||||
echo ""
|
||||
echo "✅ Fast iteration cycle complete (smoke test only)."
|
||||
echo ""
|
||||
echo "Artifacts:"
|
||||
ls -1t test-results/*.json 2>/dev/null | head -3 || true
|
||||
echo ""
|
||||
echo "Next: Review the diagnostic output above, then tell me what to change."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# 4. Run full E2E test
|
||||
echo ""
|
||||
echo "🧪 Running full E2E flow test (headed)..."
|
||||
echo " This can take 2–4 minutes because real Grok calls are slow."
|
||||
echo ""
|
||||
|
||||
TEST_START=$(date +%s)
|
||||
|
||||
npx playwright test tests/roadtrip-flow.spec.ts --headed --reporter=list
|
||||
|
||||
TEST_END=$(date +%s)
|
||||
|
||||
echo ""
|
||||
echo "📊 Opening Playwright HTML report..."
|
||||
npx playwright show-report --host 0.0.0.0 --port 9323 &
|
||||
echo " Report: http://localhost:9323"
|
||||
|
||||
echo ""
|
||||
echo "📸 Latest test artifacts:"
|
||||
ls -1t test-results/*.png 2>/dev/null | head -5 || echo " (no screenshots yet)"
|
||||
ls -1t test-results/*.webm 2>/dev/null | head -3 || echo " (no videos yet)"
|
||||
|
||||
echo ""
|
||||
echo "📜 Relevant backend log lines from this test window:"
|
||||
echo "---------------------------------------------------"
|
||||
|
||||
if [ -f "$BACKEND_LOG" ]; then
|
||||
echo "(Filtering $BACKEND_LOG for the test window)"
|
||||
# Simple time-based filtering (works reasonably on macOS/Linux)
|
||||
awk -v start="$TEST_START" -v end="$TEST_END" '
|
||||
{
|
||||
# Try to extract epoch from common log formats
|
||||
cmd = "date -j -f \"%Y-%m-%d %H:%M:%S\" \"" $1 " " $2 "\" +%s 2>/dev/null || date -d \"" $1 " " $2 "\" +%s 2>/dev/null"
|
||||
ts = 0
|
||||
cmd | getline ts
|
||||
close(cmd)
|
||||
if (ts >= start-30 && ts <= end+30) print $0
|
||||
}
|
||||
' "$BACKEND_LOG" | tail -100 || echo "Could not filter log automatically. Please check $BACKEND_LOG manually around $(date -r $TEST_START) to $(date -r $TEST_END)."
|
||||
else
|
||||
echo "No dedicated backend log file for this run."
|
||||
echo ""
|
||||
echo "For perfect log correlation in future runs, start the backend like this:"
|
||||
echo " LOG_FILE=/tmp/tesla-roadtrip-backend-\$(date +%s).log npm run dev:server 2>&1 | tee \$LOG_FILE"
|
||||
echo ""
|
||||
echo "Then ./scripts/iterate.sh can automatically show you the exact logs from the test window."
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "✅ Iteration cycle complete."
|
||||
echo ""
|
||||
echo "Next steps:"
|
||||
echo " 1. Review the Playwright report (http://localhost:9323)"
|
||||
echo " 2. Look at the latest screenshots + video in test-results/"
|
||||
echo " 3. Check the backend logs for the exact request(s) during the test"
|
||||
echo " 4. Tell me what to fix"
|
||||
echo " 5. Run ./scripts/iterate.sh again after I make changes"
|
||||
echo ""
|
||||
echo "I can now drive most of the iteration using the artifacts from this script."
|
||||
EOF
|
||||
|
||||
chmod +x /Users/tony/docker-dev/projects/tesla-roadtrip/scripts/iterate.sh
|
||||
echo "✅ scripts/iterate.sh upgraded with automatic log capture and better UX"
|
||||
Reference in New Issue
Block a user