Files
superport_v2/test/features/inventory/inbound_page_test.dart
JiWoong Sul d76f765814 feat(approvals): Approval Flow v2 프런트엔드 전면 개편
- 환경/라우터 모듈에 approval_flow_v2 토글을 추가하고 FeatureFlags 초기화를 연결 (.env*, lib/core/**)
- ApiClient 빌더·ApiRoutes 확장과 ApprovalRepositoryRemote 리팩터링으로 include·액션 시그니처를 정합화
- ApprovalFlow·ApprovalDraft 엔티티/레포/유즈케이스를 도입해 서버 초안과 단계 액션(승인·회수·재상신)을 지원
- Approval 컨트롤러·히스토리·템플릿 페이지와 공유 위젯을 재작성해 감사 로그·회수 UX·템플릿 CRUD를 반영
- Inbound/Outbound/Rental 컨트롤러·페이지에 결재 섹션을 삽입하고 대시보드 pending 카드 요약을 갱신
- SuperportDialog·FormField 등 공통 위젯을 보강하고 승인 위젯 가이드를 추가해 UI 가이드를 정리
- 결재/재고 테스트 픽스처와 단위·위젯·통합 테스트를 확장하고 flutter_test_config로 스테이징 호스트를 허용
- Approval Flow 레포트/플랜 문서를 업데이트하고 ApprovalFlow_System_Integration_and_ChangePlan.md를 추가
- 실행: flutter analyze, flutter test
2025-10-31 01:05:39 +09:00

211 lines
6.6 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:get_it/get_it.dart';
import 'package:go_router/go_router.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import 'package:superport_v2/core/config/environment.dart';
import 'package:superport_v2/core/permissions/permission_manager.dart';
import 'package:superport_v2/core/theme/superport_shad_theme.dart';
import 'package:superport_v2/features/inventory/inbound/presentation/pages/inbound_page.dart';
import 'package:superport_v2/features/inventory/shared/widgets/product_autocomplete_field.dart';
import 'package:superport_v2/widgets/components/form_field.dart';
import '../../helpers/inventory_test_stubs.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
setUpAll(() async {
await Environment.initialize();
});
setUp(() {
registerInventoryTestStubs(
const InventoryTestStubConfig(registerProductRepository: true),
);
});
tearDown(() async {
await GetIt.I.reset();
});
testWidgets('입고 필터 적용 및 초기화가 목록을 갱신한다', (tester) async {
final view = tester.view;
view.physicalSize = const Size(1280, 800);
view.devicePixelRatio = 1.0;
addTearDown(() {
view.resetPhysicalSize();
view.resetDevicePixelRatio();
});
final router = GoRouter(
initialLocation: '/inventory/inbound',
routes: [
GoRoute(
path: '/inventory/inbound',
builder: (context, state) =>
Scaffold(body: InboundPage(routeUri: state.uri)),
),
],
);
await tester.pumpWidget(
PermissionScope(
manager: PermissionManager(),
child: ShadApp.router(
routerConfig: router,
debugShowCheckedModeBanner: false,
theme: SuperportShadTheme.light(),
darkTheme: SuperportShadTheme.dark(),
),
),
);
await tester.pumpAndSettle();
expect(find.text('TX-20240301-001'), findsWidgets);
await tester.enterText(find.byType(EditableText).first, 'TX-20240305-010');
await tester.pump();
await tester.tap(find.widgetWithText(ShadButton, '검색 적용'));
await tester.pumpAndSettle();
expect(find.text('TX-20240305-010'), findsWidgets);
expect(find.text('TX-20240301-001'), findsNothing);
await tester.tap(find.widgetWithText(ShadButton, '초기화'));
await tester.pumpAndSettle();
expect(find.text('TX-20240301-001'), findsWidgets);
});
testWidgets('입고 등록 모달은 동일 제품 중복을 막는다', (tester) async {
final view = tester.view;
view.physicalSize = const Size(1280, 900);
view.devicePixelRatio = 1.0;
addTearDown(() {
view.resetPhysicalSize();
view.resetDevicePixelRatio();
});
await tester.pumpWidget(
MaterialApp(
home: ScaffoldMessenger(
child: PermissionScope(
manager: PermissionManager(),
child: ShadTheme(
data: SuperportShadTheme.light(),
child: Scaffold(
body: InboundPage(routeUri: Uri.parse('/inventory/inbound')),
),
),
),
),
),
);
await tester.pumpAndSettle();
await tester.tap(find.widgetWithText(ShadButton, '입고 등록'));
await tester.pumpAndSettle();
final transactionField = find.byWidgetPredicate(
(widget) => widget is SuperportFormField && widget.label == '트랜잭션번호',
);
final approvalField = find.byWidgetPredicate(
(widget) => widget is SuperportFormField && widget.label == '결재번호',
);
expect(transactionField, findsOneWidget);
expect(approvalField, findsOneWidget);
expect(
find.descendant(
of: transactionField,
matching: find.byType(EditableText),
),
findsNothing,
);
expect(
find.descendant(of: approvalField, matching: find.byType(EditableText)),
findsNothing,
);
expect(find.text('저장 시 자동 생성'), findsAtLeastNWidgets(2));
final productFields = find.byType(InventoryProductAutocompleteField);
expect(productFields, findsWidgets);
final firstProductInput = find.descendant(
of: productFields.at(0),
matching: find.byType(EditableText),
);
await tester.enterText(firstProductInput, 'XR-5000');
await tester.pumpAndSettle();
await tester.tap(find.text('XR-5000').last);
await tester.pumpAndSettle();
final addLineButton = find.widgetWithText(ShadButton, '품목 추가');
await tester.ensureVisible(addLineButton);
await tester.tap(addLineButton);
await tester.pumpAndSettle();
final updatedProductFields = find.byType(InventoryProductAutocompleteField);
expect(updatedProductFields, findsNWidgets(2));
final secondProductInput = find.descendant(
of: updatedProductFields.at(1),
matching: find.byType(EditableText),
);
await tester.enterText(secondProductInput, 'XR-5000');
await tester.pumpAndSettle();
await tester.tap(find.text('XR-5000').last);
await tester.pumpAndSettle();
final saveButton = find.widgetWithText(ShadButton, '저장');
await tester.ensureVisible(saveButton);
await tester.tap(saveButton);
await tester.pumpAndSettle();
expect(find.text('동일 제품이 중복되었습니다.'), findsOneWidget);
});
testWidgets('입고 등록 모달은 번호 입력 없이 저장 안내만 제공한다', (tester) async {
final view = tester.view;
view.physicalSize = const Size(1280, 900);
view.devicePixelRatio = 1.0;
addTearDown(() {
view.resetPhysicalSize();
view.resetDevicePixelRatio();
});
await tester.pumpWidget(
MaterialApp(
home: ScaffoldMessenger(
child: PermissionScope(
manager: PermissionManager(),
child: ShadTheme(
data: SuperportShadTheme.light(),
child: Scaffold(
body: InboundPage(routeUri: Uri.parse('/inventory/inbound')),
),
),
),
),
),
);
await tester.pumpAndSettle();
await tester.tap(find.widgetWithText(ShadButton, '입고 등록'));
await tester.pumpAndSettle();
expect(find.text('저장 시 자동 생성'), findsAtLeastNWidgets(2));
await tester.tap(find.widgetWithText(ShadButton, '저장'));
await tester.pump();
expect(find.text('거래번호를 입력하세요.'), findsNothing);
expect(find.text('결재번호를 입력하세요.'), findsNothing);
expect(find.textContaining('자동완성에서 선택'), findsOneWidget);
expect(find.textContaining('창고를 선택'), findsOneWidget);
});
}