- 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
393 lines
13 KiB
JavaScript
393 lines
13 KiB
JavaScript
// ========================================
|
|
// TESTS GÉNÉRÉS AUTOMATIQUEMENT - SelectiveCore
|
|
// Module: selective-enhancement/SelectiveCore.js
|
|
// Générés le: 2025-09-06T03:38:48.233Z
|
|
// ========================================
|
|
|
|
const assert = require('assert');
|
|
const { test, describe } = require('node:test');
|
|
const SelectiveCore = require('../../selective-enhancement/SelectiveCore.js');
|
|
|
|
describe('SelectiveCore - Tests automatiques', () => {
|
|
|
|
// Setup avant les tests
|
|
let testContext = {};
|
|
|
|
test('Module loading', () => {
|
|
assert.ok(SelectiveCore, 'Module should be loaded');
|
|
console.log('📦 Module SelectiveCore loaded successfully');
|
|
});
|
|
|
|
|
|
test('applySelectiveLayer - Async Operation', async () => {
|
|
const input = ["test_value", "test_value"];
|
|
|
|
try {
|
|
const startTime = Date.now();
|
|
const result = await SelectiveCore.applySelectiveLayer(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(`✅ applySelectiveLayer: Completed in ${duration}ms`);
|
|
|
|
} catch (error) {
|
|
console.error('❌ applySelectiveLayer: Async operation failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('applyTechnicalEnhancement - Async Operation', async () => {
|
|
const input = ["Test content for validation", "test_value"];
|
|
|
|
try {
|
|
const startTime = Date.now();
|
|
const result = await SelectiveCore.applyTechnicalEnhancement(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(`✅ applyTechnicalEnhancement: Completed in ${duration}ms`);
|
|
|
|
} catch (error) {
|
|
console.error('❌ applyTechnicalEnhancement: Async operation failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('applyTransitionEnhancement - Async Operation', async () => {
|
|
const input = ["Test content for validation", "test_value"];
|
|
|
|
try {
|
|
const startTime = Date.now();
|
|
const result = await SelectiveCore.applyTransitionEnhancement(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(`✅ applyTransitionEnhancement: Completed in ${duration}ms`);
|
|
|
|
} catch (error) {
|
|
console.error('❌ applyTransitionEnhancement: Async operation failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('applyStyleEnhancement - Async Operation', async () => {
|
|
const input = ["Test content for validation", "test_value"];
|
|
|
|
try {
|
|
const startTime = Date.now();
|
|
const result = await SelectiveCore.applyStyleEnhancement(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(`✅ applyStyleEnhancement: Completed in ${duration}ms`);
|
|
|
|
} catch (error) {
|
|
console.error('❌ applyStyleEnhancement: Async operation failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('applyAllSelectiveLayers - Async Operation', async () => {
|
|
const input = ["Test content for validation", "test_value"];
|
|
|
|
try {
|
|
const startTime = Date.now();
|
|
const result = await SelectiveCore.applyAllSelectiveLayers(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(`✅ applyAllSelectiveLayers: Completed in ${duration}ms`);
|
|
|
|
} catch (error) {
|
|
console.error('❌ applyAllSelectiveLayers: Async operation failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('analyzeEnhancementNeeds - Async Operation', async () => {
|
|
const input = ["Test content for validation", "test_value"];
|
|
|
|
try {
|
|
const startTime = Date.now();
|
|
const result = await SelectiveCore.analyzeEnhancementNeeds(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(`✅ analyzeEnhancementNeeds: Completed in ${duration}ms`);
|
|
|
|
} catch (error) {
|
|
console.error('❌ analyzeEnhancementNeeds: Async operation failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('selectOptimalLLM - Basic Function', () => {
|
|
const input = ["test_value", "test_value"];
|
|
|
|
try {
|
|
const result = SelectiveCore.selectOptimalLLM(input);
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(typeof result !== 'undefined', 'Result should be defined');
|
|
|
|
console.log('✅ selectOptimalLLM: Function executed successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ selectOptimalLLM: Function failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('countEnhancedElements - Basic Function', () => {
|
|
const input = ["test_value", "test_value"];
|
|
|
|
try {
|
|
const result = SelectiveCore.countEnhancedElements(input);
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(typeof result !== 'undefined', 'Result should be defined');
|
|
|
|
console.log('✅ countEnhancedElements: Function executed successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ countEnhancedElements: Function failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('assessTechnicalNeed - Basic Function', () => {
|
|
const input = ["Test content for validation", { mc0: "test keyword", t0: "Test title" }];
|
|
|
|
try {
|
|
const result = SelectiveCore.assessTechnicalNeed(input);
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(typeof result !== 'undefined', 'Result should be defined');
|
|
|
|
console.log('✅ assessTechnicalNeed: Function executed successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ assessTechnicalNeed: Function failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('assessTransitionNeed - Basic Function', () => {
|
|
const input = "Test content for validation";
|
|
|
|
try {
|
|
const result = SelectiveCore.assessTransitionNeed(input);
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(typeof result !== 'undefined', 'Result should be defined');
|
|
|
|
console.log('✅ assessTransitionNeed: Function executed successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ assessTransitionNeed: Function failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('assessStyleNeed - Basic Function', () => {
|
|
const input = ["Test content for validation", { nom: "Marc", style: "technique" }];
|
|
|
|
try {
|
|
const result = SelectiveCore.assessStyleNeed(input);
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(typeof result !== 'undefined', 'Result should be defined');
|
|
|
|
console.log('✅ assessStyleNeed: Function executed successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ assessStyleNeed: Function failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('switch - Basic Function', () => {
|
|
const input = undefined;
|
|
|
|
try {
|
|
const result = SelectiveCore.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('catch - Basic Function', () => {
|
|
const input = undefined;
|
|
|
|
try {
|
|
const result = SelectiveCore.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 = SelectiveCore.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('if - Basic Function', () => {
|
|
const input = undefined;
|
|
|
|
try {
|
|
const result = SelectiveCore.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('forEach - Basic Function', () => {
|
|
const input = undefined;
|
|
|
|
try {
|
|
const result = SelectiveCore.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 - applySelectiveLayer', () => {
|
|
assert.ok(SelectiveCore.applySelectiveLayer !== undefined, 'Export applySelectiveLayer should be available');
|
|
console.log('✅ Export applySelectiveLayer: Available');
|
|
});
|
|
|
|
test('Export - MAIN', () => {
|
|
assert.ok(SelectiveCore.MAIN !== undefined, 'Export MAIN should be available');
|
|
console.log('✅ Export MAIN: Available');
|
|
});
|
|
|
|
test('Export - ENTRY', () => {
|
|
assert.ok(SelectiveCore.ENTRY !== undefined, 'Export ENTRY should be available');
|
|
console.log('✅ Export ENTRY: Available');
|
|
});
|
|
|
|
test('Export - POINT', () => {
|
|
assert.ok(SelectiveCore.POINT !== undefined, 'Export POINT should be available');
|
|
console.log('✅ Export POINT: Available');
|
|
});
|
|
|
|
test('Export - MODULAIRE', () => {
|
|
assert.ok(SelectiveCore.MODULAIRE !== undefined, 'Export MODULAIRE should be available');
|
|
console.log('✅ Export MODULAIRE: Available');
|
|
});
|
|
|
|
test('Export - applyTechnicalEnhancement', () => {
|
|
assert.ok(SelectiveCore.applyTechnicalEnhancement !== undefined, 'Export applyTechnicalEnhancement should be available');
|
|
console.log('✅ Export applyTechnicalEnhancement: Available');
|
|
});
|
|
|
|
test('Export - applyTransitionEnhancement', () => {
|
|
assert.ok(SelectiveCore.applyTransitionEnhancement !== undefined, 'Export applyTransitionEnhancement should be available');
|
|
console.log('✅ Export applyTransitionEnhancement: Available');
|
|
});
|
|
|
|
test('Export - applyStyleEnhancement', () => {
|
|
assert.ok(SelectiveCore.applyStyleEnhancement !== undefined, 'Export applyStyleEnhancement should be available');
|
|
console.log('✅ Export applyStyleEnhancement: Available');
|
|
});
|
|
|
|
test('Export - applyAllSelectiveLayers', () => {
|
|
assert.ok(SelectiveCore.applyAllSelectiveLayers !== undefined, 'Export applyAllSelectiveLayers should be available');
|
|
console.log('✅ Export applyAllSelectiveLayers: Available');
|
|
});
|
|
|
|
test('Export - analyzeEnhancementNeeds', () => {
|
|
assert.ok(SelectiveCore.analyzeEnhancementNeeds !== undefined, 'Export analyzeEnhancementNeeds should be available');
|
|
console.log('✅ Export analyzeEnhancementNeeds: Available');
|
|
});
|
|
|
|
test('Export - selectOptimalLLM', () => {
|
|
assert.ok(SelectiveCore.selectOptimalLLM !== undefined, 'Export selectOptimalLLM should be available');
|
|
console.log('✅ Export selectOptimalLLM: Available');
|
|
});
|
|
|
|
|
|
// Test d'intégration général
|
|
test('Integration - Module health check', async () => {
|
|
try {
|
|
// Vérification exports
|
|
const exports = Object.keys(SelectiveCore);
|
|
assert.ok(exports.length > 0, 'Module should export functions');
|
|
|
|
console.log(`✅ SelectiveCore: ${exports.length} exports available`);
|
|
console.log('📋 Exports:', exports.join(', '));
|
|
|
|
} catch (error) {
|
|
console.error('❌ Integration test failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
}); |