seo-generator-server/tests/pipeline-4-phases-complet.test.js
StillHammer 4f60de68d6 Fix BatchProcessor initialization and add comprehensive test suite
- Fix BatchProcessor constructor to avoid server blocking during startup
- Add comprehensive integration tests for all modular combinations
- Enhance CLAUDE.md documentation with new test commands
- Update SelectiveLayers configuration for better LLM allocation
- Add AutoReporter system for test automation
- Include production workflow validation tests

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-19 14:17:49 +08:00

176 lines
7.3 KiB
JavaScript
Raw Permalink 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.

#!/usr/bin/env node
import test from 'node:test';
import assert from 'node:assert';
import { requireCommonJS } from './_helpers/commonjs-bridge.js';
import { AutoReporter } from './reporters/AutoReporter.js';
/**
* TEST PIPELINE 4 PHASES COMPLET AVEC TOUS LES APPELS LLM
* Workflow: Generation initial => adversarial => Heavy enhancement => human touch
* But: Capturer TOUS les appels LLM de toutes les phases
*/
// Auto-Reporter Configuration
const autoReporter = new AutoReporter();
// Configuration pipeline
const mockCsvData = {
mc0: 'solution digitale enterprise pipeline 4 phases complet',
t0: 'Pipeline complet 4 phases avec tous les appels LLM',
personality: {
nom: 'Sophie',
style: 'créatif-technique',
description: 'Experte en content strategy et pipeline complet'
}
};
console.log('🚀 PIPELINE 4 PHASES COMPLET - TOUS LES APPELS LLM');
console.log('📋 Workflow: Generation initial => adversarial => Heavy enhancement => human touch');
test('Pipeline 4 Phases Complet - Tous Appels LLM', { timeout: 300000 }, async () => {
// Définir le contexte de test pour l'AutoReporter
autoReporter.setTestContext('Pipeline 4 Phases Complet - Tous Appels LLM');
console.log('\n🔄 === DÉMARRAGE PIPELINE 4 PHASES COMPLET ===');
// =========================================
// PHASE 1: GÉNÉRATION INITIALE
// =========================================
console.log('\n📝 PHASE 1/4: Génération Initiale (Content de base)');
let result = {
content: {
'Titre_H1': 'Solutions digitales enterprise pour transformation métier avec architecture moderne et pipeline 4 phases complet',
'Introduction': 'Les solutions digitales enterprise révolutionnent la gestion des processus métier grâce à leur architecture modulaire, leurs capacités d\'intégration avancées et leurs outils analytics prédictive dans un pipeline complet.',
'Avantages_Techniques': 'Architecture cloud-native avec APIs REST sécurisées, scalabilité automatique, monitoring en temps réel des performances système, bases de données distribuées et intelligence artificielle intégrée pour pipeline optimisé.',
'Conclusion': 'Investissement stratégique permettant digitalisation complète avec pipeline 4 phases, amélioration significative de la productivité organisationnelle et avantage concurrentiel durable.'
}
};
assert.ok(result.content, 'Content initial préparé');
console.log('✅ Phase 1: Content initial préparé');
console.log(`📊 Content initial: ${Object.keys(result.content).length} éléments`);
// =========================================
// PHASE 2: ADVERSARIAL DEFENSE AVEC LLM
// =========================================
console.log('\n🛡 PHASE 2/4: Adversarial Defense avec LLM (Anti-détection)');
const AdversarialLayers = requireCommonJS('adversarial-generation/AdversarialLayers');
result = await AdversarialLayers.applyPredefinedStack(
result.content,
'standardDefense', // Plus de couches pour plus d'appels LLM
{
...mockCsvData,
preferredProvider: 'claude',
intensity: 1.0
},
{ source: 'pipeline_4_phases_complet_adversarial' }
);
assert.ok(result.content, 'Adversarial defense avec LLM appliqué');
console.log('✅ Phase 2: Adversarial defense avec Claude terminé');
console.log(`📊 Anti-détection: ${result.stats?.layersApplied || 'standard'} couches appliquées`);
// =========================================
// PHASE 3: HEAVY ENHANCEMENT AVEC LLM
// =========================================
console.log('\n⚡ PHASE 3/4: Heavy Enhancement avec LLM (Technique)');
const { applyPredefinedStack } = requireCommonJS('selective-enhancement/SelectiveLayers');
result = await applyPredefinedStack(
result.content,
'standardEnhancement', // Stack avec plus d'appels LLM
{
...mockCsvData,
preferredProvider: 'openai',
intensity: 1.2
},
{ source: 'pipeline_4_phases_complet_enhancement' }
);
assert.ok(result.content, 'Heavy enhancement avec LLM appliqué');
console.log('✅ Phase 3: Heavy enhancement avec OpenAI terminé');
console.log(`📊 Enhancement: ${result.stats?.layersApplied || 'standard'} couches appliquées`);
// =========================================
// PHASE 4: HUMAN TOUCH AVEC LLM
// =========================================
console.log('\n👤 PHASE 4/4: Human Touch avec LLM (Simulation Humaine)');
const { applyPredefinedSimulation } = requireCommonJS('human-simulation/HumanSimulationLayers');
result = await applyPredefinedSimulation(
result.content,
'personalityFocus', // Simulation plus avancée avec LLM
{
...mockCsvData,
humanization: 0.8,
fatigueLevel: 0.4,
preferredProvider: 'claude'
}
);
assert.ok(result.content, 'Human touch avec LLM appliqué');
console.log('✅ Phase 4: Human touch avec Claude terminé');
console.log(`📊 Humanisation: simulation avec personnalité ${mockCsvData.personality.nom}`);
// =========================================
// VALIDATION FINALE
// =========================================
console.log('\n🎯 === VALIDATION PIPELINE 4 PHASES COMPLET ===');
const finalContent = result.content;
const contentKeys = Object.keys(finalContent);
// Vérifications qualité finale
assert.ok(contentKeys.length >= 4, `Au moins 4 éléments (trouvé: ${contentKeys.length})`);
// Vérification contenu non vide
contentKeys.forEach(key => {
assert.ok(finalContent[key] && finalContent[key].length > 50,
`Element ${key} doit contenir du contenu substantiel`);
});
console.log('\n📈 === RÉSULTATS PIPELINE 4 PHASES COMPLET ===');
console.log(`✅ 4 phases exécutées avec succès`);
console.log(`📝 Content final: ${contentKeys.length} éléments`);
console.log(`📊 Longueur totale: ${Object.values(finalContent).join(' ').length} caractères`);
console.log(`🎭 Personnalité: ${mockCsvData.personality.nom} (${mockCsvData.personality.style})`);
console.log(`🛡️ Anti-détection: Stack standardDefense appliqué`);
console.log(`⚡ Enhancement: Stack standardEnhancement appliqué`);
console.log(`👤 Humanisation: personalityFocus appliquée`);
// Affichage échantillon final
console.log('\n📄 === ÉCHANTILLON CONTENT FINAL ===');
contentKeys.slice(0, 2).forEach(key => {
const preview = finalContent[key].substring(0, 120) + '...';
console.log(`${key}: "${preview}"`);
});
console.log('\n🎉 PIPELINE 4 PHASES COMPLET AVEC TOUS LES APPELS LLM RÉUSSI !');
// Appel LLM supplémentaire final pour validation
console.log('\n🔄 APPEL LLM FINAL...');
const finalValidation = await applyPredefinedStack(
{ 'Validation_Finale': 'Validation finale du pipeline 4 phases complet avec tous les appels LLM' },
'lightEnhancement',
{
...mockCsvData,
preferredProvider: 'openai',
intensity: 0.8
},
{ source: 'pipeline_4_phases_complet_validation' }
);
assert.ok(finalValidation, 'Validation finale avec LLM réussie');
console.log('✅ Validation finale terminée');
});
console.log('\n🔥 Test pipeline 4 phases complet avec TOUS les appels LLM');
console.log('📋 Workflow: Génération LLM → Adversarial LLM → Enhancement LLM → Human Touch LLM');
console.log('🎯 Objectif: Capturer tous les appels LLM dans le rapport AutoReporter');