333 lines
12 KiB
JavaScript
333 lines
12 KiB
JavaScript
// ========================================
|
|
// TESTS GÉNÉRÉS AUTOMATIQUEMENT - ContentGenerationAdversarial
|
|
// Module: adversarial-generation/ContentGenerationAdversarial.js
|
|
// Générés le: 2025-09-08T23:48:02.811Z
|
|
// ========================================
|
|
|
|
const assert = require('assert');
|
|
const { test, describe } = require('node:test');
|
|
const ContentGenerationAdversarial = require('../../adversarial-generation/ContentGenerationAdversarial.js');
|
|
const { AIContentValidator } = require('../validators/AIContentValidator');
|
|
|
|
describe('ContentGenerationAdversarial - Tests automatiques', () => {
|
|
|
|
// Setup avant les tests
|
|
let testContext = {};
|
|
|
|
test('Module loading', () => {
|
|
assert.ok(ContentGenerationAdversarial, 'Module should be loaded');
|
|
console.log('📦 Module ContentGenerationAdversarial loaded successfully');
|
|
});
|
|
|
|
|
|
test('generateWithAdversarialContext - Content Generation', async () => {
|
|
const mockInput = "test_value";
|
|
|
|
try {
|
|
const result = await ContentGenerationAdversarial.generateWithAdversarialContext(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('✅ generateWithAdversarialContext: Content generated successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ generateWithAdversarialContext: Generation failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('generateSimpleAdversarial - Content Generation', async () => {
|
|
const mockInput = ["test_value", { mc0: "test keyword", t0: "Test title" }, "test_value"];
|
|
|
|
try {
|
|
const result = await ContentGenerationAdversarial.generateSimpleAdversarial(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('✅ generateSimpleAdversarial: Content generated successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ generateSimpleAdversarial: Generation failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('generateAdvancedAdversarial - Content Generation', async () => {
|
|
const mockInput = ["test_value", { mc0: "test keyword", t0: "Test title" }, { test: true }];
|
|
|
|
try {
|
|
const result = await ContentGenerationAdversarial.generateAdvancedAdversarial(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('✅ generateAdvancedAdversarial: Content generated successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ generateAdvancedAdversarial: Generation failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('diagnosticAdversarialPipeline - Async Operation', async () => {
|
|
const input = ["test_value", { mc0: "test keyword", t0: "Test title" }, "test_value", "test_value", "test_value"];
|
|
|
|
try {
|
|
const startTime = Date.now();
|
|
const result = await ContentGenerationAdversarial.diagnosticAdversarialPipeline(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(`✅ diagnosticAdversarialPipeline: Completed in ${duration}ms`);
|
|
|
|
} catch (error) {
|
|
console.error('❌ diagnosticAdversarialPipeline: Async operation failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('compareAdversarialStrategies - Async Operation', async () => {
|
|
const input = ["test_value", { mc0: "test keyword", t0: "Test title" }, "test_value", "test_value", "test_value", "test_value"];
|
|
|
|
try {
|
|
const startTime = Date.now();
|
|
const result = await ContentGenerationAdversarial.compareAdversarialStrategies(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(`✅ compareAdversarialStrategies: Completed in ${duration}ms`);
|
|
|
|
} catch (error) {
|
|
console.error('❌ compareAdversarialStrategies: Async operation failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('calculateAdversarialEffectiveness - Basic Function', () => {
|
|
const input = ["test_value", "test_value", "Test content for validation"];
|
|
|
|
try {
|
|
const result = ContentGenerationAdversarial.calculateAdversarialEffectiveness(input);
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(typeof result !== 'undefined', 'Result should be defined');
|
|
|
|
console.log('✅ calculateAdversarialEffectiveness: Function executed successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ calculateAdversarialEffectiveness: Function failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('analyzeDiversityScore - Basic Function', () => {
|
|
const input = "Test content for validation";
|
|
|
|
try {
|
|
const result = ContentGenerationAdversarial.analyzeDiversityScore(input);
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(typeof result !== 'undefined', 'Result should be defined');
|
|
|
|
console.log('✅ analyzeDiversityScore: Function executed successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ analyzeDiversityScore: Function failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('getAdversarialDetectorInfo - Basic Function', () => {
|
|
const input = undefined;
|
|
|
|
try {
|
|
const result = ContentGenerationAdversarial.getAdversarialDetectorInfo(input);
|
|
|
|
// Validations de base
|
|
assert.ok(result !== undefined, 'Should return a result');
|
|
assert.ok(typeof result !== 'undefined', 'Result should be defined');
|
|
|
|
console.log('✅ getAdversarialDetectorInfo: Function executed successfully');
|
|
|
|
} catch (error) {
|
|
console.error('❌ getAdversarialDetectorInfo: Function failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
|
|
test('if - Basic Function', () => {
|
|
const input = undefined;
|
|
|
|
try {
|
|
const result = ContentGenerationAdversarial.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 = ContentGenerationAdversarial.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 = ContentGenerationAdversarial.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 = ContentGenerationAdversarial.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 - generateWithAdversarialContext', () => {
|
|
assert.ok(ContentGenerationAdversarial.generateWithAdversarialContext !== undefined, 'Export generateWithAdversarialContext should be available');
|
|
console.log('✅ Export generateWithAdversarialContext: Available');
|
|
});
|
|
|
|
test('Export - MAIN', () => {
|
|
assert.ok(ContentGenerationAdversarial.MAIN !== undefined, 'Export MAIN should be available');
|
|
console.log('✅ Export MAIN: Available');
|
|
});
|
|
|
|
test('Export - ENTRY', () => {
|
|
assert.ok(ContentGenerationAdversarial.ENTRY !== undefined, 'Export ENTRY should be available');
|
|
console.log('✅ Export ENTRY: Available');
|
|
});
|
|
|
|
test('Export - POINT', () => {
|
|
assert.ok(ContentGenerationAdversarial.POINT !== undefined, 'Export POINT should be available');
|
|
console.log('✅ Export POINT: Available');
|
|
});
|
|
|
|
test('Export - generateSimpleAdversarial', () => {
|
|
assert.ok(ContentGenerationAdversarial.generateSimpleAdversarial !== undefined, 'Export generateSimpleAdversarial should be available');
|
|
console.log('✅ Export generateSimpleAdversarial: Available');
|
|
});
|
|
|
|
test('Export - generateAdvancedAdversarial', () => {
|
|
assert.ok(ContentGenerationAdversarial.generateAdvancedAdversarial !== undefined, 'Export generateAdvancedAdversarial should be available');
|
|
console.log('✅ Export generateAdvancedAdversarial: Available');
|
|
});
|
|
|
|
test('Export - diagnosticAdversarialPipeline', () => {
|
|
assert.ok(ContentGenerationAdversarial.diagnosticAdversarialPipeline !== undefined, 'Export diagnosticAdversarialPipeline should be available');
|
|
console.log('✅ Export diagnosticAdversarialPipeline: Available');
|
|
});
|
|
|
|
test('Export - compareAdversarialStrategies', () => {
|
|
assert.ok(ContentGenerationAdversarial.compareAdversarialStrategies !== undefined, 'Export compareAdversarialStrategies should be available');
|
|
console.log('✅ Export compareAdversarialStrategies: Available');
|
|
});
|
|
|
|
test('Export - getAdversarialDetectorInfo', () => {
|
|
assert.ok(ContentGenerationAdversarial.getAdversarialDetectorInfo !== undefined, 'Export getAdversarialDetectorInfo should be available');
|
|
console.log('✅ Export getAdversarialDetectorInfo: Available');
|
|
});
|
|
|
|
test('Export - calculateAdversarialEffectiveness', () => {
|
|
assert.ok(ContentGenerationAdversarial.calculateAdversarialEffectiveness !== undefined, 'Export calculateAdversarialEffectiveness should be available');
|
|
console.log('✅ Export calculateAdversarialEffectiveness: Available');
|
|
});
|
|
|
|
|
|
// Test d'intégration général
|
|
test('Integration - Module health check', async () => {
|
|
try {
|
|
// Vérification exports
|
|
const exports = Object.keys(ContentGenerationAdversarial);
|
|
assert.ok(exports.length > 0, 'Module should export functions');
|
|
|
|
console.log(`✅ ContentGenerationAdversarial: ${exports.length} exports available`);
|
|
console.log('📋 Exports:', exports.join(', '));
|
|
|
|
} catch (error) {
|
|
console.error('❌ Integration test failed:', error.message);
|
|
throw error;
|
|
}
|
|
});
|
|
}); |