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:
128
test/integration/automated/equipment_simple_test.dart
Normal file
128
test/integration/automated/equipment_simple_test.dart
Normal file
@@ -0,0 +1,128 @@
|
||||
import 'package:test/test.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:superport/data/datasources/remote/api_client.dart';
|
||||
import 'framework/core/auto_test_system.dart';
|
||||
import 'framework/core/api_error_diagnostics.dart';
|
||||
import 'framework/core/auto_fixer.dart';
|
||||
import 'framework/core/test_data_generator.dart';
|
||||
import 'framework/infrastructure/report_collector.dart';
|
||||
import '../real_api/test_helper.dart';
|
||||
|
||||
/// 간단한 장비 API 테스트
|
||||
void main() {
|
||||
group('장비 API 테스트', () {
|
||||
late AutoTestSystem autoTestSystem;
|
||||
late ApiClient apiClient;
|
||||
late GetIt getIt;
|
||||
|
||||
setUpAll(() async {
|
||||
// 테스트 환경 설정 중...
|
||||
|
||||
// 환경 초기화
|
||||
await RealApiTestHelper.setupTestEnvironment();
|
||||
getIt = GetIt.instance;
|
||||
apiClient = getIt.get<ApiClient>();
|
||||
|
||||
// 자동 테스트 시스템 초기화
|
||||
autoTestSystem = AutoTestSystem(
|
||||
apiClient: apiClient,
|
||||
getIt: getIt,
|
||||
errorDiagnostics: ApiErrorDiagnostics(),
|
||||
autoFixer: ApiAutoFixer(diagnostics: ApiErrorDiagnostics()),
|
||||
dataGenerator: TestDataGenerator(),
|
||||
reportCollector: ReportCollector(),
|
||||
);
|
||||
|
||||
// 인증
|
||||
await autoTestSystem.ensureAuthenticated();
|
||||
});
|
||||
|
||||
tearDownAll(() async {
|
||||
await RealApiTestHelper.teardownTestEnvironment();
|
||||
});
|
||||
|
||||
test('장비 목록 조회', () async {
|
||||
final result = await autoTestSystem.runTestWithAutoFix(
|
||||
testName: '장비 목록 조회',
|
||||
screenName: 'Equipment',
|
||||
testFunction: () async {
|
||||
// [TEST] 장비 목록 조회 시작...
|
||||
|
||||
final response = await apiClient.dio.get(
|
||||
'/equipment',
|
||||
queryParameters: {
|
||||
'page': 1,
|
||||
'per_page': 10,
|
||||
},
|
||||
);
|
||||
|
||||
// print('[TEST] 응답 상태: ${response.statusCode}');
|
||||
// print('[TEST] 응답 데이터: ${response.data}');
|
||||
|
||||
expect(response.statusCode, equals(200));
|
||||
expect(response.data['success'], equals(true));
|
||||
|
||||
if (response.data['data'] != null) {
|
||||
final equipmentList = response.data['data'] as List;
|
||||
// print('[TEST] 조회된 장비 수: ${equipmentList.length}');
|
||||
|
||||
if (equipmentList.isNotEmpty) {
|
||||
// 첫 번째 장비 데이터 검증을 위한 참조
|
||||
// print('[TEST] 첫 번째 장비:');
|
||||
// print('[TEST] - ID: ${firstEquipment['id']}');
|
||||
// print('[TEST] - Serial: ${firstEquipment['serial_number']}');
|
||||
// print('[TEST] - Name: ${firstEquipment['name']}');
|
||||
// print('[TEST] - Status: ${firstEquipment['status']}');
|
||||
}
|
||||
}
|
||||
|
||||
// print('[TEST] ✅ 장비 목록 조회 성공');
|
||||
},
|
||||
);
|
||||
|
||||
expect(result.passed, isTrue);
|
||||
});
|
||||
|
||||
test('새 장비 생성', () async {
|
||||
final result = await autoTestSystem.runTestWithAutoFix(
|
||||
testName: '새 장비 생성',
|
||||
screenName: 'Equipment',
|
||||
testFunction: () async {
|
||||
// print('[TEST] 새 장비 생성 시작...');
|
||||
|
||||
// 테스트 데이터 생성
|
||||
final equipmentData = await autoTestSystem.generateTestData('equipment');
|
||||
// print('[TEST] 생성할 장비 데이터: $equipmentData');
|
||||
|
||||
final response = await apiClient.dio.post(
|
||||
'/equipment',
|
||||
data: equipmentData,
|
||||
);
|
||||
|
||||
// print('[TEST] 응답 상태: ${response.statusCode}');
|
||||
// print('[TEST] 응답 데이터: ${response.data}');
|
||||
|
||||
expect(response.statusCode, equals(201));
|
||||
expect(response.data['success'], equals(true));
|
||||
|
||||
if (response.data['data'] != null) {
|
||||
final createdEquipment = response.data['data'];
|
||||
// print('[TEST] 생성된 장비:');
|
||||
// print('[TEST] - ID: ${createdEquipment['id']}');
|
||||
// print('[TEST] - Serial: ${createdEquipment['serial_number']}');
|
||||
|
||||
// 정리를 위해 ID 저장
|
||||
if (createdEquipment['id'] != null) {
|
||||
// 나중에 삭제하기 위해 저장
|
||||
// print('[TEST] 장비 ID ${createdEquipment['id']} 저장됨');
|
||||
}
|
||||
}
|
||||
|
||||
// print('[TEST] ✅ 새 장비 생성 성공');
|
||||
},
|
||||
);
|
||||
|
||||
expect(result.passed, isTrue);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user