// Test script to verify AI learning system integration const path = require('path'); async function testLearningIntegration() { console.log('๐Ÿงช Testing AI Learning System Integration...\n'); try { // Test 1: Check if learning-enhanced automation can be imported console.log('1๏ธโƒฃ Testing automation with learning import...'); const AutomationWithLearning = require('./lib/automation-with-learning.js'); console.log('โœ… AutomationWithLearning imported successfully'); // Test 2: Create automation instance console.log('\n2๏ธโƒฃ Creating automation instance...'); const automation = new AutomationWithLearning(); console.log('โœ… Automation instance created'); console.log(' - Has learner property:', 'learner' in automation); console.log(' - Has learning methods:', typeof automation.getLearningStatus === 'function'); // Test 3: Check if SimplifiedStopLossLearner can be imported console.log('\n3๏ธโƒฃ Testing SimplifiedStopLossLearner import...'); try { const { SimplifiedStopLossLearner } = await import('./lib/simplified-stop-loss-learner-fixed.js'); console.log('โœ… SimplifiedStopLossLearner imported successfully'); // Test creating learner instance const learner = new SimplifiedStopLossLearner(); console.log('โœ… SimplifiedStopLossLearner instance created'); console.log(' - Available methods:', Object.getOwnPropertyNames(Object.getPrototypeOf(learner)).filter(name => name !== 'constructor')); } catch (learnerError) { console.log('โŒ SimplifiedStopLossLearner import failed:', learnerError.message); } // Test 4: Initialize learning system console.log('\n4๏ธโƒฃ Testing learning system initialization...'); try { const initialized = await automation.initializeLearningSystem(); console.log('โœ… Learning system initialization result:', initialized); console.log(' - Learner created:', !!automation.learner); if (automation.learner) { console.log(' - Learner type:', automation.learner.constructor.name); // Test learning status if (typeof automation.getLearningStatus === 'function') { const status = await automation.getLearningStatus(); console.log(' - Learning status:', status); } } } catch (initError) { console.log('โŒ Learning system initialization failed:', initError.message); } // Test 5: Test singleton manager console.log('\n5๏ธโƒฃ Testing singleton automation manager...'); try { const { getAutomationInstance } = require('./lib/automation-singleton.js'); const singletonInstance = await getAutomationInstance(); console.log('โœ… Singleton automation instance retrieved'); console.log(' - Instance type:', singletonInstance.constructor.name); console.log(' - Has learning capabilities:', typeof singletonInstance.getLearningStatus === 'function'); } catch (singletonError) { console.log('โŒ Singleton manager test failed:', singletonError.message); } // Test 6: Test database connection console.log('\n6๏ธโƒฃ Testing database connection...'); try { const { getDB } = require('./lib/db.js'); const db = await getDB(); console.log('โœ… Database connection successful'); // Test if learning tables exist const tables = await db.$queryRaw` SELECT name FROM sqlite_master WHERE type='table' AND name LIKE '%learning%' `; console.log(' - Learning-related tables:', tables.map(t => t.name)); } catch (dbError) { console.log('โŒ Database connection failed:', dbError.message); } console.log('\n๐ŸŽฏ Integration Test Summary:'); console.log('๐Ÿ“Š The AI learning system integration appears to be working'); console.log('๐Ÿ”— Key components are properly connected'); console.log('๐Ÿ’ก Learning system should now enhance trading decisions when automation starts'); } catch (error) { console.error('โŒ Integration test failed:', error); } } // Run the test testLearningIntegration().catch(console.error);