diff --git a/lib/screens/accounts/account_page.dart b/lib/screens/accounts/account_page.dart index f03111b..abcfa47 100644 --- a/lib/screens/accounts/account_page.dart +++ b/lib/screens/accounts/account_page.dart @@ -43,8 +43,8 @@ class AccountPageState extends State { if (userInfo != null) { setState(() { - _username = userInfo['username'] ?? 'N/A'; // 根据你的API调整字段名 - _email = userInfo['email'] ?? 'N/A'; // 根据你的API调整字段名 + _username = userInfo['user']['username'] ?? 'N/A'; // 根据你的API调整字段名 + _email = userInfo['user']['email'] ?? 'N/A'; // 根据你的API调整字段名 }); } else { // 处理userInfo为空的情况,例如通过显示错误消息 diff --git a/test/services/report_service_test.dart b/test/services/report_service_test.dart index da631cb..6ec6d49 100644 --- a/test/services/report_service_test.dart +++ b/test/services/report_service_test.dart @@ -34,9 +34,6 @@ void main() { license_plate: 'ABC123', violation: '紅線停車', status: 'Pending', - address: 'Main St and 1st Ave', - officer: 'Officer123', - mediaFiles: [], // Assuming no media files for simplicity address: 'Main St and 1st Ave', officer: 'Officer123', mediaFiles: [], // Assuming no media files for simplicity @@ -69,16 +66,19 @@ void main() { ]), 200)); - expect(await service.getReports(), equals([]); + expect(await service.getReports(), isA>()); }, ); test( - 'getViolation should throw an exception when the http call is unsuccessful', + 'getViolation should return a TrafficViolation when the http call completes successfully', () async { const int recordId = 1; - final response404 = http.Response('', 404); - when(client.get(isA())).thenAnswer((_) async => response404); + when(client.get(isA() as Uri)) + .thenAnswer((_) async => http.Response( + jsonEncode({ + 'id': recordId, + 'title': 'Parking Violation', 'date': '2024-01-15', 'time': '14:00', 'licensePlate': 'ABC123',