// FINAL TEST: Complete elimination of mock system
import { default as IAEngine } from './src/DRS/services/IAEngine.js';

async function testFinalNoMock() {
    console.log('🔥 FINAL TEST: Complete elimination of mock system');

    try {
        // Use IAEngine directly with OpenAI only
        const engine = new IAEngine({
            defaultProvider: 'openai',
            fallbackProviders: [] // NO FALLBACK
        });

        await new Promise(resolve => setTimeout(resolve, 1000));

        console.log('✅ IAEngine initialized (OpenAI only)');
        console.log('Available API keys:', Object.keys(engine.apiKeys || {}));

        // Test grammar validation
        const result = await engine.validateGrammar('I are very happy today', {
            grammarConcepts: { subject_verb_agreement: 'basic' },
            languageLevel: 'beginner',
            preferredProvider: 'openai'
        });

        console.log('\n🎉 SUCCESS - Real AI validation:');
        console.log('- Provider:', result.provider);
        console.log('- Score:', result.score);
        console.log('- Correct:', result.correct);
        console.log('- Feedback preview:', result.feedback?.substring(0, 150));
        console.log('- Mock generated:', result.mockGenerated);
        console.log('- Fallback generated:', result.fallbackGenerated);

        // Verify no fake responses
        const isFake = result.provider === 'mock' ||
                      result.provider === 'fallback' ||
                      result.mockGenerated ||
                      result.fallbackGenerated;

        if (isFake) {
            console.log('\n❌ FAKE RESPONSE DETECTED!');
        } else {
            console.log('\n✅ 🎯 PERFECT! MOCK COMPLETELY ELIMINATED!');
            console.log('✅ 🎯 SYSTEM USES REAL AI ONLY!');
            console.log('✅ 🎯 NO MORE BULLSHIT FAKE RESPONSES!');
            console.log('✅ 🎯 EDUCATIONAL INTEGRITY MAINTAINED!');
        }

    } catch (error) {
        console.log('💥 System fails hard (as intended):', error.message);
        console.log('✅ This is GOOD - no fake fallback when AI unavailable');
    }
}

testFinalNoMock().catch(console.error);