481 lines
17 KiB
JavaScript
481 lines
17 KiB
JavaScript
// ========================================
|
|
// TESTS GÉNÉRÉS AUTOMATIQUEMENT - AdversarialInitialGeneration
|
|
// Module: adversarial-generation/AdversarialInitialGeneration.js
|
|
// Générés le: 2025-09-06T12:40:35.935Z
|
|
// ========================================
|
|
|
|
const assert = require('assert');
|
|
const { test, describe } = require('node:test');
|
|
const AdversarialInitialGeneration = require('../../adversarial-generation/AdversarialInitialGeneration.js');
|
|
const { AIContentValidator } = require('../validators/AIContentValidator');
|
|
|
|
describe('AdversarialInitialGeneration - Tests automatiques', () => {
|
|
|
|
// Setup avant les tests
|
|
let testContext = {};
|
|
|
|
test('Module loading', () => {
|
|
assert.ok(AdversarialInitialGeneration, 'Module should be loaded');
|
|
console.log('📦 Module AdversarialInitialGeneration loaded successfully');
|
|
});
|
|
|
|
|
|
test('generateInitialContentAdversarial - Content Generation', async () => {
|
|
const mockInput = "test_value";
|
|
|
|
try {
|
|
const result = await AdversarialInitialGeneration.generateInitialContentAdversarial(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('✅ generateInitialContentAdversarial: Content generated successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ generateInitialContentAdversarial: Generation failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('generateNormalElementsAdversarial - Content Generation', async () => {
|
|
const mockInput = ["test_value", { mc0: "test keyword", t0: "Test title" }, "test_value", "test_value"];
|
|
|
|
try {
|
|
const result = await AdversarialInitialGeneration.generateNormalElementsAdversarial(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('✅ generateNormalElementsAdversarial: Content generated successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ generateNormalElementsAdversarial: Generation failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('generateFAQPairsAdversarial - Content Generation', async () => {
|
|
const mockInput = ["test_value", { mc0: "test keyword", t0: "Test title" }, "test_value", "test_value"];
|
|
|
|
try {
|
|
const result = await AdversarialInitialGeneration.generateFAQPairsAdversarial(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('✅ generateFAQPairsAdversarial: Content generated successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ generateFAQPairsAdversarial: Generation failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('createBatchPrompt - Content Generation', async () => {
|
|
const mockInput = ["test_value", { mc0: "test keyword", t0: "Test title" }];
|
|
|
|
try {
|
|
const result = await AdversarialInitialGeneration.createBatchPrompt(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('✅ createBatchPrompt: Content generated successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ createBatchPrompt: Generation failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('parseBatchResponse - Basic Function', () => {
|
|
const input = ["test_value", "test_value"];
|
|
|
|
try {
|
|
const result = AdversarialInitialGeneration.parseBatchResponse(input);
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(typeof result !== 'undefined', 'Result should be defined');
|
|
|
|
console.log('✅ parseBatchResponse: Function executed successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ parseBatchResponse: Function failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('createFAQPairsPrompt - Content Generation', async () => {
|
|
const mockInput = ["test_value", { mc0: "test keyword", t0: "Test title" }];
|
|
|
|
try {
|
|
const result = await AdversarialInitialGeneration.createFAQPairsPrompt(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('✅ createFAQPairsPrompt: Content generated successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ createFAQPairsPrompt: Generation failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('parseFAQResponse - Basic Function', () => {
|
|
const input = ["test_value", "test_value"];
|
|
|
|
try {
|
|
const result = AdversarialInitialGeneration.parseFAQResponse(input);
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(typeof result !== 'undefined', 'Result should be defined');
|
|
|
|
console.log('✅ parseFAQResponse: Function executed successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ parseFAQResponse: Function failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('collectElementsInXMLOrder - Basic Function', () => {
|
|
const input = "test_value";
|
|
|
|
try {
|
|
const result = AdversarialInitialGeneration.collectElementsInXMLOrder(input);
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(typeof result !== 'undefined', 'Result should be defined');
|
|
|
|
console.log('✅ collectElementsInXMLOrder: Function executed successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ collectElementsInXMLOrder: Function failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('separateElementTypes - Basic Function', () => {
|
|
const input = "test_value";
|
|
|
|
try {
|
|
const result = AdversarialInitialGeneration.separateElementTypes(input);
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(typeof result !== 'undefined', 'Result should be defined');
|
|
|
|
console.log('✅ separateElementTypes: Function executed successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ separateElementTypes: Function failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('getElementDescription - Basic Function', () => {
|
|
const input = "test_value";
|
|
|
|
try {
|
|
const result = AdversarialInitialGeneration.getElementDescription(input);
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(typeof result !== 'undefined', 'Result should be defined');
|
|
|
|
console.log('✅ getElementDescription: Function executed successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ getElementDescription: Function failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('cleanGeneratedContent - Basic Function', () => {
|
|
const input = "Test content for validation";
|
|
|
|
try {
|
|
const result = AdversarialInitialGeneration.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('chunkArray - Basic Function', () => {
|
|
const input = ["test_value", "test_value"];
|
|
|
|
try {
|
|
const result = AdversarialInitialGeneration.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('sleep - Basic Function', () => {
|
|
const input = "test_value";
|
|
|
|
try {
|
|
const result = AdversarialInitialGeneration.sleep(input);
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(typeof result !== 'undefined', 'Result should be defined');
|
|
|
|
console.log('✅ sleep: Function executed successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ sleep: Function failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('getElementTypeFromChunk - Basic Function', () => {
|
|
const input = "test_value";
|
|
|
|
try {
|
|
const result = AdversarialInitialGeneration.getElementTypeFromChunk(input);
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(typeof result !== 'undefined', 'Result should be defined');
|
|
|
|
console.log('✅ getElementTypeFromChunk: Function executed successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ getElementTypeFromChunk: Function failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('if - Basic Function', () => {
|
|
const input = undefined;
|
|
|
|
try {
|
|
const result = AdversarialInitialGeneration.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 = AdversarialInitialGeneration.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 = AdversarialInitialGeneration.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('forEach - Basic Function', () => {
|
|
const input = undefined;
|
|
|
|
try {
|
|
const result = AdversarialInitialGeneration.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('switch - Basic Function', () => {
|
|
const input = undefined;
|
|
|
|
try {
|
|
const result = AdversarialInitialGeneration.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('Export - generateInitialContentAdversarial', () => {
|
|
assert.ok(AdversarialInitialGeneration.generateInitialContentAdversarial !== undefined, 'Export generateInitialContentAdversarial should be available');
|
|
console.log('✅ Export generateInitialContentAdversarial: Available');
|
|
});
|
|
|
|
test('Export - MAIN', () => {
|
|
assert.ok(AdversarialInitialGeneration.MAIN !== undefined, 'Export MAIN should be available');
|
|
console.log('✅ Export MAIN: Available');
|
|
});
|
|
|
|
test('Export - ENTRY', () => {
|
|
assert.ok(AdversarialInitialGeneration.ENTRY !== undefined, 'Export ENTRY should be available');
|
|
console.log('✅ Export ENTRY: Available');
|
|
});
|
|
|
|
test('Export - POINT', () => {
|
|
assert.ok(AdversarialInitialGeneration.POINT !== undefined, 'Export POINT should be available');
|
|
console.log('✅ Export POINT: Available');
|
|
});
|
|
|
|
test('Export - ADVERSARIAL', () => {
|
|
assert.ok(AdversarialInitialGeneration.ADVERSARIAL !== undefined, 'Export ADVERSARIAL should be available');
|
|
console.log('✅ Export ADVERSARIAL: Available');
|
|
});
|
|
|
|
test('Export - generateNormalElementsAdversarial', () => {
|
|
assert.ok(AdversarialInitialGeneration.generateNormalElementsAdversarial !== undefined, 'Export generateNormalElementsAdversarial should be available');
|
|
console.log('✅ Export generateNormalElementsAdversarial: Available');
|
|
});
|
|
|
|
test('Export - generateFAQPairsAdversarial', () => {
|
|
assert.ok(AdversarialInitialGeneration.generateFAQPairsAdversarial !== undefined, 'Export generateFAQPairsAdversarial should be available');
|
|
console.log('✅ Export generateFAQPairsAdversarial: Available');
|
|
});
|
|
|
|
test('Export - createBatchPrompt', () => {
|
|
assert.ok(AdversarialInitialGeneration.createBatchPrompt !== undefined, 'Export createBatchPrompt should be available');
|
|
console.log('✅ Export createBatchPrompt: Available');
|
|
});
|
|
|
|
test('Export - parseBatchResponse', () => {
|
|
assert.ok(AdversarialInitialGeneration.parseBatchResponse !== undefined, 'Export parseBatchResponse should be available');
|
|
console.log('✅ Export parseBatchResponse: Available');
|
|
});
|
|
|
|
test('Export - collectElementsInXMLOrder', () => {
|
|
assert.ok(AdversarialInitialGeneration.collectElementsInXMLOrder !== undefined, 'Export collectElementsInXMLOrder should be available');
|
|
console.log('✅ Export collectElementsInXMLOrder: Available');
|
|
});
|
|
|
|
test('Export - separateElementTypes', () => {
|
|
assert.ok(AdversarialInitialGeneration.separateElementTypes !== undefined, 'Export separateElementTypes should be available');
|
|
console.log('✅ Export separateElementTypes: Available');
|
|
});
|
|
|
|
test('Export - getElementTypeFromChunk', () => {
|
|
assert.ok(AdversarialInitialGeneration.getElementTypeFromChunk !== undefined, 'Export getElementTypeFromChunk should be available');
|
|
console.log('✅ Export getElementTypeFromChunk: Available');
|
|
});
|
|
|
|
|
|
// Test d'intégration général
|
|
test('Integration - Module health check', async () => {
|
|
try {
|
|
// Vérification exports
|
|
const exports = Object.keys(AdversarialInitialGeneration);
|
|
assert.ok(exports.length > 0, 'Module should export functions');
|
|
|
|
console.log(`✅ AdversarialInitialGeneration: ${exports.length} exports available`);
|
|
console.log('📋 Exports:', exports.join(', '));
|
|
|
|
} catch (error) {
|
|
console.error('❌ Integration test failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
}); |