Class_generator/test-node-compatibility.js
StillHammer fe7153d28b Fix compatibility system and improve UX
- Add intelligent content-game compatibility system with visual badges
- Fix Adventure Reader to work with Dragon's Pearl content structure
- Implement multi-column games grid for faster navigation
- Add pronunciation display for Chinese vocabulary and sentences
- Fix navigation breadcrumb to show proper hierarchy (Home > Levels > Content)
- Add back buttons to all navigation pages
- Improve JSONContentLoader to preserve story structure
- Add comprehensive debugging and diagnostic tools

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-18 19:29:21 +08:00

107 lines
3.2 KiB
JavaScript

// === TEST NODE.JS DU SYSTÈME DE COMPATIBILITÉ ===
// Simuler l'environnement browser
global.window = {};
global.document = {};
global.logSh = (msg, level) => console.log(`[${level}] ${msg}`);
// Charger les modules
const fs = require('fs');
const path = require('path');
// Charger le système de compatibilité
const compatibilityCode = fs.readFileSync(path.join(__dirname, 'js/core/content-game-compatibility.js'), 'utf8');
eval(compatibilityCode);
// Créer les contenus de test
const testMinimalContent = {
id: "test-minimal",
name: "Test Minimal",
vocabulary: {
"hello": "bonjour",
"world": "monde"
}
};
const testRichContent = {
id: "test-rich",
name: "Test Riche",
vocabulary: {
"apple": {
translation: "pomme",
prononciation: "apple",
type: "noun"
},
"book": {
translation: "livre",
prononciation: "book",
type: "noun"
},
"car": {
translation: "voiture",
prononciation: "car",
type: "noun"
},
"dog": {
translation: "chien",
prononciation: "dog",
type: "noun"
},
"eat": {
translation: "manger",
prononciation: "eat",
type: "verb"
}
},
sentences: [
{ english: "I have an apple", french: "J'ai une pomme" },
{ english: "The dog is good", french: "Le chien est bon" },
{ english: "I like books", french: "J'aime les livres" }
],
dialogues: [
{
title: "Test dialogue",
conversation: [
{ speaker: "A", english: "Hello", french: "Bonjour" },
{ speaker: "B", english: "Hi there", french: "Salut" }
]
}
]
};
// Tester le système
console.log('🧪 Test du système de compatibilité Content-Game\n');
try {
const checker = new window.ContentGameCompatibility();
console.log('✅ ContentGameCompatibility initialisé\n');
const games = ['whack-a-mole', 'memory-match', 'quiz-game', 'fill-the-blank', 'text-reader', 'adventure-reader'];
console.log('📦 Test avec contenu minimal (2 mots):');
games.forEach(game => {
const result = checker.checkCompatibility(testMinimalContent, game);
const status = result.compatible ? '✅' : '❌';
console.log(` ${status} ${game}: ${result.score}% - ${result.reason}`);
});
console.log('\n📦 Test avec contenu riche:');
games.forEach(game => {
const result = checker.checkCompatibility(testRichContent, game);
const status = result.compatible ? '✅' : '❌';
console.log(` ${status} ${game}: ${result.score}% - ${result.reason}`);
});
console.log('\n🧪 Test des suggestions d\'amélioration:');
const suggestions = checker.getImprovementSuggestions(testMinimalContent, 'whack-a-mole');
console.log(` Suggestions pour "whack-a-mole":`);
suggestions.forEach(suggestion => {
console.log(` 💡 ${suggestion}`);
});
console.log('\n🎉 Tous les tests réussis!');
} catch (error) {
console.error('❌ Erreur:', error.message);
console.error(error.stack);
}