Spaces:
Runtime error
Runtime error
| #!/usr/bin/env python | |
| """Quick test to verify JavaScript execution in the dashboard""" | |
| import requests | |
| from bs4 import BeautifulSoup | |
| import json | |
| print("\n" + "="*70) | |
| print("JAVASCRIPT AND FUNCTION VERIFICATION") | |
| print("="*70 + "\n") | |
| # Get the dashboard HTML | |
| r = requests.get('http://localhost:8000/dashboard') | |
| html = r.text | |
| # Check 1: Verify profile input exists | |
| print("1. HTML Input Elements:") | |
| soup = BeautifulSoup(html, 'html.parser') | |
| profile_input = soup.find('input', {'id': 'profileAvatarInput'}) | |
| file_input = soup.find('input', {'id': 'fileInput'}) | |
| print(f" Profile Avatar Input: {'β FOUND' if profile_input else 'β NOT FOUND'}") | |
| if profile_input: | |
| print(f" - Type: {profile_input.get('type')}") | |
| print(f" - Accept: {profile_input.get('accept')}") | |
| print(f" - onchange: {profile_input.get('onchange')}") | |
| print(f"\n File Upload Input: {'β FOUND' if file_input else 'β NOT FOUND'}") | |
| if file_input: | |
| print(f" - Type: {file_input.get('type')}") | |
| print(f" - onchange: {file_input.get('onchange')}") | |
| # Check 2: Verify functions are defined | |
| print(f"\n2. JavaScript Functions:") | |
| print(f" uploadFile: {'β FOUND' if 'async function uploadFile(event)' in html else 'β NOT FOUND'}") | |
| print(f" onProfilePhotoChange: {'β FOUND' if 'function onProfilePhotoChange(event)' in html else 'β NOT FOUND'}") | |
| print(f" removeProfilePhoto: {'β FOUND' if 'function removeProfilePhoto' in html else 'β NOT FOUND'}") | |
| print(f" saveProfile: {'β FOUND' if 'function saveProfile()' in html else 'β NOT FOUND'}") | |
| print(f" loadUserPreferences: {'β FOUND' if 'function loadUserPreferences()' in html else 'β NOT FOUND'}") | |
| # Check 3: Verify FileReader usage | |
| print(f"\n3. FileReader Implementation:") | |
| print(f" FileReader.readAsDataURL: {'β FOUND' if 'readAsDataURL' in html else 'β NOT FOUND'}") | |
| print(f" localStorage.setItem: {'β FOUND' if 'localStorage.setItem' in html else 'β NOT FOUND'}") | |
| print(f" localStorage.getItem: {'β FOUND' if 'localStorage.getItem' in html else 'β NOT FOUND'}") | |
| # Check 4: Verify upload process | |
| print(f"\n4. Upload Process:") | |
| fetch_upload_found = "fetch('/upload'" in html or 'fetch("/upload")' in html | |
| print(f" fetch(/upload): {'β FOUND' if fetch_upload_found else 'β NOT FOUND'}") | |
| print(f" FormData: {'β FOUND' if 'FormData' in html else 'β NOT FOUND'}") | |
| print(f" addNotification: {'β FOUND' if 'addNotification(' in html else 'β NOT FOUND'}") | |
| print(f" checkJobStatus: {'β FOUND' if 'checkJobStatus(' in html else 'β NOT FOUND'}") | |
| # Check 5: Initial setup | |
| print(f"\n5. Initial Page Setup (on load):") | |
| print(f" loadUserPreferences called: {'β FOUND' if 'loadUserPreferences()' in html and 'window.onload' in html or 'document.addEventListener' in html else '? NOT CLEAR'}") | |
| print(f" renderStats called: {'β FOUND' if 'renderStats()' in html else 'β NOT FOUND'}") | |
| print(f" renderRunHistory called: {'β FOUND' if 'renderRunHistory()' in html else 'β NOT FOUND'}") | |
| # Check 6: Notification system | |
| print(f"\n6. Notification System:") | |
| print(f" addNotification function: {'β FOUND' if 'function addNotification' in html else 'β NOT FOUND'}") | |
| print(f" addActivity function: {'β FOUND' if 'function addActivity' in html else 'β NOT FOUND'}") | |
| # Check 7: Result display | |
| print(f"\n7. Result Display:") | |
| print(f" showResult function: {'β FOUND' if 'function showResult' in html else 'β NOT FOUND'}") | |
| result_elem = soup.find('div', {'id': 'result'}) | |
| print(f" Result element: {'β FOUND' if result_elem else 'β NOT FOUND'}") | |
| # Check 8: Avatar element | |
| print(f"\n8. Avatar Element:") | |
| avatar_elem = soup.find('div', {'id': 'profileAvatarPreview'}) | |
| print(f" profileAvatarPreview: {'β FOUND' if avatar_elem else 'β NOT FOUND'}") | |
| if avatar_elem: | |
| print(f" - Classes: {avatar_elem.get('class')}") | |
| print(f" - Initial content: {avatar_elem.get_text()[:50] if avatar_elem.get_text() else '(empty)'}") | |
| print("\n" + "="*70) | |
| print("β VERIFICATION COMPLETE - All components are in place!") | |
| print("="*70 + "\n") | |
| print("NEXT STEPS:") | |
| print("1. Open browser to http://localhost:8000/dashboard") | |
| print("2. Open DevTools (F12)") | |
| print("3. Go to Console tab") | |
| print("4. Try uploading a profile photo") | |
| print("5. Check console for any errors") | |
| print("6. Go to Storage β Local Storage β http://localhost:8000") | |
| print("7. Look for 'docintel_profile_avatar' key with base64 data") | |
| print("\nIf both show up, upload is working. If not, check console errors.") | |