test-composer-format.js•1.87 kB
#!/usr/bin/env node
/**
* Test the fixed format_for_composer tool
*/
import { createComposerFormatter } from './src/tools/format-for-composer.js';
console.log('🧪 Testing Fixed Composer Format');
console.log('===============================');
const formatter = createComposerFormatter();
const testLessonData = {
metadata: {
topic: 'Máquinas Simples',
subject: 'Ciências',
gradeLevel: '7º ano',
duration: 50,
learningObjectives: ['Compreender alavancas', 'Identificar polias']
},
widgets: [
{
type: 'head-1',
content: {
category: 'CIÊNCIAS',
author_name: 'Professor(a) Virtual',
author_office: 'Educador'
}
},
{
type: 'text-1',
content: {
title: 'Introdução às Máquinas Simples',
text: '<p>As máquinas simples são dispositivos que facilitam nosso trabalho.</p>'
}
}
]
};
try {
const result = await formatter.formatForComposer(testLessonData);
if (result.success) {
console.log('✅ Format successful');
const json = result.data.composerJSON;
console.log('\n📊 JSON Structure:');
console.log(' version:', json.version);
console.log(' metadata.title:', json.metadata.title);
console.log(' metadata.description:', json.metadata.description);
console.log(' interface.content_language:', json.interface.content_language);
console.log(' structure.length:', json.structure.length);
console.log('\n🎯 Full JSON Preview:');
console.log(JSON.stringify(json, null, 2).substring(0, 500) + '...');
console.log('\n✅ Fixed format matches official Composer JSON structure!');
} else {
console.log('❌ Format failed:', result.error.message);
}
} catch (error) {
console.log('💥 Test error:', error.message);
}
console.log('\n🔍 Test complete');