File size: 4,117 Bytes
ed0b977
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112

from flask import Flask, session, request
import mongomock
from utils.blueprints import assistant
from utils.blueprints.assistant import assistant_bp

# Patch mongo with mock
assistant.mongo.db = mongomock.MongoClient().db

app = Flask(__name__, template_folder='templates')
app.secret_key = 'test'
app.register_blueprint(assistant_bp)

from flask import Blueprint
admin_bp = Blueprint('admin', __name__)
@admin_bp.route('/logout')
def logout(): return "Logout"
@admin_bp.route('/login')
def login(): return "Login"
app.register_blueprint(admin_bp)

def verify_dashboard_view():
    with app.test_request_context():
        # Setup session
        session['user_type'] = 'assistant'
        session['role'] = 'data_entry'
        session['user_name'] = 'Test Assistant'
        
        # 1. Create Data
        # Patient
        assistant.mongo.db.patient.insert_one({
            "id": 101, 
            "sql_id": 101, 
            "name": "Jane User", 
            "phone": "555-0100", 
            "address": "123 Test Lane",
            "gender": "Female"
        })
        # Medical History
        assistant.mongo.db.medicalhistory.insert_one({
            "patient_id": 101,
            "condition": "Hypertension",
            "diagnosis_date": "2023-01-01",
            "notes": "Stable"
        })
        # Consultation
        assistant.mongo.db.consultation.insert_one({
            "patient_id": 101,
            "date": "2023-02-01",
            "doctor_name": "Dr. Smith",
            "diagnosis": "Checkup"
        })
        
        # 2. Render Dashboard with Patient Selected
        with app.test_client() as client:
            with client.session_transaction() as sess:
                sess['user_type'] = 'assistant'
                sess['role'] = 'data_entry'
                
            # Request with patient_id=101
            resp = client.get('/assistant/dashboard/data_entry?patient_id=101')
            html = resp.data.decode('utf-8')
            
            checks = {
                "Patient Name Pre-fill": 'value="Jane User"' not in html and "Jane User" in html, # Name is not an input, but displayed in header
                "Address Pre-fill": 'value="123 Test Lane"' in html,
                "Gender Pre-fill": 'value="Female" selected' in html or 'value="Female" selected' in html,
                "History List": "Hypertension" in html,
                "Consultation List": "Dr. Smith" in html
            }
            
            # Additional Layout Checks
            if "grid-cols-1 md:grid-cols-2" in html:
                print("[PASS] Spacious Layout Detected (grid-cols-2)")
            else:
                print("[WARN] Spacious Layout NOT Detected")
            
            # Check Default Active Tab
            if "Update Patient Profile" in html:
                 # It's always in HTML, but we want to check if the 'active' class is near it or its parent. 
                 # Since simple string check just checks existence, we assume logic is correct if HTML structure has changed.
                 # A better check is 'tab-content active' followed closely by 'Update Patient Profile'? 
                 # But parsing generic HTML is hard with regex here.
                 pass

            if "active" in html and "profile" in html: 
                 # Rough check that profile is potentially active
                 print("[PASS] Profile Tab likely Active")

                
            if "p-4 shadow-sm" in html:
                print("[PASS] Large Input Styling Detected")
            else:
                print("[WARN] Large Input Styling NOT Detected")

            
            all_passed = True
            for check, passed in checks.items():
                if passed:
                    print(f"[PASS] {check}")
                else:
                    print(f"[FAIL] {check}")
                    all_passed = False
            
            if all_passed:
                print("\nAll View/Edit checks passed!")
            else:
                print("\nSome checks failed.")

if __name__ == "__main__":
    verify_dashboard_view()