seo-generator-server/tests/single-llm-test.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

57 lines
1.9 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';
/**
* SINGLE LLM TEST - Test qui force un appel LLM pour vérifier la capture
*/
const autoReporter = new AutoReporter();
const mockCsvData = {
mc0: 'plaque métallique premium', // Contenu qui devrait déclencher amélioration technique
t0: 'Plaque signalétique professionnelle',
personality: {
nom: 'Marc',
style: 'technique'
}
};
// Contenu plus long pour déclencher l'amélioration technique
const mockContent = {
'Titre_H1': 'Plaque basique standard normale pour amélioration technique nécessaire avec matériaux génériques'
};
test('Single LLM lightEnhancement', { timeout: 30000 }, async () => {
autoReporter.onTestStart('Single LLM lightEnhancement');
const { applyPredefinedStack } = requireCommonJS('selective-enhancement/SelectiveLayers');
// Forcer l'appel LLM avec analysisMode: false
const result = await applyPredefinedStack(mockContent, 'lightEnhancement', {
csvData: mockCsvData,
analysisMode: false // Mode production pour forcer LLM calls
});
assert.ok(result, 'lightEnhancement doit retourner un résultat');
console.log('Résultat:', Object.keys(result));
});
test.after(async () => {
// Attendre que tout se termine
await new Promise(resolve => setTimeout(resolve, 500));
console.log(`\n=== RÉSULTATS AUTO-REPORTER ===`);
console.log(`Tests capturés: ${autoReporter.testResults.length}`);
console.log(`LLM calls: ${autoReporter.llmCalls.length}`);
if (autoReporter.llmCalls.length > 0) {
autoReporter.llmCalls.forEach((call, i) => {
console.log(` ${i+1}. ${call.provider} (${call.model}) - ${call.duration}ms - Context: "${call.testContext}"`);
});
}
const reportFile = autoReporter.generateReport();
console.log(`Rapport généré: ${reportFile}`);
});