const fs = require('fs'); const JSZip = require('jszip'); // Import the analysis functions directly (copy from upload-document.js) // We'll call the analysis logic directly since it's not exported // Test the enhanced location tracking async function testLocationTracking() { console.log('=== Testing Enhanced Location Tracking ===\n'); const testFile = 'reports/Protected_remediated_by_agent.docx'; if (!fs.existsSync(testFile)) { console.log(`Test file ${testFile} not found. Skipping test.`); return; } try { const fileData = fs.readFileSync(testFile); // Simple test of the location detection logic const zip = await JSZip.loadAsync(fileData); const documentXml = await zip.file('word/document.xml')?.async('string'); if (documentXml) { console.log('āœ… Successfully loaded document XML'); console.log(` Document size: ${documentXml.length} characters`); // Test basic structure analysis const paragraphMatches = documentXml.match(/]*>/g) || []; console.log(` Found ${paragraphMatches.length} paragraphs`); // Test for spacing issues const spacingMatches = documentXml.match(/]*w:line="(\d+)"[^>]*\/>/g) || []; console.log(` Found ${spacingMatches.length} explicit spacing declarations`); // Test for font issues const fontMatches = documentXml.match(/w:(?:ascii|hAnsi)="([^"]+)"/g) || []; console.log(` Found ${fontMatches.length} font declarations`); // Test for size issues const sizeMatches = documentXml.match(/