import axios from 'axios'; const API_URL = process.env.TEST_API_URL || 'http://localhost:3200/api/geocoding/search'; const AUTO_URL = process.env.TEST_AUTO_URL || 'http://localhost:3200/api/geocoding/autocomplete'; const API_KEY = process.env.TEST_API_KEY || 'zP9vL5mK2nQ8xR7jT4wS1yB6hG3fV0cX'; const testQueries = [ "قرب مستشفى", "بجانب بنك", "مقابل جامعة", ]; async function testRelativeQueries() { console.log(`🚀 Testing Relative Queries (Search & Autocomplete)`); for (const q of testQueries) { try { // Test Search const searchRes = await axios.get(API_URL, { headers: { 'x-api-key': API_KEY }, params: { q, country: 'syria' } }); console.log(`\n🔍 Search for "${q}" -> ${searchRes.data.results?.length} results`); if (searchRes.data.results?.length > 0) { console.log(` Top result name: ${searchRes.data.results[0].name}`); console.log(` Top result name_ar: ${searchRes.data.results[0].name_ar}`); } // Test Autocomplete const autoRes = await axios.get(AUTO_URL, { headers: { 'x-api-key': API_KEY }, params: { q, country: 'syria' } }); console.log(`⚡ Autocomplete for "${q}" -> ${autoRes.data.results?.length} results`); if (autoRes.data.results?.length > 0) { console.log(` Top auto name: ${autoRes.data.results[0].name}`); } } catch (e: any) { console.log(`❌ Query "${q}" failed:`, e.response?.data || e.message); } } } testRelativeQueries().catch(console.error);