seo-generator-server/tests/systematic/generated/InitialGeneration.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

453 lines
15 KiB
JavaScript

// ========================================
// TESTS GÉNÉRÉS AUTOMATIQUEMENT - InitialGeneration
// Module: generation/InitialGeneration.js
// Générés le: 2025-09-06T03:38:48.089Z
// ========================================
const assert = require('assert');
const { test, describe } = require('node:test');
const InitialGeneration = require('../../generation/InitialGeneration.js');
const { AIContentValidator } = require('../validators/AIContentValidator');
describe('InitialGeneration - Tests automatiques', () => {
// Setup avant les tests
let testContext = {};
test('Module loading', () => {
assert.ok(InitialGeneration, 'Module should be loaded');
console.log('📦 Module InitialGeneration loaded successfully');
});
test('generateInitialContent - Content Generation', async () => {
const mockInput = "test_value";
try {
const result = await InitialGeneration.generateInitialContent(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('✅ generateInitialContent: Content generated successfully');
} catch (error) {
console.error('❌ generateInitialContent: Generation failed:', error.message);
throw error;
}
});
test('generateNormalElements - Content Generation', async () => {
const mockInput = ["test_value", { mc0: "test keyword", t0: "Test title" }];
try {
const result = await InitialGeneration.generateNormalElements(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('✅ generateNormalElements: Content generated successfully');
} catch (error) {
console.error('❌ generateNormalElements: Generation failed:', error.message);
throw error;
}
});
test('generateFAQPairs - Content Generation', async () => {
const mockInput = ["test_value", { mc0: "test keyword", t0: "Test title" }];
try {
const result = await InitialGeneration.generateFAQPairs(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('✅ generateFAQPairs: Content generated successfully');
} catch (error) {
console.error('❌ generateFAQPairs: 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 InitialGeneration.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 = InitialGeneration.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 InitialGeneration.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 = InitialGeneration.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 = InitialGeneration.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 = InitialGeneration.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 = InitialGeneration.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 = InitialGeneration.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 = InitialGeneration.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 = InitialGeneration.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('if - Basic Function', () => {
const input = undefined;
try {
const result = InitialGeneration.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 = InitialGeneration.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 = InitialGeneration.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 = InitialGeneration.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 = InitialGeneration.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 - generateInitialContent', () => {
assert.ok(InitialGeneration.generateInitialContent !== undefined, 'Export generateInitialContent should be available');
console.log('✅ Export generateInitialContent: Available');
});
test('Export - MAIN', () => {
assert.ok(InitialGeneration.MAIN !== undefined, 'Export MAIN should be available');
console.log('✅ Export MAIN: Available');
});
test('Export - ENTRY', () => {
assert.ok(InitialGeneration.ENTRY !== undefined, 'Export ENTRY should be available');
console.log('✅ Export ENTRY: Available');
});
test('Export - POINT', () => {
assert.ok(InitialGeneration.POINT !== undefined, 'Export POINT should be available');
console.log('✅ Export POINT: Available');
});
test('Export - generateNormalElements', () => {
assert.ok(InitialGeneration.generateNormalElements !== undefined, 'Export generateNormalElements should be available');
console.log('✅ Export generateNormalElements: Available');
});
test('Export - generateFAQPairs', () => {
assert.ok(InitialGeneration.generateFAQPairs !== undefined, 'Export generateFAQPairs should be available');
console.log('✅ Export generateFAQPairs: Available');
});
test('Export - createBatchPrompt', () => {
assert.ok(InitialGeneration.createBatchPrompt !== undefined, 'Export createBatchPrompt should be available');
console.log('✅ Export createBatchPrompt: Available');
});
test('Export - parseBatchResponse', () => {
assert.ok(InitialGeneration.parseBatchResponse !== undefined, 'Export parseBatchResponse should be available');
console.log('✅ Export parseBatchResponse: Available');
});
test('Export - collectElementsInXMLOrder', () => {
assert.ok(InitialGeneration.collectElementsInXMLOrder !== undefined, 'Export collectElementsInXMLOrder should be available');
console.log('✅ Export collectElementsInXMLOrder: Available');
});
test('Export - separateElementTypes', () => {
assert.ok(InitialGeneration.separateElementTypes !== undefined, 'Export separateElementTypes should be available');
console.log('✅ Export separateElementTypes: Available');
});
// Test d'intégration général
test('Integration - Module health check', async () => {
try {
// Vérification exports
const exports = Object.keys(InitialGeneration);
assert.ok(exports.length > 0, 'Module should export functions');
console.log(`✅ InitialGeneration: ${exports.length} exports available`);
console.log('📋 Exports:', exports.join(', '));
} catch (error) {
console.error('❌ Integration test failed:', error.message);
throw error;
}
});
});