- Add intermediate saves (v1.0-v1.4) to Generated_Articles_Versioned - Fix compiled_text pipeline (generatedTexts object structure) - Add /api/workflow-modulaire endpoint with version tracking - Create test-modulaire.html interface with real-time logs - Support parent-child linking via Parent_Article_ID
415 lines
14 KiB
JavaScript
415 lines
14 KiB
JavaScript
// ========================================
|
|
// TESTS GÉNÉRÉS AUTOMATIQUEMENT - SelectiveUtils
|
|
// Module: selective-enhancement/SelectiveUtils.js
|
|
// Générés le: 2025-09-06T03:38:48.247Z
|
|
// ========================================
|
|
|
|
const assert = require('assert');
|
|
const { test, describe } = require('node:test');
|
|
const SelectiveUtils = require('../../selective-enhancement/SelectiveUtils.js');
|
|
const { AIContentValidator } = require('../validators/AIContentValidator');
|
|
|
|
describe('SelectiveUtils - Tests automatiques', () => {
|
|
|
|
// Setup avant les tests
|
|
let testContext = {};
|
|
|
|
test('Module loading', () => {
|
|
assert.ok(SelectiveUtils, 'Module should be loaded');
|
|
console.log('📦 Module SelectiveUtils loaded successfully');
|
|
});
|
|
|
|
|
|
test('sleep - Async Operation', async () => {
|
|
const input = ["test_value", "test_value"];
|
|
|
|
try {
|
|
const startTime = Date.now();
|
|
const result = await SelectiveUtils.sleep(input);
|
|
const duration = Date.now() - startTime;
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(duration < 30000, 'Should complete within 30 seconds');
|
|
|
|
console.log(`✅ sleep: Completed in ${duration}ms`);
|
|
|
|
} catch (error) {
|
|
console.error('❌ sleep: Async operation failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('analyzeTechnicalQuality - Basic Function', () => {
|
|
const input = ["Test content for validation", "Sample text for processing"];
|
|
|
|
try {
|
|
const result = SelectiveUtils.analyzeTechnicalQuality(input);
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(typeof result !== 'undefined', 'Result should be defined');
|
|
|
|
console.log('✅ analyzeTechnicalQuality: Function executed successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ analyzeTechnicalQuality: Function failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('analyzeTransitionFluidity - Basic Function', () => {
|
|
const input = "Test content for validation";
|
|
|
|
try {
|
|
const result = SelectiveUtils.analyzeTransitionFluidity(input);
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(typeof result !== 'undefined', 'Result should be defined');
|
|
|
|
console.log('✅ analyzeTransitionFluidity: Function executed successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ analyzeTransitionFluidity: Function failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('analyzeStyleConsistency - Basic Function', () => {
|
|
const input = ["Test content for validation", "test_value"];
|
|
|
|
try {
|
|
const result = SelectiveUtils.analyzeStyleConsistency(input);
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(typeof result !== 'undefined', 'Result should be defined');
|
|
|
|
console.log('✅ analyzeStyleConsistency: Function executed successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ analyzeStyleConsistency: Function failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('compareContentImprovement - Basic Function', () => {
|
|
const input = ["test_value", "test_value", "test_value"];
|
|
|
|
try {
|
|
const result = SelectiveUtils.compareContentImprovement(input);
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(typeof result !== 'undefined', 'Result should be defined');
|
|
|
|
console.log('✅ compareContentImprovement: Function executed successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ compareContentImprovement: Function failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('cleanGeneratedContent - Basic Function', () => {
|
|
const input = ["Test content for validation", "test_value"];
|
|
|
|
try {
|
|
const result = SelectiveUtils.cleanGeneratedContent(input);
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(typeof result !== 'undefined', 'Result should be defined');
|
|
|
|
console.log('✅ cleanGeneratedContent: Function executed successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ cleanGeneratedContent: Function failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('validateSelectiveContent - Validation', async () => {
|
|
const validInput = ["Test content for validation", "test_value", "test_value"];
|
|
const invalidInput = null;
|
|
|
|
try {
|
|
// Test avec input valide
|
|
const validResult = await SelectiveUtils.validateSelectiveContent(validInput);
|
|
assert.ok(validResult !== undefined, 'Should return result for valid input');
|
|
|
|
// Test avec input invalide
|
|
try {
|
|
const invalidResult = await SelectiveUtils.validateSelectiveContent(invalidInput);
|
|
// Si pas d'erreur, vérifier que la validation échoue
|
|
if (typeof invalidResult === 'boolean') {
|
|
assert.strictEqual(invalidResult, false, 'Should return false for invalid input');
|
|
}
|
|
} catch (error) {
|
|
// C'est attendu pour une validation qui throw
|
|
console.log('Expected validation error:', error.message);
|
|
}
|
|
|
|
console.log('✅ validateSelectiveContent: Validation working correctly');
|
|
|
|
} catch (error) {
|
|
console.error('❌ validateSelectiveContent: Validation test failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('chunkArray - Basic Function', () => {
|
|
const input = ["test_value", "test_value", "test_value"];
|
|
|
|
try {
|
|
const result = SelectiveUtils.chunkArray(input);
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(typeof result !== 'undefined', 'Result should be defined');
|
|
|
|
console.log('✅ chunkArray: Function executed successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ chunkArray: Function failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('measurePerformance - Basic Function', () => {
|
|
const input = ["test_value", "test_value"];
|
|
|
|
try {
|
|
const result = SelectiveUtils.measurePerformance(input);
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(typeof result !== 'undefined', 'Result should be defined');
|
|
|
|
console.log('✅ measurePerformance: Function executed successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ measurePerformance: Function failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('formatDuration - Basic Function', () => {
|
|
const input = "test_value";
|
|
|
|
try {
|
|
const result = SelectiveUtils.formatDuration(input);
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(typeof result !== 'undefined', 'Result should be defined');
|
|
|
|
console.log('✅ formatDuration: Function executed successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ formatDuration: Function failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('generateImprovementReport - Content Generation', async () => {
|
|
const mockInput = ["test_value", "test_value", "test_value"];
|
|
|
|
try {
|
|
const result = await SelectiveUtils.generateImprovementReport(mockInput);
|
|
|
|
// Validations de base
|
|
assert.ok(result, 'Should return a result');
|
|
assert.ok(typeof result === 'string' || typeof result === 'object', 'Should return content');
|
|
|
|
// Validation IA si contenu texte
|
|
if (typeof result === 'string' && result.length > 50) {
|
|
const validation = await AIContentValidator.quickValidate(result, {
|
|
context: 'Generated content test'
|
|
});
|
|
assert.ok(validation.overall >= 40, 'Content quality should be acceptable');
|
|
}
|
|
|
|
console.log('✅ generateImprovementReport: Content generated successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ generateImprovementReport: Generation failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('if - Basic Function', () => {
|
|
const input = undefined;
|
|
|
|
try {
|
|
const result = SelectiveUtils.if(input);
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(typeof result !== 'undefined', 'Result should be defined');
|
|
|
|
console.log('✅ if: Function executed successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ if: Function failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('for - Basic Function', () => {
|
|
const input = undefined;
|
|
|
|
try {
|
|
const result = SelectiveUtils.for(input);
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(typeof result !== 'undefined', 'Result should be defined');
|
|
|
|
console.log('✅ for: Function executed successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ for: Function failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('switch - Basic Function', () => {
|
|
const input = undefined;
|
|
|
|
try {
|
|
const result = SelectiveUtils.switch(input);
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(typeof result !== 'undefined', 'Result should be defined');
|
|
|
|
console.log('✅ switch: Function executed successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ switch: Function failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('forEach - Basic Function', () => {
|
|
const input = undefined;
|
|
|
|
try {
|
|
const result = SelectiveUtils.forEach(input);
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(typeof result !== 'undefined', 'Result should be defined');
|
|
|
|
console.log('✅ forEach: Function executed successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ forEach: Function failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('Export - Analyseurs', () => {
|
|
assert.ok(SelectiveUtils.Analyseurs !== undefined, 'Export Analyseurs should be available');
|
|
console.log('✅ Export Analyseurs: Available');
|
|
});
|
|
|
|
test('Export - analyzeTechnicalQuality', () => {
|
|
assert.ok(SelectiveUtils.analyzeTechnicalQuality !== undefined, 'Export analyzeTechnicalQuality should be available');
|
|
console.log('✅ Export analyzeTechnicalQuality: Available');
|
|
});
|
|
|
|
test('Export - analyzeTransitionFluidity', () => {
|
|
assert.ok(SelectiveUtils.analyzeTransitionFluidity !== undefined, 'Export analyzeTransitionFluidity should be available');
|
|
console.log('✅ Export analyzeTransitionFluidity: Available');
|
|
});
|
|
|
|
test('Export - analyzeStyleConsistency', () => {
|
|
assert.ok(SelectiveUtils.analyzeStyleConsistency !== undefined, 'Export analyzeStyleConsistency should be available');
|
|
console.log('✅ Export analyzeStyleConsistency: Available');
|
|
});
|
|
|
|
test('Export - Comparateurs', () => {
|
|
assert.ok(SelectiveUtils.Comparateurs !== undefined, 'Export Comparateurs should be available');
|
|
console.log('✅ Export Comparateurs: Available');
|
|
});
|
|
|
|
test('Export - compareContentImprovement', () => {
|
|
assert.ok(SelectiveUtils.compareContentImprovement !== undefined, 'Export compareContentImprovement should be available');
|
|
console.log('✅ Export compareContentImprovement: Available');
|
|
});
|
|
|
|
test('Export - Utilitaires', () => {
|
|
assert.ok(SelectiveUtils.Utilitaires !== undefined, 'Export Utilitaires should be available');
|
|
console.log('✅ Export Utilitaires: Available');
|
|
});
|
|
|
|
test('Export - contenu', () => {
|
|
assert.ok(SelectiveUtils.contenu !== undefined, 'Export contenu should be available');
|
|
console.log('✅ Export contenu: Available');
|
|
});
|
|
|
|
test('Export - cleanGeneratedContent', () => {
|
|
assert.ok(SelectiveUtils.cleanGeneratedContent !== undefined, 'Export cleanGeneratedContent should be available');
|
|
console.log('✅ Export cleanGeneratedContent: Available');
|
|
});
|
|
|
|
test('Export - validateSelectiveContent', () => {
|
|
assert.ok(SelectiveUtils.validateSelectiveContent !== undefined, 'Export validateSelectiveContent should be available');
|
|
console.log('✅ Export validateSelectiveContent: Available');
|
|
});
|
|
|
|
test('Export - techniques', () => {
|
|
assert.ok(SelectiveUtils.techniques !== undefined, 'Export techniques should be available');
|
|
console.log('✅ Export techniques: Available');
|
|
});
|
|
|
|
test('Export - chunkArray', () => {
|
|
assert.ok(SelectiveUtils.chunkArray !== undefined, 'Export chunkArray should be available');
|
|
console.log('✅ Export chunkArray: Available');
|
|
});
|
|
|
|
test('Export - sleep', () => {
|
|
assert.ok(SelectiveUtils.sleep !== undefined, 'Export sleep should be available');
|
|
console.log('✅ Export sleep: Available');
|
|
});
|
|
|
|
test('Export - measurePerformance', () => {
|
|
assert.ok(SelectiveUtils.measurePerformance !== undefined, 'Export measurePerformance should be available');
|
|
console.log('✅ Export measurePerformance: Available');
|
|
});
|
|
|
|
test('Export - formatDuration', () => {
|
|
assert.ok(SelectiveUtils.formatDuration !== undefined, 'Export formatDuration should be available');
|
|
console.log('✅ Export formatDuration: Available');
|
|
});
|
|
|
|
test('Export - Rapports', () => {
|
|
assert.ok(SelectiveUtils.Rapports !== undefined, 'Export Rapports should be available');
|
|
console.log('✅ Export Rapports: Available');
|
|
});
|
|
|
|
test('Export - generateImprovementReport', () => {
|
|
assert.ok(SelectiveUtils.generateImprovementReport !== undefined, 'Export generateImprovementReport should be available');
|
|
console.log('✅ Export generateImprovementReport: Available');
|
|
});
|
|
|
|
|
|
// Test d'intégration général
|
|
test('Integration - Module health check', async () => {
|
|
try {
|
|
// Vérification exports
|
|
const exports = Object.keys(SelectiveUtils);
|
|
assert.ok(exports.length > 0, 'Module should export functions');
|
|
|
|
console.log(`✅ SelectiveUtils: ${exports.length} exports available`);
|
|
console.log('📋 Exports:', exports.join(', '));
|
|
|
|
} catch (error) {
|
|
console.error('❌ Integration test failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
}); |