| 1 | // Test script to verify map data integration |
| 2 | const testMapData = async () => { |
| 3 | try { |
| 4 | console.log("🧪 Testing Map Data Integration...") |
| 5 | |
| 6 | // Test live data API |
| 7 | const response = await fetch("http://localhost:3000/api/social/live-data?limit=10&confidence=0.5") |
| 8 | const data = await response.json() |
| 9 | |
| 10 | console.log("✅ Live Data API Response:") |
| 11 | console.log("- Success:", data.success) |
| 12 | console.log("- Data Count:", data.data?.length || 0) |
| 13 | console.log("- Source:", data.source) |
| 14 | console.log("- Stats:", data.stats) |
| 15 | |
| 16 | if (data.data && data.data.length > 0) { |
| 17 | console.log("\n📍 Sample Report:") |
| 18 | const sample = data.data[0] |
| 19 | console.log("- ID:", sample.id) |
| 20 | console.log("- Title:", sample.title) |
| 21 | console.log("- Type:", sample.type) |
| 22 | console.log("- Severity:", sample.severity) |
| 23 | console.log("- Location:", sample.location) |
| 24 | console.log("- Geo-fencing:", sample.geoFencing) |
| 25 | console.log("- Social Media Data:", sample.socialMediaData) |
| 26 | } |
| 27 | |
| 28 | // Test social extraction API |
| 29 | console.log("\n🔍 Testing Social Extraction API...") |
| 30 | const extractResponse = await fetch("http://localhost:3000/api/social/extract", { |
| 31 | method: "POST", |
| 32 | headers: { "Content-Type": "application/json" }, |
| 33 | body: JSON.stringify({ |
| 34 | keywords: ["tsunami", "cyclone", "flooding"], |
| 35 | platforms: ["all"] |
| 36 | }) |
| 37 | }) |
| 38 | |
| 39 | const extractData = await extractResponse.json() |
| 40 | console.log("✅ Social Extraction Response:") |
| 41 | console.log("- Success:", extractData.success) |
| 42 | console.log("- Posts Count:", extractData.extracted_posts?.length || 0) |
| 43 | console.log("- Processing Time:", extractData.processing_time) |
| 44 | |
| 45 | console.log("\n🎉 Map data integration test completed!") |
| 46 | |
| 47 | } catch (error) { |
| 48 | console.error("❌ Test failed:", error.message) |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | // Run the test |
| 53 | testMapData() |