# Quick Test Guide - BinectChrome ## 1. Setup (2 minutes) ```bash # Rebuild extension npm run build # Load in Chrome # 1. Open chrome://extensions/ # 2. Enable "Developer mode" # 3. Click "Reload" on BinectChrome (or "Load unpacked" if first time, select dist/) # 4. Accept new permissions when prompted ``` ## 2. Open Debug Consoles **Service Worker:** - `chrome://extensions/` → Click "service worker" under BinectChrome - Keep this window open **Popup (optional):** - Click extension icon → Right-click → "Inspect" ## 3. Test PDF Viewer Detection (RECOMMENDED - Most Reliable) **This is the easiest way to test the API integration!** 1. **Open a test PDF in Chrome:** ``` https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf ``` Just paste the URL in the address bar and press Enter 2. **Click the extension icon** - Should detect the PDF immediately - Shows filename, domain, "Send PDF to Binect" button 3. **Sign in and send:** - Enter your Binect credentials - Click "Send PDF to Binect" - Watch for "Uploading..." → "Success!" **Expected Popup Logs:** ``` [Popup] Loading last PDF... [Popup] Found PDF in current tab: dummy.pdf ``` **✅ This method always works - no service worker timing issues!** ## 4. Test Download Detection (May Need Fallback) **Method 1: Right-click → Save** 1. Right-click this link: https://www.africau.edu/images/default/sample.pdf 2. Select "Save link as..." 3. Save to Downloads 4. Watch service worker console for logs **Method 2: Direct download** 1. Paste URL: https://www.adobe.com/support/products/enterprise/knowledgecenter/media/c4611_sample_explain.pdf 2. Chrome starts download 3. Watch service worker console **Expected Service Worker Logs (if working):** ``` [PDF Detector] Download changed: {...} [PDF Detector] Download complete, searching for item: X [PDF Detector] PDF detected! [Service Worker] PDF DETECTED CALLBACK: sample.pdf [Service Worker] Badge updated, PDF stored in memory ``` **If badge shows "1":** Download detection worked! ✅ **If no badge:** Fallback will still work! Continue... 5. **Click extension icon** - Even if service worker missed it, popup checks recent downloads - PDF should appear **Expected Popup Logs (fallback):** ``` [Popup] Background has no PDF, checking recent downloads as fallback... [Popup] Checked recent downloads: X items [Popup] Found recent PDF: sample.pdf ``` ## 5. Test Binect API Integration **Prerequisites:** - Have Binect credentials ready - PDF is detected (from viewer OR download) **Steps:** 1. Click extension icon 2. If not signed in: - Enter username and password - Click "Sign In" - Should show main view 3. PDF details should be visible 4. Click "Send PDF to Binect" 5. Wait for upload **Expected Results:** ``` Status: Uploading... → Success! Document ID: [id] ``` **Check Tracking:** - Click "?" button in popup - Opens tracking page - Should show the transfer with success status ## 6. Test Error Handling **Invalid Credentials:** 1. Sign out (if signed in) 2. Enter wrong username/password 3. Click "Sign In" 4. Should show error: "Invalid credentials" **Network Error:** 1. Disconnect from internet 2. Try to authenticate or send PDF 3. Should show network error ## Quick Debug Checklist **If PDF viewer detection doesn't work:** - [ ] Is the URL actually a PDF? (ends with .pdf) - [ ] Check popup console for error logs - [ ] Try refreshing the PDF tab **If download detection doesn't work:** - [ ] Check service worker console for `[PDF Detector]` logs - [ ] Look for "Listener registered successfully" - [ ] Try downloading again while service worker console is open - [ ] Open popup - fallback should still find it **If API upload fails:** - [ ] Check credentials are correct - [ ] Verify PDF URL is accessible (try opening in new tab) - [ ] Check popup console for detailed error - [ ] Look at Network tab in popup DevTools for API calls ## Expected Console Output Summary ### Service Worker (when working): ``` [Service Worker] ===== BinectChrome service worker loaded ===== [Service Worker] Initializing PDF detection... [PDF Detector] Starting PDF detection, registering download listener [PDF Detector] Listener registered successfully # On download: [PDF Detector] Download changed: {id: X, ...} [PDF Detector] PDF detected! [Service Worker] PDF DETECTED CALLBACK: filename.pdf [Service Worker] Badge updated, PDF stored in memory ``` ### Popup (viewer detection): ``` [Popup] Loading last PDF... [Popup] Found PDF in current tab: document.pdf ``` ### Popup (fallback): ``` [Popup] Loading last PDF... [Popup] No PDF in current tab, checking background script... [Service Worker] Returning last PDF: none [Popup] Background has no PDF, checking recent downloads as fallback... [Popup] Found recent PDF: document.pdf ``` ## Common Questions **Q: Badge doesn't show but popup finds the PDF?** A: Normal! Service worker may have been asleep. Fallback handled it. **Q: PDF disappears after a few minutes?** A: Service worker memory is cleared when it sleeps. Fallback will re-fetch it. **Q: Which detection method should I use?** A: **PDF viewer detection** is more reliable. Just open PDFs in Chrome instead of downloading. **Q: Can I test without Binect credentials?** A: You can test PDF detection, but not the upload. You'll see authentication errors when trying to send. ## Test URLs **Small PDFs (quick tests):** - https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf (1 page) - https://www.africau.edu/images/default/sample.pdf (1 page) **Medium PDFs:** - https://www.adobe.com/support/products/enterprise/knowledgecenter/media/c4611_sample_explain.pdf (multi-page) ## Next Steps 1. **Test viewer detection** - Most reliable 2. **Test download detection** - May need fallback 3. **Test API integration** - Requires credentials 4. **Check tracking page** - Verify data is recorded ## Getting Help If something doesn't work: 1. Check the detailed guides: - `DEBUG_DOWNLOAD_DETECTION.md` - Download debugging - `TESTING_PDF_VIEWER.md` - Viewer testing - `DOWNLOAD_DETECTION_FIXES.md` - Technical details 2. Export console logs (right-click → Save as) 3. Note your Chrome version: `chrome://version/` 4. Email: bernd.worsch@binect.de ## Success Criteria ✅ PDF viewer detection works consistently ✅ Download detection works OR fallback finds PDFs ✅ API authentication succeeds ✅ PDF upload succeeds ✅ Tracking records the transfer ✅ Badge updates (when service worker is awake) **You're ready to use BinectChrome!**