Add: Advanced diagnostic tools for production debugging
New Diagnostic Endpoints: - /test-simulation: Full simulation flow testing - /api/test-websocket: WebSocket connectivity testing Enhanced Browser Testing: - testWebSocket(): Test real-time communication - testDistributionChart(): Enhanced chart diagnostics - WebSocket test message handler for live testing Debugging Improvements: - Real-time WebSocket message testing - Manual chart update testing - Complete simulation data flow validation - End-to-end connectivity verification These tools will help identify the exact failure point in the wealth distribution histogram issue.
This commit is contained in:
@@ -1,3 +1,26 @@
|
||||
/**
|
||||
* Test WebSocket connectivity and chart update
|
||||
* Call from browser console: testWebSocket()
|
||||
*/
|
||||
window.testWebSocket = async function() {
|
||||
debugLog('=== WEBSOCKET CONNECTIVITY TEST ===');
|
||||
|
||||
try {
|
||||
const response = await fetch('/api/test-websocket');
|
||||
const result = await response.json();
|
||||
debugLog('WebSocket test API response', result);
|
||||
|
||||
if (result.status === 'success') {
|
||||
debugLog('✅ WebSocket test message sent from server');
|
||||
debugLog('Wait for incoming WebSocket message...');
|
||||
} else {
|
||||
debugLog('❌ WebSocket test API failed', result);
|
||||
}
|
||||
} catch (error) {
|
||||
debugLog('❌ WebSocket test API error', error);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Production debugging test function
|
||||
* Call from browser console: testDistributionChart()
|
||||
@@ -458,6 +481,23 @@ function initializeRealtimeUpdates() {
|
||||
}
|
||||
});
|
||||
|
||||
// WebSocket test handler
|
||||
socket.on('websocket_test', function(data) {
|
||||
debugLog('WebSocket test message received', data);
|
||||
|
||||
// Test updating the distribution chart with test data
|
||||
if (charts.distribution && data.distribution) {
|
||||
try {
|
||||
charts.distribution.data.labels = data.distribution.labels;
|
||||
charts.distribution.data.datasets[0].data = data.distribution.counts;
|
||||
charts.distribution.update();
|
||||
debugLog('✅ WebSocket test: Chart updated successfully with test data');
|
||||
} catch (error) {
|
||||
debugLog('❌ WebSocket test: Chart update failed', error);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Simulation progress updates
|
||||
socket.on('simulation_progress', function(data) {
|
||||
debugLog('Received real-time progress update');
|
||||
|
Reference in New Issue
Block a user