agmission/Development/server/tests/test_no_duplication.js

62 lines
2.5 KiB
JavaScript

describe('No Duplication', function() {
this.timeout(120000);
it('should execute test successfully', async function() {
const { expect } = require('chai');
const SatLocProcessor = require('../helpers/satloc_application_processor');
const path = require('path');
async function testProcessLogFileNoDuplication() {
console.log('=== Testing processLogFile Without Duplicate Parsing ===\n');
const processor = new SatLocProcessor();
const logFilePath = path.join(__dirname, 'test-logs', 'Liquid_IF2_G4.log');
// Mock context data
const contextData = {
userId: 'test-user',
jobId: null,
uploadedDate: new Date()
};
// Track parsing calls to ensure no duplication
let parseCallCount = 0;
const originalParseSatLocLogFile = processor.parseSatLocLogFile;
processor.parseSatLocLogFile = function(...args) {
parseCallCount++;
console.log(`📝 Parse call #${parseCallCount}: parsing log file...`);
return originalParseSatLocLogFile.apply(this, args);
};
try {
console.log('🔍 Testing processLogFile...');
const result = await processor.processLogFile({ filePath: logFilePath }, contextData);
console.log('\n📊 Processing Results:');
console.log(`- Success: ${result.success}`);
console.log(`- Parse calls made: ${parseCallCount} (should be 1)`);
console.log(`- Applications created: ${result.applications?.length || 0}`);
console.log(`- Application files created: ${result.applicationFiles?.length || 0}`);
console.log(`- Total details: ${result.totalDetails}`);
if (parseCallCount === 1) {
console.log('\n✅ SUCCESS: Log file was parsed only once!');
} else {
console.log(`\n❌ ISSUE: Log file was parsed ${parseCallCount} times (should be 1)`);
}
if (result.success) {
console.log('✅ SUCCESS: processLogFile completed without errors!');
} else {
console.log(`❌ ERROR: ${result.error}`);
}
} catch (error) {
console.error('❌ Test failed:', error.message);
console.log(`Parse calls made before error: ${parseCallCount}`);
}
}
await testProcessLogFileNoDuplication();
});
});