- 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
384 lines
13 KiB
JavaScript
384 lines
13 KiB
JavaScript
// ========================================
|
|
// TESTS GÉNÉRÉS AUTOMATIQUEMENT - BrainConfig
|
|
// Module: BrainConfig.js
|
|
// Générés le: 2025-09-06T03:38:47.921Z
|
|
// ========================================
|
|
|
|
const assert = require('assert');
|
|
const { test, describe } = require('node:test');
|
|
const BrainConfig = require('../../BrainConfig.js');
|
|
const { AIContentValidator } = require('../validators/AIContentValidator');
|
|
|
|
describe('BrainConfig - Tests automatiques', () => {
|
|
|
|
// Setup avant les tests
|
|
let testContext = {};
|
|
|
|
test('Module loading', () => {
|
|
assert.ok(BrainConfig, 'Module should be loaded');
|
|
console.log('📦 Module BrainConfig loaded successfully');
|
|
});
|
|
|
|
|
|
test('getBrainConfig - Async Operation', async () => {
|
|
const input = { mc0: "test keyword", t0: "Test title" };
|
|
|
|
try {
|
|
const startTime = Date.now();
|
|
const result = await BrainConfig.getBrainConfig(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(`✅ getBrainConfig: Completed in ${duration}ms`);
|
|
|
|
} catch (error) {
|
|
console.error('❌ getBrainConfig: Async operation failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('readInstructionsData - Async Operation', async () => {
|
|
const input = "test_value";
|
|
|
|
try {
|
|
const startTime = Date.now();
|
|
const result = await BrainConfig.readInstructionsData(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(`✅ readInstructionsData: Completed in ${duration}ms`);
|
|
|
|
} catch (error) {
|
|
console.error('❌ readInstructionsData: Async operation failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('getPersonalities - Async Operation', async () => {
|
|
const input = undefined;
|
|
|
|
try {
|
|
const startTime = Date.now();
|
|
const result = await BrainConfig.getPersonalities(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(`✅ getPersonalities: Completed in ${duration}ms`);
|
|
|
|
} catch (error) {
|
|
console.error('❌ getPersonalities: Async operation failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('selectMultiplePersonalitiesWithAI - Async Operation', async () => {
|
|
const input = ["test_value", "test_value", "test_value"];
|
|
|
|
try {
|
|
const startTime = Date.now();
|
|
const result = await BrainConfig.selectMultiplePersonalitiesWithAI(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(`✅ selectMultiplePersonalitiesWithAI: Completed in ${duration}ms`);
|
|
|
|
} catch (error) {
|
|
console.error('❌ selectMultiplePersonalitiesWithAI: Async operation failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('selectPersonalityWithAI - Async Operation', async () => {
|
|
const input = ["test_value", "test_value", "test_value"];
|
|
|
|
try {
|
|
const startTime = Date.now();
|
|
const result = await BrainConfig.selectPersonalityWithAI(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(`✅ selectPersonalityWithAI: Completed in ${duration}ms`);
|
|
|
|
} catch (error) {
|
|
console.error('❌ selectPersonalityWithAI: Async operation failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('createSampleDataFiles - Content Generation', async () => {
|
|
const mockInput = undefined;
|
|
|
|
try {
|
|
const result = await BrainConfig.createSampleDataFiles(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('✅ createSampleDataFiles: Content generated successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ createSampleDataFiles: Generation failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('parseCSVField - Basic Function', () => {
|
|
const input = "test_value";
|
|
|
|
try {
|
|
const result = BrainConfig.parseCSVField(input);
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(typeof result !== 'undefined', 'Result should be defined');
|
|
|
|
console.log('✅ parseCSVField: Function executed successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ parseCSVField: Function failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('selectRandomPersonalities - Basic Function', () => {
|
|
const input = ["test_value", "test_value"];
|
|
|
|
try {
|
|
const result = BrainConfig.selectRandomPersonalities(input);
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(typeof result !== 'undefined', 'Result should be defined');
|
|
|
|
console.log('✅ selectRandomPersonalities: Function executed successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ selectRandomPersonalities: Function failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('createDefaultXMLTemplate - Content Generation', async () => {
|
|
const mockInput = undefined;
|
|
|
|
try {
|
|
const result = await BrainConfig.createDefaultXMLTemplate(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('✅ createDefaultXMLTemplate: Content generated successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ createDefaultXMLTemplate: Generation failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('if - Basic Function', () => {
|
|
const input = undefined;
|
|
|
|
try {
|
|
const result = BrainConfig.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('catch - Basic Function', () => {
|
|
const input = undefined;
|
|
|
|
try {
|
|
const result = BrainConfig.catch(input);
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(typeof result !== 'undefined', 'Result should be defined');
|
|
|
|
console.log('✅ catch: Function executed successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ catch: Function failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('for - Basic Function', () => {
|
|
const input = undefined;
|
|
|
|
try {
|
|
const result = BrainConfig.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('while - Basic Function', () => {
|
|
const input = undefined;
|
|
|
|
try {
|
|
const result = BrainConfig.while(input);
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(typeof result !== 'undefined', 'Result should be defined');
|
|
|
|
console.log('✅ while: Function executed successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ while: Function failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('Export - getBrainConfig', () => {
|
|
assert.ok(BrainConfig.getBrainConfig !== undefined, 'Export getBrainConfig should be available');
|
|
console.log('✅ Export getBrainConfig: Available');
|
|
});
|
|
|
|
test('Export - getPersonalities', () => {
|
|
assert.ok(BrainConfig.getPersonalities !== undefined, 'Export getPersonalities should be available');
|
|
console.log('✅ Export getPersonalities: Available');
|
|
});
|
|
|
|
test('Export - selectPersonalityWithAI', () => {
|
|
assert.ok(BrainConfig.selectPersonalityWithAI !== undefined, 'Export selectPersonalityWithAI should be available');
|
|
console.log('✅ Export selectPersonalityWithAI: Available');
|
|
});
|
|
|
|
test('Export - selectMultiplePersonalitiesWithAI', () => {
|
|
assert.ok(BrainConfig.selectMultiplePersonalitiesWithAI !== undefined, 'Export selectMultiplePersonalitiesWithAI should be available');
|
|
console.log('✅ Export selectMultiplePersonalitiesWithAI: Available');
|
|
});
|
|
|
|
test('Export - NOUVEAU', () => {
|
|
assert.ok(BrainConfig.NOUVEAU !== undefined, 'Export NOUVEAU should be available');
|
|
console.log('✅ Export NOUVEAU: Available');
|
|
});
|
|
|
|
test('Export - de', () => {
|
|
assert.ok(BrainConfig.de !== undefined, 'Export de should be available');
|
|
console.log('✅ Export de: Available');
|
|
});
|
|
|
|
test('Export - la', () => {
|
|
assert.ok(BrainConfig.la !== undefined, 'Export la should be available');
|
|
console.log('✅ Export la: Available');
|
|
});
|
|
|
|
test('Export - fonction', () => {
|
|
assert.ok(BrainConfig.fonction !== undefined, 'Export fonction should be available');
|
|
console.log('✅ Export fonction: Available');
|
|
});
|
|
|
|
test('Export - multi', () => {
|
|
assert.ok(BrainConfig.multi !== undefined, 'Export multi should be available');
|
|
console.log('✅ Export multi: Available');
|
|
});
|
|
|
|
test('Export - personnalit', () => {
|
|
assert.ok(BrainConfig.personnalit !== undefined, 'Export personnalit should be available');
|
|
console.log('✅ Export personnalit: Available');
|
|
});
|
|
|
|
test('Export - s', () => {
|
|
assert.ok(BrainConfig.s !== undefined, 'Export s should be available');
|
|
console.log('✅ Export s: Available');
|
|
});
|
|
|
|
test('Export - selectRandomPersonalities', () => {
|
|
assert.ok(BrainConfig.selectRandomPersonalities !== undefined, 'Export selectRandomPersonalities should be available');
|
|
console.log('✅ Export selectRandomPersonalities: Available');
|
|
});
|
|
|
|
test('Export - parseCSVField', () => {
|
|
assert.ok(BrainConfig.parseCSVField !== undefined, 'Export parseCSVField should be available');
|
|
console.log('✅ Export parseCSVField: Available');
|
|
});
|
|
|
|
test('Export - readInstructionsData', () => {
|
|
assert.ok(BrainConfig.readInstructionsData !== undefined, 'Export readInstructionsData should be available');
|
|
console.log('✅ Export readInstructionsData: Available');
|
|
});
|
|
|
|
test('Export - createSampleDataFiles', () => {
|
|
assert.ok(BrainConfig.createSampleDataFiles !== undefined, 'Export createSampleDataFiles should be available');
|
|
console.log('✅ Export createSampleDataFiles: Available');
|
|
});
|
|
|
|
test('Export - createDefaultXMLTemplate', () => {
|
|
assert.ok(BrainConfig.createDefaultXMLTemplate !== undefined, 'Export createDefaultXMLTemplate should be available');
|
|
console.log('✅ Export createDefaultXMLTemplate: Available');
|
|
});
|
|
|
|
test('Export - CONFIG', () => {
|
|
assert.ok(BrainConfig.CONFIG !== undefined, 'Export CONFIG should be available');
|
|
console.log('✅ Export CONFIG: Available');
|
|
});
|
|
|
|
|
|
// Test d'intégration général
|
|
test('Integration - Module health check', async () => {
|
|
try {
|
|
// Vérification exports
|
|
const exports = Object.keys(BrainConfig);
|
|
assert.ok(exports.length > 0, 'Module should export functions');
|
|
|
|
console.log(`✅ BrainConfig: ${exports.length} exports available`);
|
|
console.log('📋 Exports:', exports.join(', '));
|
|
|
|
} catch (error) {
|
|
console.error('❌ Integration test failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
}); |