seo-generator-server/tests/systematic/generated/AdversarialPromptEngine.generated.test.js
Trouve Alexis 870cfb0340 [200~add step-by-step versioning system with Google Sheets integration
- 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
2025-09-06 16:38:20 +08:00

319 lines
12 KiB
JavaScript

// ========================================
// TESTS GÉNÉRÉS AUTOMATIQUEMENT - AdversarialPromptEngine
// Module: adversarial-generation/AdversarialPromptEngine.js
// Générés le: 2025-09-06T03:38:48.027Z
// ========================================
const assert = require('assert');
const { test, describe } = require('node:test');
const AdversarialPromptEngine = require('../../adversarial-generation/AdversarialPromptEngine.js');
const { AIContentValidator } = require('../validators/AIContentValidator');
describe('AdversarialPromptEngine - Tests automatiques', () => {
// Setup avant les tests
let testContext = {};
test('Module loading', () => {
assert.ok(AdversarialPromptEngine, 'Module should be loaded');
console.log('📦 Module AdversarialPromptEngine loaded successfully');
});
test('createAdversarialPrompt - Content Generation', async () => {
const mockInput = ["test_value", "test_value"];
try {
const result = await AdversarialPromptEngine.createAdversarialPrompt(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('✅ createAdversarialPrompt: Content generated successfully');
} catch (error) {
console.error('❌ createAdversarialPrompt: Generation failed:', error.message);
throw error;
}
});
test('buildAdversarialInstructions - Content Generation', async () => {
const mockInput = ["test_value", "test_value"];
try {
const result = await AdversarialPromptEngine.buildAdversarialInstructions(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('✅ buildAdversarialInstructions: Content generated successfully');
} catch (error) {
console.error('❌ buildAdversarialInstructions: Generation failed:', error.message);
throw error;
}
});
test('selectActiveRules - Basic Function', () => {
const input = ["test_value", "test_value"];
try {
const result = AdversarialPromptEngine.selectActiveRules(input);
// Validations de base
assert.ok(result !== undefined, 'Should return a result');
assert.ok(typeof result !== 'undefined', 'Result should be defined');
console.log('✅ selectActiveRules: Function executed successfully');
} catch (error) {
console.error('❌ selectActiveRules: Function failed:', error.message);
throw error;
}
});
test('generatePersonalityAdaptations - Content Generation', async () => {
const mockInput = [{ nom: "Marc", style: "technique" }, "test_value"];
try {
const result = await AdversarialPromptEngine.generatePersonalityAdaptations(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('✅ generatePersonalityAdaptations: Content generated successfully');
} catch (error) {
console.error('❌ generatePersonalityAdaptations: Generation failed:', error.message);
throw error;
}
});
test('generateContextualInstructions - Content Generation', async () => {
const mockInput = [{ mc0: "test keyword", t0: "Test title" }, "test_value"];
try {
const result = await AdversarialPromptEngine.generateContextualInstructions(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('✅ generateContextualInstructions: Content generated successfully');
} catch (error) {
console.error('❌ generateContextualInstructions: Generation failed:', error.message);
throw error;
}
});
test('assembleEnhancedPrompt - Basic Function', () => {
const input = ["test_value", "test_value", "test_value"];
try {
const result = AdversarialPromptEngine.assembleEnhancedPrompt(input);
// Validations de base
assert.ok(result !== undefined, 'Should return a result');
assert.ok(typeof result !== 'undefined', 'Result should be defined');
console.log('✅ assembleEnhancedPrompt: Function executed successfully');
} catch (error) {
console.error('❌ assembleEnhancedPrompt: Function failed:', error.message);
throw error;
}
});
test('analyzePromptEffectiveness - Basic Function', () => {
const input = ["test_value", "test_value", "test_value"];
try {
const result = AdversarialPromptEngine.analyzePromptEffectiveness(input);
// Validations de base
assert.ok(result !== undefined, 'Should return a result');
assert.ok(typeof result !== 'undefined', 'Result should be defined');
console.log('✅ analyzePromptEffectiveness: Function executed successfully');
} catch (error) {
console.error('❌ analyzePromptEffectiveness: Function failed:', error.message);
throw error;
}
});
test('analyzeGeneratedContent - Basic Function', () => {
const input = "Test content for validation";
try {
const result = AdversarialPromptEngine.analyzeGeneratedContent(input);
// Validations de base
assert.ok(result !== undefined, 'Should return a result');
assert.ok(typeof result !== 'undefined', 'Result should be defined');
console.log('✅ analyzeGeneratedContent: Function executed successfully');
} catch (error) {
console.error('❌ analyzeGeneratedContent: Function failed:', error.message);
throw error;
}
});
test('getSupportedDetectors - Basic Function', () => {
const input = undefined;
try {
const result = AdversarialPromptEngine.getSupportedDetectors(input);
// Validations de base
assert.ok(result !== undefined, 'Should return a result');
assert.ok(typeof result !== 'undefined', 'Result should be defined');
console.log('✅ getSupportedDetectors: Function executed successfully');
} catch (error) {
console.error('❌ getSupportedDetectors: Function failed:', error.message);
throw error;
}
});
test('if - Basic Function', () => {
const input = undefined;
try {
const result = AdversarialPromptEngine.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 = AdversarialPromptEngine.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('Export - createAdversarialPrompt', () => {
assert.ok(AdversarialPromptEngine.createAdversarialPrompt !== undefined, 'Export createAdversarialPrompt should be available');
console.log('✅ Export createAdversarialPrompt: Available');
});
test('Export - MAIN', () => {
assert.ok(AdversarialPromptEngine.MAIN !== undefined, 'Export MAIN should be available');
console.log('✅ Export MAIN: Available');
});
test('Export - ENTRY', () => {
assert.ok(AdversarialPromptEngine.ENTRY !== undefined, 'Export ENTRY should be available');
console.log('✅ Export ENTRY: Available');
});
test('Export - POINT', () => {
assert.ok(AdversarialPromptEngine.POINT !== undefined, 'Export POINT should be available');
console.log('✅ Export POINT: Available');
});
test('Export - buildAdversarialInstructions', () => {
assert.ok(AdversarialPromptEngine.buildAdversarialInstructions !== undefined, 'Export buildAdversarialInstructions should be available');
console.log('✅ Export buildAdversarialInstructions: Available');
});
test('Export - analyzePromptEffectiveness', () => {
assert.ok(AdversarialPromptEngine.analyzePromptEffectiveness !== undefined, 'Export analyzePromptEffectiveness should be available');
console.log('✅ Export analyzePromptEffectiveness: Available');
});
test('Export - analyzeGeneratedContent', () => {
assert.ok(AdversarialPromptEngine.analyzeGeneratedContent !== undefined, 'Export analyzeGeneratedContent should be available');
console.log('✅ Export analyzeGeneratedContent: Available');
});
test('Export - getSupportedDetectors', () => {
assert.ok(AdversarialPromptEngine.getSupportedDetectors !== undefined, 'Export getSupportedDetectors should be available');
console.log('✅ Export getSupportedDetectors: Available');
});
test('Export - ADVERSARIAL_INSTRUCTIONS', () => {
assert.ok(AdversarialPromptEngine.ADVERSARIAL_INSTRUCTIONS !== undefined, 'Export ADVERSARIAL_INSTRUCTIONS should be available');
console.log('✅ Export ADVERSARIAL_INSTRUCTIONS: Available');
});
test('Export - ELEMENT_SPECIFIC_INSTRUCTIONS', () => {
assert.ok(AdversarialPromptEngine.ELEMENT_SPECIFIC_INSTRUCTIONS !== undefined, 'Export ELEMENT_SPECIFIC_INSTRUCTIONS should be available');
console.log('✅ Export ELEMENT_SPECIFIC_INSTRUCTIONS: Available');
});
// Test d'intégration général
test('Integration - Module health check', async () => {
try {
// Vérification exports
const exports = Object.keys(AdversarialPromptEngine);
assert.ok(exports.length > 0, 'Module should export functions');
console.log(`✅ AdversarialPromptEngine: ${exports.length} exports available`);
console.log('📋 Exports:', exports.join(', '));
} catch (error) {
console.error('❌ Integration test failed:', error.message);
throw error;
}
});
});