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:
106
test/integration/automated/simple_test_runner.dart
Normal file
106
test/integration/automated/simple_test_runner.dart
Normal file
@@ -0,0 +1,106 @@
|
||||
import 'package:test/test.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:superport/data/datasources/remote/api_client.dart';
|
||||
import '../real_api/test_helper.dart';
|
||||
import 'framework/core/test_auth_service.dart';
|
||||
|
||||
/// 간단한 API 테스트 실행
|
||||
void main() {
|
||||
group('간단한 API 연결 테스트', () {
|
||||
late GetIt getIt;
|
||||
late ApiClient apiClient;
|
||||
late TestAuthService testAuthService;
|
||||
|
||||
setUpAll(() async {
|
||||
// 테스트 환경 설정 중...
|
||||
|
||||
// 환경 초기화
|
||||
await RealApiTestHelper.setupTestEnvironment();
|
||||
getIt = GetIt.instance;
|
||||
apiClient = getIt.get<ApiClient>();
|
||||
|
||||
// 테스트용 인증 서비스 생성
|
||||
testAuthService = TestAuthHelper.getInstance(apiClient);
|
||||
});
|
||||
|
||||
tearDownAll(() async {
|
||||
TestAuthHelper.clearInstance();
|
||||
await RealApiTestHelper.teardownTestEnvironment();
|
||||
});
|
||||
|
||||
test('API 서버 연결 확인', () async {
|
||||
// [TEST] API 서버 연결 확인 중...
|
||||
|
||||
try {
|
||||
// Health check
|
||||
final response = await apiClient.dio.get('/health');
|
||||
|
||||
// [TEST] 응답 상태 코드: ${response.statusCode}
|
||||
// [TEST] 응답 데이터: ${response.data}
|
||||
|
||||
expect(response.statusCode, equals(200));
|
||||
expect(response.data['success'], equals(true));
|
||||
|
||||
// [TEST] ✅ API 서버 연결 성공!
|
||||
} catch (e) {
|
||||
// [TEST] ❌ API 서버 연결 실패: $e
|
||||
rethrow;
|
||||
}
|
||||
});
|
||||
|
||||
test('로그인 테스트', () async {
|
||||
// print('\n[TEST] 로그인 테스트 시작...');
|
||||
|
||||
const email = 'admin@superport.kr';
|
||||
const password = 'admin123!';
|
||||
|
||||
// print('[TEST] 로그인 정보:');
|
||||
// print('[TEST] - Email: $email');
|
||||
// print('[TEST] - Password: ***');
|
||||
|
||||
try {
|
||||
final loginResponse = await testAuthService.login(email, password);
|
||||
|
||||
// print('[TEST] ✅ 로그인 성공!');
|
||||
// print('[TEST] - 사용자: ${loginResponse.user.email}');
|
||||
// print('[TEST] - 역할: ${loginResponse.user.role}');
|
||||
// print('[TEST] - 토큰 타입: ${loginResponse.tokenType}');
|
||||
// print('[TEST] - 만료 시간: ${loginResponse.expiresIn}초');
|
||||
|
||||
expect(loginResponse.accessToken, isNotEmpty);
|
||||
expect(loginResponse.user.email, equals(email));
|
||||
} catch (e) {
|
||||
// print('[TEST] ❌ 로그인 실패: $e');
|
||||
fail('로그인 실패: $e');
|
||||
}
|
||||
});
|
||||
|
||||
test('인증된 API 호출 테스트', () async {
|
||||
// print('\n[TEST] 인증된 API 호출 테스트...');
|
||||
|
||||
try {
|
||||
// 현재 사용자 정보 조회
|
||||
final response = await apiClient.dio.get('/me');
|
||||
|
||||
// print('[TEST] 현재 사용자 정보:');
|
||||
// print('[TEST] - ID: ${response.data['data']['id']}');
|
||||
// print('[TEST] - Email: ${response.data['data']['email']}');
|
||||
// print('[TEST] - Name: ${response.data['data']['first_name']} ${response.data['data']['last_name']}');
|
||||
// print('[TEST] - Role: ${response.data['data']['role']}');
|
||||
|
||||
expect(response.statusCode, equals(200));
|
||||
expect(response.data['success'], equals(true));
|
||||
|
||||
// print('[TEST] ✅ 인증된 API 호출 성공!');
|
||||
} catch (e) {
|
||||
// print('[TEST] ❌ 인증된 API 호출 실패: $e');
|
||||
if (e is DioException) {
|
||||
// print('[TEST] - 응답: ${e.response?.data}');
|
||||
// print('[TEST] - 상태 코드: ${e.response?.statusCode}');
|
||||
}
|
||||
rethrow;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user