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:
@@ -11,7 +11,7 @@ import 'package:superport/core/errors/failures.dart';
|
||||
class WarehouseLocationListController extends ChangeNotifier {
|
||||
final bool useApi;
|
||||
final MockDataService? mockDataService;
|
||||
late final WarehouseService _warehouseService;
|
||||
WarehouseService? _warehouseService;
|
||||
|
||||
List<WarehouseLocation> _warehouseLocations = [];
|
||||
List<WarehouseLocation> _filteredLocations = [];
|
||||
@@ -55,15 +55,18 @@ class WarehouseLocationListController extends ChangeNotifier {
|
||||
_currentPage = 1;
|
||||
_warehouseLocations.clear();
|
||||
_hasMore = true;
|
||||
} else {
|
||||
// 다음 페이지를 로드할 때는 페이지 번호를 먼저 증가
|
||||
_currentPage++;
|
||||
}
|
||||
|
||||
notifyListeners();
|
||||
|
||||
try {
|
||||
if (useApi && GetIt.instance.isRegistered<WarehouseService>()) {
|
||||
if (useApi && _warehouseService != null) {
|
||||
// API 사용
|
||||
print('[WarehouseLocationListController] Using API to fetch warehouse locations');
|
||||
final fetchedLocations = await _warehouseService.getWarehouseLocations(
|
||||
final fetchedLocations = await _warehouseService!.getWarehouseLocations(
|
||||
page: _currentPage,
|
||||
perPage: _pageSize,
|
||||
isActive: _isActive,
|
||||
@@ -80,7 +83,7 @@ class WarehouseLocationListController extends ChangeNotifier {
|
||||
_hasMore = fetchedLocations.length >= _pageSize;
|
||||
|
||||
// 전체 개수 조회
|
||||
_total = await _warehouseService.getTotalWarehouseLocations(
|
||||
_total = await _warehouseService!.getTotalWarehouseLocations(
|
||||
isActive: _isActive,
|
||||
);
|
||||
print('[WarehouseLocationListController] Total warehouse locations: $_total');
|
||||
@@ -123,10 +126,6 @@ class WarehouseLocationListController extends ChangeNotifier {
|
||||
|
||||
_applySearchFilter();
|
||||
print('[WarehouseLocationListController] After filtering: ${_filteredLocations.length} locations shown');
|
||||
|
||||
if (!isInitialLoad) {
|
||||
_currentPage++;
|
||||
}
|
||||
} catch (e, stackTrace) {
|
||||
print('[WarehouseLocationListController] Error loading warehouse locations: $e');
|
||||
print('[WarehouseLocationListController] Error type: ${e.runtimeType}');
|
||||
@@ -146,7 +145,6 @@ class WarehouseLocationListController extends ChangeNotifier {
|
||||
// 다음 페이지 로드
|
||||
Future<void> loadNextPage() async {
|
||||
if (!_hasMore || _isLoading) return;
|
||||
_currentPage++;
|
||||
await loadWarehouseLocations(isInitialLoad: false);
|
||||
}
|
||||
|
||||
@@ -185,8 +183,8 @@ class WarehouseLocationListController extends ChangeNotifier {
|
||||
/// 입고지 추가
|
||||
Future<void> addWarehouseLocation(WarehouseLocation location) async {
|
||||
try {
|
||||
if (useApi && GetIt.instance.isRegistered<WarehouseService>()) {
|
||||
await _warehouseService.createWarehouseLocation(location);
|
||||
if (useApi && _warehouseService != null) {
|
||||
await _warehouseService!.createWarehouseLocation(location);
|
||||
} else {
|
||||
mockDataService?.addWarehouseLocation(location);
|
||||
}
|
||||
@@ -202,8 +200,8 @@ class WarehouseLocationListController extends ChangeNotifier {
|
||||
/// 입고지 수정
|
||||
Future<void> updateWarehouseLocation(WarehouseLocation location) async {
|
||||
try {
|
||||
if (useApi && GetIt.instance.isRegistered<WarehouseService>()) {
|
||||
await _warehouseService.updateWarehouseLocation(location);
|
||||
if (useApi && _warehouseService != null) {
|
||||
await _warehouseService!.updateWarehouseLocation(location);
|
||||
} else {
|
||||
mockDataService?.updateWarehouseLocation(location);
|
||||
}
|
||||
@@ -224,8 +222,8 @@ class WarehouseLocationListController extends ChangeNotifier {
|
||||
/// 입고지 삭제
|
||||
Future<void> deleteWarehouseLocation(int id) async {
|
||||
try {
|
||||
if (useApi && GetIt.instance.isRegistered<WarehouseService>()) {
|
||||
await _warehouseService.deleteWarehouseLocation(id);
|
||||
if (useApi && _warehouseService != null) {
|
||||
await _warehouseService!.deleteWarehouseLocation(id);
|
||||
} else {
|
||||
mockDataService?.deleteWarehouseLocation(id);
|
||||
}
|
||||
@@ -249,8 +247,8 @@ class WarehouseLocationListController extends ChangeNotifier {
|
||||
// 사용 중인 창고 위치 조회
|
||||
Future<List<WarehouseLocation>> getInUseWarehouseLocations() async {
|
||||
try {
|
||||
if (useApi && GetIt.instance.isRegistered<WarehouseService>()) {
|
||||
return await _warehouseService.getInUseWarehouseLocations();
|
||||
if (useApi && _warehouseService != null) {
|
||||
return await _warehouseService!.getInUseWarehouseLocations();
|
||||
} else {
|
||||
// Mock 데이터에서는 모든 창고가 사용 중으로 간주
|
||||
return mockDataService?.getAllWarehouseLocations() ?? [];
|
||||
|
||||
@@ -298,27 +298,41 @@ class _WarehouseLocationListRedesignState
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
IconButton(
|
||||
icon: Icon(
|
||||
Icons.edit,
|
||||
size: 16,
|
||||
color: ShadcnTheme.primary,
|
||||
Flexible(
|
||||
child: IconButton(
|
||||
constraints: const BoxConstraints(
|
||||
minWidth: 30,
|
||||
minHeight: 30,
|
||||
),
|
||||
padding: const EdgeInsets.all(4),
|
||||
icon: Icon(
|
||||
Icons.edit,
|
||||
size: 16,
|
||||
color: ShadcnTheme.primary,
|
||||
),
|
||||
onPressed: () => _navigateToEdit(location),
|
||||
tooltip: '수정',
|
||||
),
|
||||
onPressed: () => _navigateToEdit(location),
|
||||
tooltip: '수정',
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(
|
||||
Icons.delete,
|
||||
size: 16,
|
||||
color: ShadcnTheme.destructive,
|
||||
Flexible(
|
||||
child: IconButton(
|
||||
constraints: const BoxConstraints(
|
||||
minWidth: 30,
|
||||
minHeight: 30,
|
||||
),
|
||||
padding: const EdgeInsets.all(4),
|
||||
icon: Icon(
|
||||
Icons.delete,
|
||||
size: 16,
|
||||
color: ShadcnTheme.destructive,
|
||||
),
|
||||
onPressed:
|
||||
location.id != null
|
||||
? () =>
|
||||
_showDeleteDialog(location.id!)
|
||||
: null,
|
||||
tooltip: '삭제',
|
||||
),
|
||||
onPressed:
|
||||
location.id != null
|
||||
? () =>
|
||||
_showDeleteDialog(location.id!)
|
||||
: null,
|
||||
tooltip: '삭제',
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user