const SatLocProcessor = require('./helpers/satloc_application_processor'); const path = require('path'); async function testParsingLogic() { console.log('=== Testing Parsing Logic Without Database ===\n'); const processor = new SatLocProcessor(); const logFilePath = path.join(__dirname, 'test-logs', 'Liquid_IF2_G4.log'); // Track parsing calls 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 parseSatLocLogFile directly...'); const parseResult = await processor.parseSatLocLogFile(logFilePath, {}); console.log('\nšŸ“Š Parse Results:'); console.log(`- Success: ${parseResult.success}`); console.log(`- Parse calls made: ${parseCallCount}`); console.log(`- Application details: ${parseResult.applicationDetails?.length || 0}`); console.log(`- UTM Zone: ${parseResult.utmZone}`); console.log(`- File size: ${(parseResult.fileSize / 1024 / 1024).toFixed(2)} MB`); // Test grouping logic console.log('\nšŸ” Testing grouping logic...'); const jobGroups = processor.groupApplicationDetailsByJob(parseResult.applicationDetails); console.log(`- Job groups found: ${Object.keys(jobGroups).length}`); for (const [jobId, details] of Object.entries(jobGroups)) { console.log(` - Job "${jobId}": ${details.length} details`); } console.log('\nāœ… SUCCESS: Parsing and grouping logic works correctly!'); console.log(`āœ… OPTIMIZATION: Only ${parseCallCount} parse call made (no duplication)`); } catch (error) { console.error('āŒ Test failed:', error.message); console.log(`Parse calls made before error: ${parseCallCount}`); } } testParsingLogic();