Class_generator/tests/ai-validation/test-real-ai-integration.js
StillHammer f5cef0c913 Add comprehensive testing suite with UI/UX and E2E integration tests
- Create complete integration test system (test-integration.js)
- Add UI/UX interaction testing with real event simulation (test-uiux-integration.js)
- Implement end-to-end scenario testing for user journeys (test-e2e-scenarios.js)
- Add console testing commands for rapid development testing (test-console-commands.js)
- Create comprehensive test guide documentation (TEST-GUIDE.md)
- Integrate test buttons in debug panel (F12 → 3 test types)
- Add vocabulary modal two-progress-bar system integration
- Fix flashcard retry system for "don't know" cards
- Update IntelligentSequencer for task distribution validation

🧪 Testing Coverage:
- 35+ integration tests (architecture/modules)
- 20+ UI/UX tests (real user interactions)
- 5 E2E scenarios (complete user journeys)
- Console commands for rapid testing
- Debug panel integration

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-28 23:04:38 +08:00

110 lines
4.1 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* Real AI Integration Test
* Test Open Analysis Modules with actual AI responses
*/
function createMockDependencies() {
return {
orchestrator: {
getSharedServices: () => ({
iaEngine: {
validateEducationalContent: async (prompt, options) => ({
content: JSON.stringify([{
question: "Test question",
expectations: "Test expectations",
targetLength: 100
}])
})
}
}),
handleExerciseCompletion: (data) => {
console.log('📊 Exercise completion handled:', data.moduleType);
}
},
llmValidator: {
isAvailable: () => true,
validateTextComprehension: async (text, response, context) => {
// This will use the real IAEngine now
const { default: LLMValidator } = await import('./src/DRS/services/LLMValidator.js');
const validator = new LLMValidator();
return await validator.validateTextComprehension(text, response, context);
}
},
prerequisiteEngine: {
checkPrerequisites: () => true
},
contextMemory: {
store: () => {},
retrieve: () => null
}
};
}
async function testRealAIIntegration() {
console.log('🚀 Testing Open Analysis Modules with Real AI Integration...\n');
try {
// Test TextAnalysisModule with real AI
console.log('1⃣ Testing TextAnalysisModule with real AI...');
const { default: TextAnalysisModule } = await import('./src/DRS/exercise-modules/TextAnalysisModule.js');
const mockDeps = createMockDependencies();
const textModule = new TextAnalysisModule(
mockDeps.orchestrator,
mockDeps.llmValidator,
mockDeps.prerequisiteEngine,
mockDeps.contextMemory
);
// Real content with proper structure
const realContent = {
text: "Climate change is one of the most pressing issues of our time. Rising global temperatures are causing ice caps to melt, sea levels to rise, and weather patterns to become more extreme.",
title: "Climate Change",
difficulty: "intermediate",
language: "en"
};
// Test if module can run
const canRun = textModule.canRun([], { texts: [realContent] });
console.log('TextAnalysisModule canRun:', canRun);
if (canRun) {
// Test present method with proper context
const context = {
content: realContent,
difficulty: "intermediate",
language: "en"
};
const presentation = textModule.present(context);
console.log('TextAnalysisModule presentation type:', typeof presentation);
// Test validate method with AI
console.log('Testing AI validation...');
const userResponse = "Climate change causes global warming and extreme weather.";
const validationContext = {
text: realContent.text,
difficulty: "intermediate",
language: "en"
};
const validation = await textModule.validate(userResponse, validationContext);
console.log('✅ Real AI Validation Result:');
console.log('- Success:', validation.success);
console.log('- Score:', validation.score);
console.log('- Provider:', validation.provider);
console.log('- Feedback preview:', validation.feedback?.substring(0, 150));
}
console.log('\n🎯 Real AI integration test completed!');
} catch (error) {
console.error('❌ Real AI integration test failed:', error.message);
console.error('Stack:', error.stack);
}
}
// Run the test
testRealAIIntegration().catch(error => {
console.error('❌ Test execution failed:', error);
process.exit(1);
});