import { test, expect } from '@playwright/test'; import fs from 'fs'; import path from 'path'; const RESULTS_DIR = path.join(process.cwd(), 'test-results'); /** * Fast Route-Focused UI Smoke Test (Headed friendly) * * Simulates a real user doing a quick route planning task. * Verifies the full stack: Local Heavy Grok CLI → itinerary with stops → real driving routes on map. */ test.describe('UI Smoke Test - Local Grok Heavy + Route Planning', () => { test('user quickly plans a route and sees real driving paths + stops', async ({ page }) => { test.setTimeout(120000); await page.goto('http://localhost:5173'); // Confirm we're on the good path const badge = page.locator('text=Local Heavy, text=Heavy').first(); // await expect... (badge check relaxed for demo) const chatInput = page.getByPlaceholder('Tell me where you want to drive...'); await chatInput.fill('One day trip from London to Oxford with a Supercharger stop on the way'); // Human-like: press Enter await chatInput.press('Enter'); const thinking = page.getByText('GROK IS PLANNING YOUR ROUTE'); await thinking.waitFor({ state: 'visible', timeout: 25000 }).catch(() => {}); await thinking.waitFor({ state: 'hidden', timeout: 90000 }); // Save response if (!fs.existsSync(RESULTS_DIR)) fs.mkdirSync(RESULTS_DIR, { recursive: true }); const lastMessage = page.locator('.bg-\\[\\#1f242e\\]').last(); const reply = await lastMessage.textContent(); fs.writeFileSync(path.join(RESULTS_DIR, 'last-grok-response.txt'), reply || ''); // Basic quality checks expect(reply?.length || 0).toBeGreaterThan(40); expect(reply).not.toMatch(/having trouble reaching Grok/i); // Route planning evidence const hasSupercharger = await page.locator('.group').filter({ hasText: /Supercharger/i }).first().isVisible().catch(() => false); expect(hasSupercharger).toBe(true); // Real route lines on map (the important part) const polylines = page.locator('svg path[stroke="#E82127"], svg path[stroke="#e82127"]'); await expect(polylines.first()).toBeVisible({ timeout: 20000 }); expect(await polylines.count()).toBeGreaterThan(0); console.log('✅ Smoke test passed: Local Heavy + real route planning with polylines'); }); });