test-intelligent-content.js•4.14 kB
#!/usr/bin/env node
/**
* Test script to validate the intelligent content generation
* This will create a composition and save the generated content to a file
*/
import { chromium } from 'playwright';
import { writeFileSync } from 'fs';
async function testIntelligentGeneration() {
console.log('🧪 Testing Intelligent Content Generation...');
// Import the EuConquisto Composer Server
const { EuConquistoComposerServer } = await import('./dist/browser-automation-api-direct-save-v4.0.3.js');
const server = new EuConquistoComposerServer();
// Test parameters
const testParams = {
prompt: 'Crie uma aula sobre fotossíntese com clorofila, CO2 e glicose para alunos do 6º ano',
subject: 'Ciências',
gradeLevel: '6º ano'
};
console.log('📝 Test Parameters:');
console.log(` Prompt: ${testParams.prompt}`);
console.log(` Subject: ${testParams.subject}`);
console.log(` Grade Level: ${testParams.gradeLevel}`);
// Generate composition data
const compositionData = server.generateCorrectComposition(
testParams.prompt,
testParams.subject,
testParams.gradeLevel
);
console.log('\n🎯 Generated Composition:');
console.log(` Title: ${compositionData.metadata.title}`);
console.log(` Elements: ${compositionData.structure.length}`);
// Save to file for inspection
const filename = `test-intelligent-generation-${Date.now()}.json`;
writeFileSync(filename, JSON.stringify(compositionData, null, 2));
console.log(`\n💾 Composition saved to: ${filename}`);
// Analyze the content
const textWidget = compositionData.structure.find(element => element.type === 'text-2');
if (textWidget) {
console.log('\n📄 Text Widget Analysis:');
console.log(` Title: ${textWidget.content_title}`);
console.log(` Content Preview: ${textWidget.text.slice(0, 200)}...`);
// Check for intelligent content markers
const hasPhotosynthesis = textWidget.text.includes('fotossíntese');
const hasChlorophyll = textWidget.text.includes('clorofila');
const hasCO2 = textWidget.text.includes('CO₂');
const hasGlucose = textWidget.text.includes('glicose');
const hasGenericSobre = textWidget.text.includes('Sobre');
console.log('\n🔍 Content Analysis:');
console.log(` ✅ Contains "fotossíntese": ${hasPhotosynthesis}`);
console.log(` ✅ Contains "clorofila": ${hasChlorophyll}`);
console.log(` ✅ Contains "CO₂": ${hasCO2}`);
console.log(` ✅ Contains "glicose": ${hasGlucose}`);
console.log(` ❌ Contains generic "Sobre": ${hasGenericSobre}`);
const isIntelligent = hasPhotosynthesis && hasChlorophyll && hasCO2 && hasGlucose && !hasGenericSobre;
console.log(`\n🎯 INTELLIGENT GENERATION STATUS: ${isIntelligent ? '✅ SUCCESS' : '❌ FAILED'}`);
if (isIntelligent) {
console.log('🎉 The intelligent content generation is working correctly!');
console.log('✨ Scientific terms are present and generic placeholders are absent.');
} else {
console.log('⚠️ The intelligent content generation needs debugging.');
console.log('🔧 Check the topic extraction and content generation methods.');
}
}
// Check flashcards
const flashcardsWidget = compositionData.structure.find(element => element.type === 'flashcards-1');
if (flashcardsWidget && flashcardsWidget.items) {
console.log('\n🃏 Flashcards Analysis:');
console.log(` Number of flashcards: ${flashcardsWidget.items.length}`);
const firstCard = flashcardsWidget.items[0];
if (firstCard) {
console.log(` First card front: ${firstCard.front_card.text}`);
console.log(` First card back: ${firstCard.back_card.text}`);
const hasIntelligentFlashcards = firstCard.front_card.text.includes('fotossíntese') ||
firstCard.back_card.text.includes('fotossíntese');
console.log(` ✅ Intelligent flashcards: ${hasIntelligentFlashcards}`);
}
}
console.log('\n🏁 Test Complete!');
}
// Run the test
testIntelligentGeneration().catch(console.error);