- 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>
128 lines
4.8 KiB
JavaScript
128 lines
4.8 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert';
|
|
import { requireCommonJS } from './_helpers/commonjs-bridge.js';
|
|
import { AutoReporter } from './reporters/AutoReporter.js';
|
|
|
|
/**
|
|
* TESTS TI AVEC AUTO-REPORTING
|
|
* Version simplifiée qui capture automatiquement tout depuis les logs
|
|
*/
|
|
|
|
// Auto-reporter qui se branche automatiquement sur les logs
|
|
const autoReporter = new AutoReporter();
|
|
|
|
const mockCsvData = {
|
|
mc0: 'plaque test intégration rapide',
|
|
t0: 'Test intégration modulaire rapide',
|
|
personality: {
|
|
nom: 'Marc',
|
|
style: 'technique',
|
|
description: 'Expert technique pour tests rapides'
|
|
}
|
|
};
|
|
|
|
const mockContent = {
|
|
'Titre_H1': 'Test titre avec contenu générique nécessitant amélioration technique',
|
|
'Introduction': 'Introduction générique avec vocabulaire basique à améliorer',
|
|
'Contenu_Principal': 'Contenu principal avec termes génériques optimal et efficace nécessitant précision technique',
|
|
'Conclusion': 'Conclusion basique qui nécessite enhancement professionnel'
|
|
};
|
|
|
|
// =========================================
|
|
// TESTS ESSENTIELS AVEC AUTO-CAPTURE
|
|
// =========================================
|
|
|
|
test('lightEnhancement (rapide)', { timeout: 30000 }, async () => {
|
|
autoReporter.onTestStart('lightEnhancement (rapide)');
|
|
|
|
const { applyPredefinedStack } = requireCommonJS('selective-enhancement/SelectiveLayers');
|
|
const result = await applyPredefinedStack(mockContent, 'lightEnhancement', {
|
|
csvData: mockCsvData,
|
|
analysisMode: true
|
|
});
|
|
|
|
assert.ok(result, 'Résultat lightEnhancement');
|
|
assert.ok(result.content, 'Contenu généré');
|
|
assert.equal(result.stats.stackName, 'lightEnhancement', 'Stack correct');
|
|
console.log(`✅ lightEnhancement: ${result.stats.totalModifications} modifications en ${result.stats.totalDuration}ms`);
|
|
});
|
|
|
|
test('standardEnhancement (complet)', { timeout: 60000 }, async () => {
|
|
autoReporter.onTestStart('standardEnhancement (complet)');
|
|
|
|
const { applyPredefinedStack } = requireCommonJS('selective-enhancement/SelectiveLayers');
|
|
const result = await applyPredefinedStack(mockContent, 'standardEnhancement', {
|
|
csvData: mockCsvData,
|
|
analysisMode: true
|
|
});
|
|
|
|
assert.ok(result, 'Résultat standardEnhancement');
|
|
assert.ok(result.content, 'Contenu généré');
|
|
assert.equal(result.stats.stackName, 'standardEnhancement', 'Stack correct');
|
|
console.log(`✅ standardEnhancement: ${result.stats.layers.length} couches, ${result.stats.totalModifications} modifications`);
|
|
});
|
|
|
|
test('fullEnhancement (maximum)', { timeout: 90000 }, async () => {
|
|
autoReporter.onTestStart('fullEnhancement (maximum)');
|
|
|
|
const { applyPredefinedStack } = requireCommonJS('selective-enhancement/SelectiveLayers');
|
|
const result = await applyPredefinedStack(mockContent, 'fullEnhancement', {
|
|
csvData: mockCsvData,
|
|
analysisMode: true
|
|
});
|
|
|
|
assert.ok(result, 'Résultat fullEnhancement');
|
|
assert.ok(result.content, 'Contenu généré');
|
|
assert.equal(result.stats.stackName, 'fullEnhancement', 'Stack correct');
|
|
console.log(`✅ fullEnhancement: ${result.stats.layers.length} couches, ${result.stats.totalModifications} modifications`);
|
|
});
|
|
|
|
test('Adversarial general', { timeout: 45000 }, async () => {
|
|
autoReporter.onTestStart('Adversarial general');
|
|
|
|
const { applyAdversarialLayer } = requireCommonJS('adversarial-generation/AdversarialCore');
|
|
const result = await applyAdversarialLayer(mockContent, {
|
|
detectorTarget: 'general',
|
|
method: 'regeneration',
|
|
intensity: 0.8
|
|
});
|
|
|
|
assert.ok(result, 'Résultat adversarial general');
|
|
console.log(`✅ Adversarial general: ${Object.keys(result).length} éléments traités`);
|
|
});
|
|
|
|
test('Pipeline Standard → Adversarial', { timeout: 120000 }, async () => {
|
|
autoReporter.onTestStart('Pipeline Standard → Adversarial');
|
|
|
|
const { applyPredefinedStack } = requireCommonJS('selective-enhancement/SelectiveLayers');
|
|
const { applyAdversarialLayer } = requireCommonJS('adversarial-generation/AdversarialCore');
|
|
|
|
// Étape 1: Selective standardEnhancement
|
|
const step1 = await applyPredefinedStack(mockContent, 'standardEnhancement', {
|
|
csvData: mockCsvData,
|
|
analysisMode: true
|
|
});
|
|
|
|
assert.ok(step1?.content, 'Étape 1 standard réussie');
|
|
|
|
// Étape 2: Adversarial sur résultat
|
|
const step2 = await applyAdversarialLayer(step1.content, {
|
|
detectorTarget: 'general',
|
|
method: 'enhancement',
|
|
intensity: 0.7
|
|
});
|
|
|
|
assert.ok(step2, 'Étape 2 adversarial réussie');
|
|
console.log(`✅ Pipeline Standard→Adversarial: ${step1.stats.totalModifications} selective + adversarial`);
|
|
});
|
|
|
|
// =========================================
|
|
// GÉNÉRATION AUTOMATIQUE DU RAPPORT
|
|
// =========================================
|
|
|
|
test.after(() => {
|
|
// Attendre un peu pour que tous les tests soient terminés et capturés
|
|
setTimeout(() => {
|
|
autoReporter.generateReport();
|
|
}, 1000);
|
|
}); |