import axios from 'axios'; const API_URL = process.env.TEST_API_URL || 'http://localhost:3200/api/geocoding/autocomplete'; const API_KEY = process.env.TEST_API_KEY || 'zP9vL5mK2nQ8xR7jT4wS1yB6hG3fV0cX'; const testQueries = [ "مستش", "شارع ال", "جامعة", "بنك ا", "صيد" ]; async function testAutocomplete() { console.log(`🚀 Testing Autocomplete Latency`); for (const q of testQueries) { const start = Date.now(); try { const res = await axios.get(API_URL, { headers: { 'x-api-key': API_KEY }, params: { q, country: 'syria' } }); const time = Date.now() - start; const count = res.data.results?.length || 0; console.log(`✅ [${time}ms] Query: "${q}" -> ${count} results`); if (count > 0) { console.log(` First result: ${res.data.results[0].name} (${res.data.results[0].category})`); } } catch (e: any) { console.log(`❌ Query: "${q}" failed:`, e.message); } } } testAutocomplete().catch(console.error);