feat(menu-permissions): 메뉴 API 연동으로 사이드바 권한 정비

- .env.development.example과 lib/core/config/environment.dart, lib/core/permissions/permission_manager.dart에서 PERMISSION__ 폴백을 view 전용으로 좁히고 기본 정책을 명시적으로 거부하도록 재정비했다

- lib/core/navigation/*, lib/core/routing/app_router.dart, lib/widgets/app_shell.dart, lib/main.dart에서 메뉴 매니페스트·카탈로그를 도입해 /menus 응답을 캐싱하고 라우터·사이드바·Breadcrumb가 동일 menu_code/route_path를 쓰도록 리팩터링했다

- lib/core/permissions/permission_resources.dart와 그룹 권한/메뉴 마스터 모듈을 menu_code 기반 CRUD 및 Catalog 경로 정합성 검사로 전환하고 PermissionSynchronizer·PermissionBootstrapper를 확장했다

- test/helpers/test_permissions.dart, test/widgets/app_shell_test.dart 등 신규 구조를 반영하는 테스트·골든과 doc/frontend_menu_permission_tasks.md 문서를 보강했다
This commit is contained in:
JiWoong Sul
2025-11-12 18:29:03 +09:00
parent f767c44573
commit 753f76e952
72 changed files with 1914 additions and 704 deletions

View File

@@ -5,6 +5,7 @@ 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/navigation/route_paths.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';
@@ -13,6 +14,11 @@ import 'package:superport_v2/widgets/components/form_field.dart';
import '../../helpers/inventory_test_stubs.dart';
Future<void> _tapVisible(WidgetTester tester, Finder finder) async {
await tester.ensureVisible(finder);
await tester.tap(finder);
}
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
@@ -40,10 +46,10 @@ void main() {
});
final router = GoRouter(
initialLocation: '/inventory/inbound',
initialLocation: inventoryReceiptsRoutePath,
routes: [
GoRoute(
path: '/inventory/inbound',
path: inventoryReceiptsRoutePath,
builder: (context, state) =>
Scaffold(body: InboundPage(routeUri: state.uri)),
),
@@ -68,13 +74,13 @@ void main() {
await tester.enterText(find.byType(EditableText).first, 'TX-20240305-010');
await tester.pump();
await tester.tap(find.widgetWithText(ShadButton, '검색 적용'));
await _tapVisible(tester, 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 _tapVisible(tester, find.widgetWithText(ShadButton, '초기화'));
await tester.pumpAndSettle();
expect(find.text('TX-20240301-001'), findsWidgets);
@@ -97,7 +103,7 @@ void main() {
child: ShadTheme(
data: SuperportShadTheme.light(),
child: Scaffold(
body: InboundPage(routeUri: Uri.parse('/inventory/inbound')),
body: InboundPage(routeUri: Uri.parse(inventoryReceiptsRoutePath)),
),
),
),
@@ -106,7 +112,7 @@ void main() {
);
await tester.pumpAndSettle();
await tester.tap(find.widgetWithText(ShadButton, '입고 등록'));
await _tapVisible(tester, find.widgetWithText(ShadButton, '입고 등록'));
await tester.pumpAndSettle();
final transactionField = find.byWidgetPredicate(
@@ -140,12 +146,11 @@ void main() {
);
await tester.enterText(firstProductInput, 'XR-5000');
await tester.pumpAndSettle();
await tester.tap(find.text('XR-5000').last);
await _tapVisible(tester, find.text('XR-5000').last);
await tester.pumpAndSettle();
final addLineButton = find.widgetWithText(ShadButton, '품목 추가');
await tester.ensureVisible(addLineButton);
await tester.tap(addLineButton);
await _tapVisible(tester, addLineButton);
await tester.pumpAndSettle();
final updatedProductFields = find.byType(InventoryProductAutocompleteField);
@@ -157,12 +162,11 @@ void main() {
);
await tester.enterText(secondProductInput, 'XR-5000');
await tester.pumpAndSettle();
await tester.tap(find.text('XR-5000').last);
await _tapVisible(tester, find.text('XR-5000').last);
await tester.pumpAndSettle();
final saveButton = find.widgetWithText(ShadButton, '저장');
await tester.ensureVisible(saveButton);
await tester.tap(saveButton);
await _tapVisible(tester, saveButton);
await tester.pumpAndSettle();
expect(find.text('동일 제품이 중복되었습니다.'), findsOneWidget);
@@ -185,7 +189,7 @@ void main() {
child: ShadTheme(
data: SuperportShadTheme.light(),
child: Scaffold(
body: InboundPage(routeUri: Uri.parse('/inventory/inbound')),
body: InboundPage(routeUri: Uri.parse(inventoryReceiptsRoutePath)),
),
),
),
@@ -194,12 +198,12 @@ void main() {
);
await tester.pumpAndSettle();
await tester.tap(find.widgetWithText(ShadButton, '입고 등록'));
await _tapVisible(tester, find.widgetWithText(ShadButton, '입고 등록'));
await tester.pumpAndSettle();
expect(find.text('저장 시 자동 생성'), findsAtLeastNWidgets(2));
await tester.tap(find.widgetWithText(ShadButton, '저장'));
await _tapVisible(tester, find.widgetWithText(ShadButton, '저장'));
await tester.pump();
expect(find.text('거래번호를 입력하세요.'), findsNothing);
@@ -225,7 +229,7 @@ void main() {
child: ShadTheme(
data: SuperportShadTheme.light(),
child: Scaffold(
body: InboundPage(routeUri: Uri.parse('/inventory/inbound')),
body: InboundPage(routeUri: Uri.parse(inventoryReceiptsRoutePath)),
),
),
),
@@ -234,14 +238,14 @@ void main() {
);
await tester.pumpAndSettle();
await tester.tap(find.text('TX-20240301-001').first);
await _tapVisible(tester, find.text('TX-20240301-001').first);
await tester.pumpAndSettle();
expect(find.text('입고 상세'), findsOneWidget);
final editButton = find.widgetWithText(ShadButton, '수정').last;
await tester.ensureVisible(editButton);
await tester.tap(editButton);
await _tapVisible(tester, editButton);
await tester.pump();
await tester.pumpAndSettle(const Duration(milliseconds: 500));