- 모든 서비스 메서드 시그니처를 실제 구현에 맞게 수정 - 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
98 lines
2.6 KiB
Dart
98 lines
2.6 KiB
Dart
/// 테스트 컨텍스트 - 테스트 실행 중 상태와 데이터를 관리
|
|
class TestContext {
|
|
final Map<String, dynamic> _data = {};
|
|
final List<String> _createdResourceIds = [];
|
|
final Map<String, List<String>> _resourcesByType = {};
|
|
final Map<String, dynamic> _config = {};
|
|
String? currentScreen;
|
|
|
|
/// 데이터 저장
|
|
void setData(String key, dynamic value) {
|
|
_data[key] = value;
|
|
}
|
|
|
|
/// 데이터 조회
|
|
dynamic getData(String key) {
|
|
return _data[key];
|
|
}
|
|
|
|
/// 모든 데이터 조회
|
|
Map<String, dynamic> getAllData() {
|
|
return Map.from(_data);
|
|
}
|
|
|
|
/// 생성된 리소스 ID 추가
|
|
void addCreatedResourceId(String resourceType, String id) {
|
|
_createdResourceIds.add('$resourceType:$id');
|
|
_resourcesByType.putIfAbsent(resourceType, () => []).add(id);
|
|
}
|
|
|
|
/// 특정 타입의 생성된 리소스 ID 목록 조회
|
|
List<String> getCreatedResourceIds(String resourceType) {
|
|
return _resourcesByType[resourceType] ?? [];
|
|
}
|
|
|
|
/// 모든 생성된 리소스 ID 조회
|
|
List<String> getAllCreatedResourceIds() {
|
|
return List.from(_createdResourceIds);
|
|
}
|
|
|
|
/// 생성된 리소스 ID 제거
|
|
void removeCreatedResourceId(String resourceType, String id) {
|
|
final resourceKey = '$resourceType:$id';
|
|
_createdResourceIds.remove(resourceKey);
|
|
_resourcesByType[resourceType]?.remove(id);
|
|
}
|
|
|
|
/// 컨텍스트 초기화
|
|
void clear() {
|
|
_data.clear();
|
|
_createdResourceIds.clear();
|
|
_resourcesByType.clear();
|
|
}
|
|
|
|
/// 특정 키의 데이터 존재 여부 확인
|
|
bool hasData(String key) {
|
|
return _data.containsKey(key);
|
|
}
|
|
|
|
/// 특정 키의 데이터 제거
|
|
void removeData(String key) {
|
|
_data.remove(key);
|
|
}
|
|
|
|
/// 현재 상태 스냅샷
|
|
Map<String, dynamic> snapshot() {
|
|
return {
|
|
'data': Map.from(_data),
|
|
'createdResources': List.from(_createdResourceIds),
|
|
'resourcesByType': Map.from(_resourcesByType),
|
|
};
|
|
}
|
|
|
|
/// 스냅샷에서 복원
|
|
void restore(Map<String, dynamic> snapshot) {
|
|
_data.clear();
|
|
_data.addAll(snapshot['data'] ?? {});
|
|
|
|
_createdResourceIds.clear();
|
|
_createdResourceIds.addAll(List<String>.from(snapshot['createdResources'] ?? []));
|
|
|
|
_resourcesByType.clear();
|
|
final resourcesByType = snapshot['resourcesByType'] as Map<String, dynamic>? ?? {};
|
|
resourcesByType.forEach((key, value) {
|
|
_resourcesByType[key] = List<String>.from(value as List);
|
|
});
|
|
}
|
|
|
|
|
|
/// 설정값 저장
|
|
void setConfig(String key, dynamic value) {
|
|
_config[key] = value;
|
|
}
|
|
|
|
/// 설정값 조회
|
|
dynamic getConfig(String key) {
|
|
return _config[key];
|
|
}
|
|
} |