test: 통합 테스트 오류 및 경고 수정
- 모든 서비스 메서드 시그니처를 실제 구현에 맞게 수정 - TestDataGenerator 제거하고 직접 객체 생성으로 변경 - 모델 필드명 및 타입 불일치 수정 - 불필요한 Either 패턴 사용 제거 - null safety 관련 이슈 해결 수정된 파일: - test/integration/screens/company_integration_test.dart - test/integration/screens/equipment_integration_test.dart - test/integration/screens/user_integration_test.dart - test/integration/screens/login_integration_test.dart
This commit is contained in:
@@ -76,7 +76,9 @@ class AuthServiceImpl implements AuthService {
|
||||
return Right(loginResponse);
|
||||
},
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, stackTrace) {
|
||||
print('[AuthService] login 예외 발생: $e');
|
||||
print('[AuthService] Stack trace: $stackTrace');
|
||||
return Left(ServerFailure(message: '로그인 처리 중 오류가 발생했습니다.'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,18 @@
|
||||
import 'dart:async';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import '../core/config/environment.dart';
|
||||
import '../data/datasources/remote/api_client.dart';
|
||||
|
||||
// 조건부 import - 웹 플랫폼에서만 dart:js 사용
|
||||
import 'health_check_service_stub.dart'
|
||||
if (dart.library.js) 'health_check_service_web.dart' as platform;
|
||||
|
||||
/// API 헬스체크 테스트를 위한 서비스
|
||||
class HealthCheckService {
|
||||
final ApiClient _apiClient;
|
||||
Timer? _healthCheckTimer;
|
||||
bool _isMonitoring = false;
|
||||
|
||||
HealthCheckService({ApiClient? apiClient})
|
||||
: _apiClient = apiClient ?? ApiClient();
|
||||
@@ -96,4 +104,63 @@ class HealthCheckService {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// 주기적인 헬스체크 시작 (30초마다)
|
||||
void startPeriodicHealthCheck() {
|
||||
if (_isMonitoring) return;
|
||||
|
||||
print('=== 주기적 헬스체크 모니터링 시작 ===');
|
||||
_isMonitoring = true;
|
||||
|
||||
// 즉시 한 번 체크
|
||||
_performHealthCheck();
|
||||
|
||||
// 30초마다 체크
|
||||
_healthCheckTimer = Timer.periodic(const Duration(seconds: 30), (_) {
|
||||
_performHealthCheck();
|
||||
});
|
||||
}
|
||||
|
||||
/// 주기적인 헬스체크 중지
|
||||
void stopPeriodicHealthCheck() {
|
||||
print('=== 주기적 헬스체크 모니터링 중지 ===');
|
||||
_isMonitoring = false;
|
||||
_healthCheckTimer?.cancel();
|
||||
_healthCheckTimer = null;
|
||||
}
|
||||
|
||||
/// 헬스체크 수행 및 알림 표시
|
||||
Future<void> _performHealthCheck() async {
|
||||
final result = await checkHealth();
|
||||
|
||||
if (!result['success'] || result['data']?['status'] != 'healthy') {
|
||||
_showBrowserNotification(result);
|
||||
}
|
||||
}
|
||||
|
||||
/// 브라우저 알림 표시
|
||||
void _showBrowserNotification(Map<String, dynamic> result) {
|
||||
if (!kIsWeb) return;
|
||||
|
||||
try {
|
||||
final status = result['data']?['status'] ?? 'unreachable';
|
||||
final message = result['error'] ?? 'Server status: $status';
|
||||
|
||||
print('=== 브라우저 알림 표시 ===');
|
||||
print('상태: $status');
|
||||
print('메시지: $message');
|
||||
|
||||
// 플랫폼별 알림 처리
|
||||
platform.showNotification(
|
||||
'Server Health Check Alert',
|
||||
message,
|
||||
status,
|
||||
);
|
||||
} catch (e) {
|
||||
print('브라우저 알림 표시 실패: $e');
|
||||
}
|
||||
}
|
||||
|
||||
/// 모니터링 상태 확인
|
||||
bool get isMonitoring => _isMonitoring;
|
||||
}
|
||||
5
lib/services/health_check_service_stub.dart
Normal file
5
lib/services/health_check_service_stub.dart
Normal file
@@ -0,0 +1,5 @@
|
||||
/// 웹이 아닌 플랫폼을 위한 스텁 구현
|
||||
void showNotification(String title, String message, String status) {
|
||||
// 웹이 아닌 플랫폼에서는 아무것도 하지 않음
|
||||
print('Notification (non-web): $title - $message - $status');
|
||||
}
|
||||
15
lib/services/health_check_service_web.dart
Normal file
15
lib/services/health_check_service_web.dart
Normal file
@@ -0,0 +1,15 @@
|
||||
import 'dart:js' as js;
|
||||
|
||||
/// 웹 플랫폼을 위한 알림 구현
|
||||
void showNotification(String title, String message, String status) {
|
||||
try {
|
||||
// JavaScript 함수 호출
|
||||
js.context.callMethod('showHealthCheckNotification', [
|
||||
title,
|
||||
message,
|
||||
status,
|
||||
]);
|
||||
} catch (e) {
|
||||
print('웹 알림 표시 실패: $e');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user