test: 통합 테스트 오류 및 경고 수정
Some checks failed
Flutter Test & Quality Check / Test on macos-latest (push) Has been cancelled
Flutter Test & Quality Check / Test on ubuntu-latest (push) Has been cancelled
Flutter Test & Quality Check / Build APK (push) Has been cancelled

- 모든 서비스 메서드 시그니처를 실제 구현에 맞게 수정
- 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:
JiWoong Sul
2025-08-05 20:24:05 +09:00
parent d6f34c0a52
commit 198aac6525
145 changed files with 41527 additions and 5220 deletions

View File

@@ -0,0 +1,162 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:get_it/get_it.dart';
import 'package:superport/models/company_model.dart';
import 'package:superport/models/address_model.dart';
import 'package:superport/services/company_service.dart';
import 'package:superport/services/auth_service.dart';
import './real_api/test_helper.dart';
/// 회사 관리 간단 데모 테스트
///
/// 핵심 기능만 보여주는 간단한 버전:
/// 1. 회사 생성
/// 2. 회사 조회
/// 3. 회사 수정
/// 4. 회사 삭제
void main() {
late CompanyService companyService;
late AuthService authService;
int? createdCompanyId;
setUpAll(() async {
print('\n🚀 회사 관리 데모 시작\n');
// 환경 설정
await RealApiTestHelper.setupTestEnvironment();
// 서비스 가져오기
companyService = GetIt.instance<CompanyService>();
authService = GetIt.instance<AuthService>();
// 로그인
print('🔐 로그인 중...');
await RealApiTestHelper.loginAndGetToken();
print('✅ 로그인 완료!\n');
});
tearDownAll(() async {
// 생성한 회사 정리
if (createdCompanyId != null) {
try {
await companyService.deleteCompany(createdCompanyId!);
print('\n🧹 테스트 회사 삭제 완료');
} catch (e) {
// 삭제 실패는 무시
}
}
await RealApiTestHelper.teardownTestEnvironment();
print('\n👋 회사 관리 데모 종료\n');
});
test('회사 관리 간단 데모', () async {
// 1. 회사 생성
print(' 1단계: 새 회사 생성');
print('━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
final timestamp = DateTime.now().millisecondsSinceEpoch;
final newCompany = Company(
name: '삼성전자 TEST_$timestamp',
address: Address(
zipCode: '06164',
region: '서울특별시 강남구',
detailAddress: '테헤란로 142, 삼성빌딩 10층',
),
contactName: '김철수',
contactPosition: '과장',
contactPhone: '02-1234-5678',
contactEmail: 'test@samsung-test.com',
companyTypes: [CompanyType.customer],
remark: '데모 테스트용 회사',
);
print(' 회사명: ${newCompany.name}');
print(' 주소: ${newCompany.address.toString()}');
print(' 담당자: ${newCompany.contactName} ${newCompany.contactPosition}');
final created = await companyService.createCompany(newCompany);
createdCompanyId = created.id;
print('\n✅ 회사 생성 성공! (ID: $createdCompanyId)\n');
// 잠시 대기
await Future.delayed(Duration(seconds: 2));
// 2. 회사 목록 조회
print('📋 2단계: 회사 목록 조회');
print('━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
final companies = await companyService.getCompanies(
page: 1,
perPage: 5,
);
print(' 전체 ${companies.length}개 회사 중 최근 3개:');
for (var i = 0; i < companies.length && i < 3; i++) {
final company = companies[i];
print(' ${i + 1}. ${company.name}');
}
print('');
// 3. 회사 상세 조회
print('🔍 3단계: 회사 상세 정보 확인');
print('━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
final detail = await companyService.getCompanyDetail(createdCompanyId!);
print(' 회사명: ${detail.name}');
print(' 주소: ${detail.address.toString()}');
print(' 담당자: ${detail.contactName} ${detail.contactPosition}');
print(' 연락처: ${detail.contactPhone}');
print(' 이메일: ${detail.contactEmail}');
print(' 회사 유형: ${detail.companyTypes.map((t) => companyTypeToString(t)).join(', ')}');
print('');
// 잠시 대기
await Future.delayed(Duration(seconds: 2));
// 4. 회사 정보 수정
print('✏️ 4단계: 회사 정보 수정');
print('━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
print(' 변경 전 연락처: ${detail.contactPhone}');
print(' 변경 전 이메일: ${detail.contactEmail}');
final updated = detail.copyWith(
contactPhone: '02-9999-8888',
contactEmail: 'updated@samsung-test.com',
companyTypes: [CompanyType.customer, CompanyType.partner],
);
final result = await companyService.updateCompany(createdCompanyId!, updated);
print('\n 변경 후 연락처: ${result.contactPhone}');
print(' 변경 후 이메일: ${result.contactEmail}');
print(' 변경 후 회사 유형: ${result.companyTypes.map((t) => companyTypeToString(t)).join(', ')}');
print('\n✅ 회사 정보 수정 완료!\n');
// 5. 회사 검색
print('🔎 5단계: 회사 검색');
print('━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
print(' 검색어: "삼성"');
final searchResults = await companyService.getCompanies(
page: 1,
perPage: 5,
search: '삼성',
);
print(' 검색 결과: ${searchResults.length}');
for (var i = 0; i < searchResults.length && i < 3; i++) {
print(' - ${searchResults[i].name}');
}
print('\n🎉 회사 관리 데모 완료!');
print('━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
print('✅ 회사 생성');
print('✅ 회사 조회');
print('✅ 회사 수정');
print('✅ 회사 검색');
print('━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
}, timeout: Timeout(Duration(minutes: 5)));
}