Class_generator/test-real-flow.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

116 lines
4.6 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.

// === TEST DU FLUX COMPLET ===
// Test qui simule exactement le flux réel de l'application
async function testRealFlow() {
console.log('🔄 Test du flux complet de l\'application\n');
// Simuler l'environnement browser
global.window = {};
global.document = {};
global.logSh = (msg, level) => console.log(`[${level}] ${msg}`);
// Charger tous les modules
const fs = require('fs');
const path = require('path');
// 1. Charger ContentScanner
const scannerCode = fs.readFileSync(path.join(__dirname, 'js/core/content-scanner.js'), 'utf8');
eval(scannerCode);
// 2. Charger ContentGameCompatibility
const compatibilityCode = fs.readFileSync(path.join(__dirname, 'js/core/content-game-compatibility.js'), 'utf8');
eval(compatibilityCode);
// 3. Charger le contenu Dragon's Pearl
const dragonPearlCode = fs.readFileSync(path.join(__dirname, 'js/content/chinese-long-story.js'), 'utf8');
eval(dragonPearlCode);
try {
console.log('🚀 1. Initialisation du système...');
const scanner = new window.ContentScanner();
const checker = new window.ContentGameCompatibility();
console.log('📦 2. Scan du contenu...');
const results = await scanner.scanAllContent();
console.log(` Trouvé: ${results.found.length} modules`);
// 3. Rechercher Dragon's Pearl dans les résultats
console.log('🐉 3. Recherche Dragon\'s Pearl...');
const dragonPearl = results.found.find(content =>
content.name.includes('Dragon') || content.id.includes('chinese-long-story')
);
if (dragonPearl) {
console.log(` ✅ Trouvé: ${dragonPearl.name} (ID: ${dragonPearl.id})`);
// 4. Test de compatibilité comme dans l'interface
console.log('🎮 4. Test de compatibilité des jeux...');
const games = ['whack-a-mole', 'memory-match', 'quiz-game', 'fill-the-blank', 'text-reader', 'adventure-reader'];
const compatibleGames = [];
const incompatibleGames = [];
games.forEach(game => {
const compatibility = checker.checkCompatibility(dragonPearl, game);
const gameData = { game, compatibility };
if (compatibility.compatible) {
compatibleGames.push(gameData);
} else {
incompatibleGames.push(gameData);
}
console.log(` ${compatibility.compatible ? '✅' : '❌'} ${game}: ${compatibility.score}%`);
});
console.log(`\n📊 Résultat final:`);
console.log(` 🎯 Jeux compatibles: ${compatibleGames.length}`);
console.log(` ⚠️ Jeux incompatibles: ${incompatibleGames.length}`);
if (compatibleGames.length > 0) {
console.log(`\n🎉 SUCCESS: Dragon's Pearl devrait maintenant afficher ${compatibleGames.length} jeux compatibles`);
// Simuler l'affichage comme dans l'interface
console.log('\n🎯 Jeux recommandés:');
compatibleGames
.sort((a, b) => b.compatibility.score - a.compatibility.score)
.forEach(({ game, compatibility }) => {
const badge = compatibility.score >= 80 ? '🎯 Excellent' :
compatibility.score >= 60 ? '✅ Recommandé' : '👍 Compatible';
console.log(` ${badge} ${game} (${compatibility.score}%)`);
});
if (incompatibleGames.length > 0) {
console.log('\n⚠ Jeux avec limitations:');
incompatibleGames.forEach(({ game, compatibility }) => {
console.log(` ⚠️ Limité ${game} (${compatibility.score}%) - ${compatibility.reason}`);
});
}
} else {
console.log('❌ PROBLÈME: Aucun jeu compatible détecté');
}
} else {
console.log('❌ Dragon\'s Pearl non trouvé dans les résultats');
console.log(' Contenus trouvés:');
results.found.forEach(content => {
console.log(` - ${content.name} (ID: ${content.id})`);
});
}
} catch (error) {
console.error('❌ Erreur:', error.message);
console.error(error.stack);
}
}
// Utils pour le scanner
global.window = global.window || {};
global.window.Utils = {
storage: {
get: (key, defaultValue) => defaultValue,
set: (key, value) => {}
}
};
testRealFlow();