113 lines
3.4 KiB
Python
113 lines
3.4 KiB
Python
#!/usr/bin/env python
|
|
"""
|
|
Test script to access admin evaluation dashboard through browser
|
|
"""
|
|
from django.test import Client
|
|
from django.contrib.auth import get_user_model
|
|
|
|
# Initialize Django
|
|
import os
|
|
import django
|
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings.base')
|
|
django.setup()
|
|
|
|
print("🚀 Testing Admin Evaluation Dashboard via Browser")
|
|
print("=" * 60)
|
|
|
|
User = get_user_model()
|
|
|
|
# Get one of the test admin users
|
|
admin_user = User.objects.filter(username='rahaf').first()
|
|
|
|
if not admin_user:
|
|
print("❌ Test admin user 'rahaf' not found!")
|
|
print(" Please run: python manage.py seed_admin_test_data")
|
|
exit(1)
|
|
|
|
print(f"✓ Found test user: {admin_user.username}")
|
|
print(f" Email: {admin_user.email}")
|
|
print()
|
|
|
|
# Create test client
|
|
client = Client()
|
|
|
|
# Login the user
|
|
client.force_login(admin_user)
|
|
print("✓ User logged in successfully")
|
|
print()
|
|
|
|
# Access the admin evaluation page
|
|
print("📊 Accessing admin evaluation dashboard...")
|
|
print(" URL: /admin-evaluation/")
|
|
print()
|
|
|
|
response = client.get('/admin-evaluation/', HTTP_HOST='localhost')
|
|
|
|
print(f"✓ Response status code: {response.status_code}")
|
|
print()
|
|
|
|
if response.status_code == 200:
|
|
print("✓ Page loaded successfully!")
|
|
print()
|
|
|
|
# Check content
|
|
content = response.content.decode('utf-8')
|
|
|
|
# Check for key elements
|
|
checks = {
|
|
'Admin Evaluation Dashboard': 'Page title',
|
|
'Date Range': 'Date range filter',
|
|
'Hospital': 'Hospital filter',
|
|
'Department': 'Department filter',
|
|
'Compare Staff': 'Staff comparison',
|
|
'Total Staff': 'Total staff card',
|
|
'Total Complaints': 'Total complaints card',
|
|
'Total Inquiries': 'Total inquiries card',
|
|
'Resolution Rate': 'Resolution rate card',
|
|
'Complaints': 'Complaints tab',
|
|
'Inquiries': 'Inquiries tab',
|
|
'complaintSourceChart': 'Complaint source chart',
|
|
'complaintStatusChart': 'Complaint status chart',
|
|
'complaintActivationChart': 'Complaint activation chart',
|
|
'complaintResponseChart': 'Complaint response chart',
|
|
'inquiryStatusChart': 'Inquiry status chart',
|
|
'inquiryResponseChart': 'Inquiry response chart',
|
|
}
|
|
|
|
print("Checking page elements:")
|
|
print("-" * 60)
|
|
|
|
found_count = 0
|
|
for text, description in checks.items():
|
|
if text in content:
|
|
print(f"✓ {description:30s} - Found")
|
|
found_count += 1
|
|
else:
|
|
print(f"✗ {description:30s} - NOT FOUND")
|
|
|
|
print()
|
|
print(f"Summary: {found_count}/{len(checks)} elements found")
|
|
print()
|
|
|
|
# Check for performance data
|
|
if 'performance_data' in content:
|
|
print("✓ Performance data is present in the page")
|
|
else:
|
|
print("⚠ Performance data may not be rendered (check if any staff have assignments)")
|
|
|
|
print()
|
|
print("=" * 60)
|
|
print("✅ Dashboard test completed!")
|
|
print()
|
|
print("To view the page in a browser:")
|
|
print("1. The server is running on http://localhost:8000")
|
|
print("2. Login with username: rahaf@example.com")
|
|
print("3. Password: password123 (if needed)")
|
|
print("4. Navigate to: http://localhost:8000/dashboard/admin-evaluation/")
|
|
|
|
else:
|
|
print(f"❌ Page failed to load. Status code: {response.status_code}")
|
|
print()
|
|
if hasattr(response, 'content'):
|
|
error_msg = response.content.decode('utf-8')[:500]
|
|
print(f"Error preview: {error_msg}...") |