#!/usr/bin/env node /** * Dashboard Data Verification - Check if real learning data is displayed */ const baseUrl = 'http://localhost:9001'; async function verifyDashboardData() { console.log('šŸ” Dashboard Data Verification Test\n'); try { // 1. Test AI Learning Status API (the one fixed) console.log('šŸ“Š AI Learning Status API:'); const aiLearningResponse = await fetch(`${baseUrl}/api/ai-learning-status`); const aiLearningData = await aiLearningResponse.json(); if (aiLearningData.success) { console.log(` āœ… API Working: ${aiLearningData.success}`); console.log(` šŸ“ˆ Total Analyses: ${aiLearningData.data.totalAnalyses}`); console.log(` šŸŽÆ Total Decisions: ${aiLearningData.data.totalDecisions}`); console.log(` 🧠 Learning Phase: ${aiLearningData.data.phase}`); console.log(` šŸ’Ŗ AI Confidence: ${aiLearningData.data.confidenceLevel}%`); console.log(` šŸ’” Recommendation: ${aiLearningData.data.recommendation}`); // This should show REAL data now, not mock data if (aiLearningData.data.totalAnalyses > 9000) { console.log(' āœ… REAL DATA: Showing actual 9,400+ analyses'); } else if (aiLearningData.data.totalAnalyses === 1120) { console.log(' āŒ MOCK DATA: Still showing old fallback value of 1,120'); } else { console.log(` āš ļø UNKNOWN: Showing ${aiLearningData.data.totalAnalyses} analyses`); } } else { console.log(' āŒ API Failed'); } // 2. Test Automation Learning Status API console.log('\nšŸ¤– Automation Learning Status API:'); const automationLearningResponse = await fetch(`${baseUrl}/api/automation/learning-status`); const automationLearningData = await automationLearningResponse.json(); if (automationLearningData.success) { console.log(` āœ… API Working: ${automationLearningData.success}`); console.log(` šŸ”§ Learning Enabled: ${automationLearningData.learningSystem.enabled}`); console.log(` šŸ“ Message: ${automationLearningData.learningSystem.message}`); console.log(` šŸ”— DB Connected: ${automationLearningData.visibility.learningDatabaseConnected}`); } else { console.log(' āŒ API Failed'); } // 3. Test main automation status console.log('\nāš™ļø Main Automation Status:'); const statusResponse = await fetch(`${baseUrl}/api/automation/status`); const statusData = await statusResponse.json(); console.log(` šŸ”„ Is Active: ${statusData.isActive ? 'YES' : 'NO'}`); console.log(` šŸ“Š Mode: ${statusData.mode || 'Not set'}`); console.log(` šŸ’¹ Symbol: ${statusData.symbol || 'Not set'}`); // 4. Test component integration by checking if page loads with correct data console.log('\nšŸ–„ļø Dashboard Page Integration:'); try { const pageResponse = await fetch(`${baseUrl}/automation-v2`); if (pageResponse.ok) { console.log(' āœ… Page loads successfully'); // Check if the page includes the learning component const pageText = await pageResponse.text(); if (pageText.includes('AI Learning System')) { console.log(' āœ… AI Learning System component present'); } if (pageText.includes('EnhancedAILearningPanel')) { console.log(' āœ… Enhanced AI Learning Panel component loaded'); } } else { console.log(' āŒ Page failed to load'); } } catch (pageError) { console.log(` āŒ Page load error: ${pageError.message}`); } // 5. Summary console.log('\nšŸ“‹ Dashboard Data Summary:'); if (aiLearningData.success && aiLearningData.data.totalAnalyses > 9000) { console.log(' āœ… FIXED: Dashboard should now show 9,400+ real analyses'); console.log(' āœ… Learning system data: REAL database values'); console.log(' āœ… Pattern recognition: ACTIVE'); console.log(' āœ… AI confidence: Real percentage from learning system'); } else { console.log(' āŒ ISSUE: Dashboard may still show mock/fallback data'); } console.log('\nšŸŽÆ Expected Dashboard Display:'); console.log(' šŸ“Š Total Analyses: 9,413 (real data)'); console.log(' šŸŽÆ Total Decisions: 100 (real data)'); console.log(' 🧠 Learning Phase: PATTERN RECOGNITION'); console.log(' šŸ’Ŗ AI Confidence: 50%'); console.log(' šŸ’” System Status: Active with real learning metrics'); } catch (error) { console.error('āŒ Dashboard verification failed:', error.message); } } // Run the verification verifyDashboardData().catch(console.error);