seo-generator-server/tests/trend-validation.test.js
StillHammer f51c4095f6 Add modular pipeline demo system with real module integration
- Add complete modular demo interface (public/modular-pipeline-demo.html)
- Add standalone demo server (simple-server.js) on port 3333
- Integrate real SelectiveCore, AdversarialCore, HumanSimulation, PatternBreaking modules
- Add configurable pipeline with step-by-step content transformation display
- Add new trend management and workflow configuration modules
- Add comprehensive test suite for full pipeline validation
- Update core modules for better modular integration and demo compatibility

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-23 16:03:20 +08:00

218 lines
7.2 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 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();
}