// Test parser integration directly const { SatLocLogParser } = require('./helpers/satloc_log_parser'); const fs = require('fs'); async function testParserIntegration() { console.log('Testing SatLoc Parser Integration...\n'); try { const testFile = './test-logs/02220710.LOG'; const parser = new SatLocLogParser(); const buffer = fs.readFileSync(testFile); console.log(`Processing file: ${testFile}`); console.log(`File size: ${buffer.length} bytes\n`); // Test the method that would be called by the application processor const headerInfo = {}; // Parser will extract header info const fileContext = { filenameJobId: 'TEST_JOB_001', filePath: testFile, fileName: '02220710.LOG' }; console.log('=== Testing Parser Integration ==='); // Test parseRecordsFromBuffer (the method used by processLogFile) const parseResults = await parser.parseRecordsFromBuffer(buffer, headerInfo, fileContext); console.log('\nšŸ“Š Parse Results Summary:'); console.log(`āœ“ Total records parsed: ${parseResults.recordCount}`); console.log(`āœ“ Job groups found: ${Object.keys(parseResults.jobGroups).length}`); console.log(`āœ“ UTM Zone calculated: ${parseResults.utmZone ? parseResults.utmZone.toString() : 'None'}`); console.log('\nšŸ” UTM Zone Details:'); if (parseResults.utmZone) { console.log(` - Zone Number: ${parseResults.utmZone.zoneNumber}`); console.log(` - Hemisphere: ${parseResults.utmZone.hemisphere}`); console.log(` - toString(): ${parseResults.utmZone.toString()}`); console.log(` āœ“ UTM Zone object structure is correct!`); } console.log('\nšŸ“ Job Groups Analysis:'); for (const [jobId, applicationDetails] of Object.entries(parseResults.jobGroups)) { console.log(` Job ID: "${jobId}"`); console.log(` - Application details: ${applicationDetails.length}`); if (applicationDetails.length > 0) { const firstDetail = applicationDetails[0]; console.log(` - First detail properties: ${Object.keys(firstDetail).length}`); console.log(` - Has coordinates: ${firstDetail.lat !== undefined && firstDetail.lon !== undefined}`); console.log(` - Sample coordinates: lat=${firstDetail.lat}, lon=${firstDetail.lon}`); } } console.log('\nšŸ“ Metadata Extracted:'); const metadata = parseResults.metadata; console.log(` - Job ID: ${metadata.jobId || 'Not found'}`); console.log(` - Aircraft ID: ${metadata.aircraftId || 'Not found'}`); console.log(` - Pilot Name: ${metadata.pilotName || 'Not found'}`); console.log(` - Controller Type: ${metadata.controllerType || 'Not found'}`); console.log('\nšŸŽÆ Detected Job IDs:'); const detected = parseResults.detectedJobIds; console.log(` - Filename Job ID: ${detected.filenameJobId || 'None'}`); console.log(` - Job Long Label Name: ${detected.jobLongLabelName || 'None'}`); console.log(` - SatLoc Job ID: ${detected.satlocJobId || 'None'}`); console.log('\nāœ… All integration tests passed!'); console.log('šŸš€ Parser is ready for Application Processor integration'); } catch (error) { console.error('\nāŒ Error during integration test:', error.message); console.error('Stack:', error.stack); } } // Run the test testParserIntegration().catch(console.error);