chore: initial checkpoint - Tesla Roadtrip planner
- Proactive Grok integration (xAI API + local CLI fallback) - Real road routing via OSRM (no more bird's-eye lines) - Heavy structured logging for fast iteration - Strong sanitization + geocoding + ErrorBoundary (no black screens) - Playwright E2E tests (API diagnostic + full UI flow) - scripts/dev.sh for one-command startup - Clean .env.example + documentation This is a stable checkpoint before further prompt/UI refinement.
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
test.describe('Grok API Diagnostic (Backend Only)', () => {
|
||||
|
||||
test('backend should successfully call xAI Grok and return a response', async ({ request }) => {
|
||||
test.setTimeout(120000); // Grok can be slow
|
||||
|
||||
const payload = {
|
||||
message: "Plan a short day trip from Milton Keynes to Telford in a Model Y. Include one Supercharger stop.",
|
||||
vehicle: { name: "Model Y Long Range", rangeKm: 514 },
|
||||
itinerary: null,
|
||||
history: []
|
||||
};
|
||||
|
||||
const response = await request.post('http://localhost:3000/api/chat', {
|
||||
data: payload,
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
|
||||
expect(response.ok()).toBeTruthy();
|
||||
|
||||
const body = await response.json();
|
||||
|
||||
console.log('[Diagnostic] Grok reply length:', body.reply?.length);
|
||||
console.log('[Diagnostic] Has itinerary update:', !!body.itinerary);
|
||||
|
||||
expect(body.reply).toBeDefined();
|
||||
expect(body.reply.length).toBeGreaterThan(50);
|
||||
|
||||
// It should NOT be the generic error message
|
||||
expect(body.reply).not.toContain('having trouble reaching Grok');
|
||||
|
||||
// If it produced an itinerary, validate basic shape
|
||||
if (body.itinerary) {
|
||||
expect(body.itinerary.days).toBeDefined();
|
||||
expect(Array.isArray(body.itinerary.days)).toBe(true);
|
||||
expect(body.itinerary.days.length).toBeGreaterThan(0);
|
||||
console.log('[Diagnostic] Itinerary days:', body.itinerary.days.length);
|
||||
}
|
||||
|
||||
console.log('✅ Backend successfully called real Grok!');
|
||||
});
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user