1+ #!/usr/bin/env node
2+
3+ // Test script to verify PDF analysis functionality on both platforms
4+ console . log ( '🔍 Testing PDF Analysis Cross-Platform\n' ) ;
5+
6+ const fs = require ( 'fs' ) ;
7+ const path = require ( 'path' ) ;
8+
9+ // Create a test PDF file with text containing sensitive information
10+ const testPdfContent = `%PDF-1.3
11+ 1 0 obj
12+ << /Type /Catalog /Pages 2 0 R >>
13+ endobj
14+
15+ 2 0 obj
16+ << /Type /Pages /Kids [3 0 R] /Count 1 >>
17+ endobj
18+
19+ 3 0 obj
20+ << /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792] /Contents 4 0 R /Resources << /Font << /F1 5 0 R >> >> >>
21+ endobj
22+
23+ 4 0 obj
24+ << /Length 200 >>
25+ stream
26+ BT
27+ /F1 12 Tf
28+ 100 700 Td
29+ (Personal Information) Tj
30+ 0 -20 Td
31+ (Email: john.doe@company.com) Tj
32+ 0 -20 Td
33+ (Phone: (555) 123-4567) Tj
34+ 0 -20 Td
35+ (SSN: 123-45-6789) Tj
36+ 0 -20 Td
37+ (Credit Card: 4532-0151-1283-0366) Tj
38+ ET
39+ endstream
40+ endobj
41+
42+ 5 0 obj
43+ << /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>
44+ endobj
45+
46+ xref
47+ 0 6
48+ 0000000000 65535 f
49+ 0000000009 00000 n
50+ 0000000058 00000 n
51+ 0000000115 00000 n
52+ 0000000251 00000 n
53+ 0000000502 00000 n
54+ trailer
55+ << /Size 6 /Root 1 0 R >>
56+ startxref
57+ 569
58+ %%EOF` ;
59+
60+ const testDir = path . join ( __dirname , 'test-samples' ) ;
61+ if ( ! fs . existsSync ( testDir ) ) {
62+ fs . mkdirSync ( testDir , { recursive : true } ) ;
63+ }
64+
65+ const testPdfPath = path . join ( testDir , 'sensitive-document.pdf' ) ;
66+ fs . writeFileSync ( testPdfPath , testPdfContent ) ;
67+
68+ console . log ( '✅ Created test PDF with sensitive content:' ) ;
69+ console . log ( ` Path: ${ testPdfPath } ` ) ;
70+ console . log ( ' Content: Email, Phone, SSN, Credit Card' ) ;
71+
72+ console . log ( '\n📋 Testing Instructions:' ) ;
73+ console . log ( '' ) ;
74+ console . log ( '1. 🌐 Web App (http://localhost:3000):' ) ;
75+ console . log ( ' • Open the web app in your browser' ) ;
76+ console . log ( ' • Upload the test PDF file' ) ;
77+ console . log ( ' • Verify detection of: EMAIL, PHONE, SSN, PAN' ) ;
78+ console . log ( ' • Check console logs for "Analyzing PDF with pdfjs-dist"' ) ;
79+ console . log ( '' ) ;
80+
81+ console . log ( '2. 📱 Mobile App (http://localhost:8081):' ) ;
82+ console . log ( ' • Open the mobile app in your browser' ) ;
83+ console . log ( ' • Upload the same test PDF file' ) ;
84+ console . log ( ' • Verify detection of: EMAIL, PHONE, SSN, PAN' ) ;
85+ console . log ( ' • Check console logs for "Mobile: Analyzing PDF with pdfjs-dist"' ) ;
86+ console . log ( ' • Should NO LONGER see "PDF analysis not implemented yet"' ) ;
87+ console . log ( '' ) ;
88+
89+ console . log ( '3. 🔄 Cross-Platform Comparison:' ) ;
90+ console . log ( ' • Both platforms should detect the same sensitive items' ) ;
91+ console . log ( ' • Detection counts should be identical' ) ;
92+ console . log ( ' • Coordinate systems may differ but detections should match' ) ;
93+ console . log ( '' ) ;
94+
95+ console . log ( '4. ⚡ Performance Test:' ) ;
96+ console . log ( ' • PDF analysis should complete within 5-10 seconds' ) ;
97+ console . log ( ' • No JavaScript errors in console' ) ;
98+ console . log ( ' • Progress indicators should show during processing' ) ;
99+ console . log ( '' ) ;
100+
101+ console . log ( '✅ Test PDF created successfully!' ) ;
102+ console . log ( '📝 File size:' , fs . statSync ( testPdfPath ) . size , 'bytes' ) ;
103+ console . log ( '' ) ;
104+ console . log ( '🚀 Ready for Testing:' ) ;
105+ console . log ( '🔗 Web App: http://localhost:3000' ) ;
106+ console . log ( '🔗 Mobile App: http://localhost:8081 (FIXED - now serving mobile interface)' ) ;
107+ console . log ( '' ) ;
108+ console . log ( '📁 Test PDF Location:' ) ;
109+ console . log ( ` ${ testPdfPath } ` ) ;
110+ console . log ( '' ) ;
111+ console . log ( '🔍 Expected Detections:' ) ;
112+ console . log ( ' • EMAIL: john.doe@company.com' ) ;
113+ console . log ( ' • PHONE: (555) 123-4567' ) ;
114+ console . log ( ' • SSN: 123-45-6789' ) ;
115+ console . log ( ' • PAN: 4532-0151-1283-0366' ) ;
0 commit comments