feat: 重构管理后台前端架构并新增完整功能
This commit is contained in:
commit
93304a1803
88 files changed
+9941
-6500
No files matched your search
@@ -60,7 +60,8 @@ def test_user_management(client, admin_headers):
|
||||
"role": "user",
|
||||
"password": "password123",
|
||||
"real_name": "Test User",
|
||||
"employee_id": "EMP001"
|
||||
"employee_id": "EMP001",
|
||||
"phone_number": "13800000001"
|
||||
}
|
||||
response = client.post('/api/admin/users', json=new_user, headers=admin_headers)
|
||||
assert response.status_code == 201
|
||||
@@ -180,6 +181,22 @@ def test_reports(client, admin_headers):
|
||||
"""
|
||||
Test report endpoints
|
||||
"""
|
||||
response = client.get('/api/admin/dashboard/summary', headers=admin_headers)
|
||||
assert response.status_code == 200
|
||||
data = response.json
|
||||
assert set(data.keys()) == {'agent_count', 'user_count', 'total_conversations', 'avg_score'}
|
||||
assert isinstance(data['agent_count'], int)
|
||||
assert isinstance(data['user_count'], int)
|
||||
assert isinstance(data['total_conversations'], int)
|
||||
assert isinstance(data['avg_score'], (int, float))
|
||||
|
||||
response = client.get('/api/admin/dashboard/badges', headers=admin_headers)
|
||||
assert response.status_code == 200
|
||||
badges = response.json
|
||||
assert set(badges.keys()) == {'pending_approvals', 'pending_requests'}
|
||||
assert isinstance(badges['pending_approvals'], int)
|
||||
assert isinstance(badges['pending_requests'], int)
|
||||
|
||||
response = client.get('/api/admin/reports/usage', headers=admin_headers)
|
||||
assert response.status_code == 200
|
||||
data = response.json
|
||||
|
||||
@@ -100,8 +100,12 @@ def test_login_success(client):
|
||||
def test_login_fail(client):
|
||||
res = client.post('/api/user/login', json={'username': 'test1', 'password': 'wrongpassword'})
|
||||
assert res.status_code == 401
|
||||
assert 'Incorrect password' in res.get_json()['error']
|
||||
|
||||
body = res.get_json()
|
||||
assert body['error']['code'] == 'AUTH.INCORRECT_PASSWORD'
|
||||
assert 'Incorrect password' in body['error']['message']
|
||||
|
||||
res = client.post('/api/user/login', json={'username': 'nonexistent', 'password': 'password'})
|
||||
assert res.status_code == 404
|
||||
assert 'User not found' in res.get_json()['error']
|
||||
body = res.get_json()
|
||||
assert body['error']['code'] == 'AUTH.USER_NOT_FOUND'
|
||||
assert 'User not found' in body['error']['message']
|
||||
@@ -52,7 +52,8 @@ def test_admin_duplicate_employee_id(client, admin_headers):
|
||||
"password": "pwd",
|
||||
"email": "au1@e.com",
|
||||
"real_name": "Admin User 1",
|
||||
"employee_id": "ADM001"
|
||||
"employee_id": "ADM001",
|
||||
"phone_number": "13800000011"
|
||||
}
|
||||
response = client.post('/api/admin/users', json=u1, headers=admin_headers)
|
||||
assert response.status_code == 201
|
||||
@@ -63,7 +64,8 @@ def test_admin_duplicate_employee_id(client, admin_headers):
|
||||
"password": "pwd",
|
||||
"email": "au2@e.com",
|
||||
"real_name": "Admin User 2",
|
||||
"employee_id": "ADM001"
|
||||
"employee_id": "ADM001",
|
||||
"phone_number": "13800000012"
|
||||
}
|
||||
response = client.post('/api/admin/users', json=u2, headers=admin_headers)
|
||||
assert response.status_code == 400
|
||||
@@ -76,7 +78,8 @@ def test_admin_duplicate_employee_id(client, admin_headers):
|
||||
"password": "pwd",
|
||||
"email": "au3@e.com",
|
||||
"real_name": "Admin User 3",
|
||||
"employee_id": "ADM003"
|
||||
"employee_id": "ADM003",
|
||||
"phone_number": "13800000013"
|
||||
}
|
||||
res = client.post('/api/admin/users', json=u3, headers=admin_headers)
|
||||
u3_id = res.json['id']
|
||||
|
||||
Reference in new issue
Block a user