feat: 결재·마스터 실연동 업데이트
This commit is contained in:
@@ -7,11 +7,15 @@ import 'package:shadcn_ui/shadcn_ui.dart';
|
||||
import 'package:superport_v2/core/common/models/paginated_result.dart';
|
||||
import 'package:superport_v2/core/config/environment.dart';
|
||||
import 'package:superport_v2/core/permissions/permission_manager.dart';
|
||||
import 'package:superport_v2/core/permissions/permission_resources.dart';
|
||||
import 'package:superport_v2/features/approvals/domain/entities/approval.dart';
|
||||
import 'package:superport_v2/features/approvals/domain/entities/approval_template.dart';
|
||||
import 'package:superport_v2/features/approvals/domain/entities/approval_proceed_status.dart';
|
||||
import 'package:superport_v2/features/approvals/domain/repositories/approval_repository.dart';
|
||||
import 'package:superport_v2/features/approvals/domain/repositories/approval_template_repository.dart';
|
||||
import 'package:superport_v2/features/approvals/presentation/pages/approval_page.dart';
|
||||
import 'package:superport_v2/features/inventory/lookups/domain/entities/lookup_item.dart';
|
||||
import 'package:superport_v2/features/inventory/lookups/domain/repositories/inventory_lookup_repository.dart';
|
||||
|
||||
import '../../helpers/test_app.dart';
|
||||
|
||||
@@ -42,12 +46,14 @@ void main() {
|
||||
testWidgets('결재 단계 액션은 승인 권한이 없으면 비활성화된다', (tester) async {
|
||||
final repo = _StubApprovalRepository();
|
||||
final templateRepo = _StubApprovalTemplateRepository();
|
||||
final lookupRepo = _StubInventoryLookupRepository();
|
||||
GetIt.I.registerSingleton<ApprovalRepository>(repo);
|
||||
GetIt.I.registerSingleton<ApprovalTemplateRepository>(templateRepo);
|
||||
GetIt.I.registerSingleton<InventoryLookupRepository>(lookupRepo);
|
||||
|
||||
final permissionManager = PermissionManager(
|
||||
overrides: {
|
||||
'/approvals/requests': {PermissionAction.view},
|
||||
PermissionResources.approvals: {PermissionAction.view},
|
||||
},
|
||||
);
|
||||
|
||||
@@ -83,12 +89,14 @@ void main() {
|
||||
testWidgets('승인 권한이 있으면 단계 액션을 실행할 수 있다', (tester) async {
|
||||
final repo = _StubApprovalRepository();
|
||||
final templateRepo = _StubApprovalTemplateRepository();
|
||||
final lookupRepo = _StubInventoryLookupRepository();
|
||||
GetIt.I.registerSingleton<ApprovalRepository>(repo);
|
||||
GetIt.I.registerSingleton<ApprovalTemplateRepository>(templateRepo);
|
||||
GetIt.I.registerSingleton<InventoryLookupRepository>(lookupRepo);
|
||||
|
||||
final permissionManager = PermissionManager(
|
||||
overrides: {
|
||||
'/approvals/requests': {
|
||||
PermissionResources.approvals: {
|
||||
PermissionAction.view,
|
||||
PermissionAction.approve,
|
||||
},
|
||||
@@ -115,6 +123,44 @@ void main() {
|
||||
expect(approveButton.onPressed, isNotNull);
|
||||
expect(find.text('결재 권한이 없어 단계 행위를 실행할 수 없습니다.'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('canProceed가 false면 단계 버튼을 비활성화하고 이유를 안내한다', (tester) async {
|
||||
final repo = _BlockingApprovalRepository();
|
||||
final templateRepo = _StubApprovalTemplateRepository();
|
||||
final lookupRepo = _StubInventoryLookupRepository();
|
||||
GetIt.I.registerSingleton<ApprovalRepository>(repo);
|
||||
GetIt.I.registerSingleton<ApprovalTemplateRepository>(templateRepo);
|
||||
GetIt.I.registerSingleton<InventoryLookupRepository>(lookupRepo);
|
||||
|
||||
final permissionManager = PermissionManager(
|
||||
overrides: {
|
||||
PermissionResources.approvals: {
|
||||
PermissionAction.view,
|
||||
PermissionAction.approve,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
await pumpApprovalPage(tester, permissionManager);
|
||||
|
||||
final rowFinder = find.byKey(const ValueKey('approval_row_1'));
|
||||
expect(rowFinder, findsOneWidget);
|
||||
|
||||
await tester.tap(rowFinder);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final tabContext = tester.element(find.byType(TabBar));
|
||||
final tabController = DefaultTabController.of(tabContext);
|
||||
tabController.animateTo(1);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.textContaining('선행 단계가 완료되지 않았습니다.'), findsWidgets);
|
||||
|
||||
final approveButton = tester.widget<ShadButton>(
|
||||
find.byKey(const ValueKey('step_action_100_approve')),
|
||||
);
|
||||
expect(approveButton.onPressed, isNull);
|
||||
});
|
||||
}
|
||||
|
||||
class _StubApprovalRepository implements ApprovalRepository {
|
||||
@@ -194,6 +240,11 @@ class _StubApprovalRepository implements ApprovalRepository {
|
||||
return _approval;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<ApprovalProceedStatus> canProceed(int id) async {
|
||||
return ApprovalProceedStatus(approvalId: id, canProceed: true);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Approval> create(ApprovalInput input) {
|
||||
throw UnimplementedError();
|
||||
@@ -215,6 +266,17 @@ class _StubApprovalRepository implements ApprovalRepository {
|
||||
}
|
||||
}
|
||||
|
||||
class _BlockingApprovalRepository extends _StubApprovalRepository {
|
||||
@override
|
||||
Future<ApprovalProceedStatus> canProceed(int id) async {
|
||||
return ApprovalProceedStatus(
|
||||
approvalId: id,
|
||||
canProceed: false,
|
||||
reason: '선행 단계가 완료되지 않았습니다. 관리자에게 문의하세요.',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _StubApprovalTemplateRepository implements ApprovalTemplateRepository {
|
||||
_StubApprovalTemplateRepository();
|
||||
|
||||
@@ -285,3 +347,45 @@ class _StubApprovalTemplateRepository implements ApprovalTemplateRepository {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
}
|
||||
|
||||
class _StubInventoryLookupRepository implements InventoryLookupRepository {
|
||||
@override
|
||||
Future<List<LookupItem>> fetchTransactionTypes({
|
||||
bool activeOnly = true,
|
||||
}) async {
|
||||
return <LookupItem>[
|
||||
LookupItem(id: 1, name: '입고', code: 'INBOUND'),
|
||||
LookupItem(id: 2, name: '출고', code: 'OUTBOUND'),
|
||||
];
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<LookupItem>> fetchTransactionStatuses({
|
||||
bool activeOnly = true,
|
||||
}) async {
|
||||
return <LookupItem>[
|
||||
LookupItem(id: 10, name: '승인대기', code: 'pending'),
|
||||
LookupItem(id: 11, name: '진행중', code: 'in_progress'),
|
||||
];
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<LookupItem>> fetchApprovalStatuses({
|
||||
bool activeOnly = true,
|
||||
}) async {
|
||||
return <LookupItem>[
|
||||
LookupItem(id: 20, name: '승인대기', code: 'pending'),
|
||||
LookupItem(id: 21, name: '진행중', code: 'in_progress'),
|
||||
];
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<LookupItem>> fetchApprovalActions({
|
||||
bool activeOnly = true,
|
||||
}) async {
|
||||
return <LookupItem>[
|
||||
LookupItem(id: 30, name: '승인', code: 'approve'),
|
||||
LookupItem(id: 31, name: '반려', code: 'reject'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user