// ======================================== // TEST VALIDATION SYSTÈME TENDANCES // Test des configurations de tendances et intégration avec pipeline modulaire // ======================================== const { TrendManager } = require('../lib/trend-prompts/TrendManager'); const { applySelectiveLayer } = require('../lib/selective-enhancement/SelectiveCore'); describe('🎯 Système de Tendances - Validation', () => { let trendManager; beforeEach(() => { trendManager = new TrendManager(); }); describe('📋 TrendManager - Fonctionnalités de base', () => { test('Initialisation et tendances prédéfinies', () => { const trends = trendManager.getAvailableTrends(); expect(trends.length).toBeGreaterThan(5); expect(trends.find(t => t.id === 'eco-responsable')).toBeDefined(); expect(trends.find(t => t.id === 'tech-innovation')).toBeDefined(); expect(trends.find(t => t.id === 'artisanal-premium')).toBeDefined(); }); test('Sélection tendance eco-responsable', async () => { const result = await trendManager.setTrend('eco-responsable'); expect(result.id).toBe('eco-responsable'); expect(result.name).toBe('Eco-Responsable'); expect(result.isCustom).toBe(false); expect(result.config.technical.targetTerms).toContain('durable'); expect(result.config.style.targetStyle).toBe('conscient et responsable'); }); test('Configuration couche technique avec tendance', async () => { await trendManager.setTrend('tech-innovation'); const config = trendManager.getLayerConfig('technical', { intensity: 0.8 }); expect(config.intensity).toBe(0.8); expect(config.targetTerms).toContain('intelligent'); expect(config.targetTerms).toContain('connecté'); expect(config._trend.id).toBe('tech-innovation'); }); }); describe('🧪 Intégration Pipeline Modulaire', () => { test('Application tendance sur contenu via SelectiveCore', async () => { // Contenu test const testContent = { titre: 'Installation système sécurité', intro: 'Guide installation caméras surveillance maison', section1: 'Étapes installation détaillées' }; console.log('\n🎯 Test tendance "tech-innovation" appliquée:'); // Appliquer couche technique avec tendance tech-innovation const result = await applySelectiveLayer(testContent, { layerType: 'technical', trendId: 'tech-innovation', llmProvider: 'openai', csvData: { mc0: 'caméra sécurité connectée' } }); expect(result.success).toBe(true); expect(result.content).toBeDefined(); expect(result.stats.trendApplied).toBe('tech-innovation'); // Vérifier que le contenu a été modifié expect(Object.keys(result.content)).toEqual(Object.keys(testContent)); console.log('✅ Résultat tendance appliquée:'); console.log(' - Tendance:', result.stats.trendApplied); console.log(' - Éléments traités:', result.stats.elementsProcessed); console.log(' - Éléments améliorés:', result.stats.elementsEnhanced); }, 60000); test('Comparaison avec/sans tendance', async () => { const testContent = { titre: 'Création bijoux personnalisés', intro: 'Atelier création bijoux uniques' }; console.log('\n⚖️ Comparaison avec/sans tendance:'); // Sans tendance const resultStandard = await applySelectiveLayer(testContent, { layerType: 'style', llmProvider: 'mistral' }); // Avec tendance artisanale const resultTrend = await applySelectiveLayer(testContent, { layerType: 'style', trendId: 'artisanal-premium', llmProvider: 'mistral' }); expect(resultStandard.success).toBe(true); expect(resultTrend.success).toBe(true); expect(resultTrend.stats.trendApplied).toBe('artisanal-premium'); console.log('✅ Standard:', resultStandard.content.titre?.substring(0, 50) + '...'); console.log('✅ Tendance:', resultTrend.content.titre?.substring(0, 50) + '...'); }, 60000); }); describe('🌟 Tendances Spécialisées', () => { test('Tendance saisonnière automne-cocooning', async () => { await trendManager.setTrend('automne-cocooning'); const config = trendManager.getLayerConfig('style'); expect(config.targetTerms).toContain('chaleureux'); expect(config.targetTerms).toContain('douillet'); expect(config.targetStyle).toBe('chaleureux et enveloppant'); expect(config.tone).toBe('bienveillant et réconfortant'); }); test('Tendance générationnelle generation-z', async () => { await trendManager.setTrend('generation-z'); const config = trendManager.getLayerConfig('technical'); expect(config.targetTerms).toContain('personnalisable'); expect(config.targetTerms).toContain('inclusif'); expect(config.focusAreas).toContain('personnalisation'); }); test('Création tendance personnalisée', () => { const customTrend = { name: 'Test Custom', description: 'Tendance de test', config: { technical: { targetTerms: ['test', 'custom'], focusAreas: ['testing'] } } }; trendManager.createCustomTrend('test-custom', customTrend); const trends = trendManager.getAvailableTrends(); const custom = trends.find(t => t.id === 'test-custom'); expect(custom).toBeDefined(); expect(custom.isCustom).toBe(true); expect(custom.category).toBe('custom'); }); }); describe('📊 Status et Monitoring', () => { test('Status TrendManager', async () => { const status = trendManager.getStatus(); expect(status.activeTrend).toBeNull(); expect(status.availableTrends).toBeGreaterThan(5); expect(status.customTrends).toBe(0); await trendManager.setTrend('eco-responsable'); const statusActive = trendManager.getStatus(); expect(statusActive.activeTrend.id).toBe('eco-responsable'); expect(statusActive.activeTrend.isCustom).toBe(false); }); test('Catégorisation tendances', () => { expect(trendManager.getTrendCategory('eco-responsable')).toBe('sectorielle'); expect(trendManager.getTrendCategory('generation-z')).toBe('générationnelle'); expect(trendManager.getTrendCategory('automne-cocooning')).toBe('saisonnière'); }); test('Réinitialisation', async () => { await trendManager.setTrend('tech-innovation'); expect(trendManager.getCurrentTrend()).toBeDefined(); trendManager.clearTrend(); expect(trendManager.getCurrentTrend()).toBeNull(); }); }); }); // ======================================== // TESTS HELPER FUNCTIONS // ======================================== /** * Test helper - Affiche les tendances disponibles */ function logAvailableTrends() { const manager = new TrendManager(); const trends = manager.getAvailableTrends(); console.log('\n📋 Tendances disponibles:'); trends.forEach(trend => { console.log(` ${trend.id} (${trend.category}) - ${trend.description}`); }); } // Exporter pour tests manuels if (require.main === module) { logAvailableTrends(); }