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:
@@ -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));
|
||||
|
||||
@@ -2,12 +2,15 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:shadcn_ui/shadcn_ui.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';
|
||||
import 'package:superport_v2/features/inventory/outbound/presentation/pages/outbound_page.dart';
|
||||
import 'package:superport_v2/features/inventory/rental/presentation/pages/rental_page.dart';
|
||||
|
||||
import '../../helpers/test_permissions.dart';
|
||||
|
||||
Widget _wrapInventoryPage(Widget child) {
|
||||
return PermissionScope(
|
||||
manager: PermissionManager(),
|
||||
@@ -20,6 +23,10 @@ Widget _wrapInventoryPage(Widget child) {
|
||||
}
|
||||
|
||||
void main() {
|
||||
setUp(() {
|
||||
grantTestPermissions();
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'Inbound page reflects include state from route and closes dialog with Esc',
|
||||
(tester) async {
|
||||
@@ -33,7 +40,9 @@ void main() {
|
||||
|
||||
await tester.pumpWidget(
|
||||
_wrapInventoryPage(
|
||||
InboundPage(routeUri: Uri.parse('/inventory/inbound?include=lines')),
|
||||
InboundPage(
|
||||
routeUri: Uri.parse('$inventoryReceiptsRoutePath?include=lines'),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
@@ -63,7 +72,9 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
_wrapInventoryPage(
|
||||
OutboundPage(
|
||||
routeUri: Uri.parse('/inventory/outbound?include=lines,customers'),
|
||||
routeUri: Uri.parse(
|
||||
'$inventoryIssuesRoutePath?include=lines,customers',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -85,7 +96,9 @@ void main() {
|
||||
|
||||
await tester.pumpWidget(
|
||||
_wrapInventoryPage(
|
||||
RentalPage(routeUri: Uri.parse('/inventory/rental?include=lines')),
|
||||
RentalPage(
|
||||
routeUri: Uri.parse('$inventoryRentalsRoutePath?include=lines'),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -4,12 +4,18 @@ import 'package:get_it/get_it.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/outbound/presentation/pages/outbound_page.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();
|
||||
|
||||
@@ -44,7 +50,9 @@ void main() {
|
||||
child: ShadTheme(
|
||||
data: SuperportShadTheme.light(),
|
||||
child: Scaffold(
|
||||
body: OutboundPage(routeUri: Uri.parse('/inventory/outbound')),
|
||||
body: OutboundPage(
|
||||
routeUri: Uri.parse(inventoryIssuesRoutePath),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -53,12 +61,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);
|
||||
@@ -84,7 +92,9 @@ void main() {
|
||||
child: ShadTheme(
|
||||
data: SuperportShadTheme.light(),
|
||||
child: Scaffold(
|
||||
body: OutboundPage(routeUri: Uri.parse('/inventory/outbound')),
|
||||
body: OutboundPage(
|
||||
routeUri: Uri.parse(inventoryIssuesRoutePath),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -93,14 +103,14 @@ void main() {
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await tester.tap(find.text('TX-20240302-010').first);
|
||||
await _tapVisible(tester, find.text('TX-20240302-010').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));
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:get_it/get_it.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/rental/presentation/pages/rental_page.dart';
|
||||
@@ -44,7 +45,9 @@ void main() {
|
||||
child: ShadTheme(
|
||||
data: SuperportShadTheme.light(),
|
||||
child: Scaffold(
|
||||
body: RentalPage(routeUri: Uri.parse('/inventory/rental')),
|
||||
body: RentalPage(
|
||||
routeUri: Uri.parse(inventoryRentalsRoutePath),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -84,7 +87,9 @@ void main() {
|
||||
child: ShadTheme(
|
||||
data: SuperportShadTheme.light(),
|
||||
child: Scaffold(
|
||||
body: RentalPage(routeUri: Uri.parse('/inventory/rental')),
|
||||
body: RentalPage(
|
||||
routeUri: Uri.parse(inventoryRentalsRoutePath),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 24 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 24 KiB |
@@ -20,6 +20,8 @@ import 'package:superport_v2/features/inventory/summary/presentation/pages/inven
|
||||
import 'package:superport_v2/features/masters/warehouse/domain/entities/warehouse.dart';
|
||||
import 'package:superport_v2/features/masters/warehouse/domain/repositories/warehouse_repository.dart';
|
||||
|
||||
import '../../../../../helpers/test_permissions.dart';
|
||||
|
||||
class _MockInventoryRepository extends Mock implements InventoryRepository {}
|
||||
|
||||
class _MockWarehouseRepository extends Mock implements WarehouseRepository {}
|
||||
@@ -141,6 +143,7 @@ void _stubWarehouseList(_MockWarehouseRepository repository) {
|
||||
|
||||
Future<void> _pumpInventoryPage(WidgetTester tester) async {
|
||||
await tester.binding.setSurfaceSize(const Size(1600, 1200));
|
||||
addTearDown(() => tester.binding.setSurfaceSize(null));
|
||||
await tester.pumpWidget(
|
||||
_buildApp(
|
||||
InventorySummaryPage(
|
||||
@@ -153,7 +156,7 @@ Future<void> _pumpInventoryPage(WidgetTester tester) async {
|
||||
}
|
||||
|
||||
void main() {
|
||||
final binding = TestWidgetsFlutterBinding.ensureInitialized();
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
setUpAll(() {
|
||||
registerFallbackValue(const InventorySummaryFilter());
|
||||
@@ -161,6 +164,7 @@ void main() {
|
||||
});
|
||||
|
||||
setUp(() async {
|
||||
grantTestPermissions(includeWrites: false);
|
||||
final inventoryRepository = _MockInventoryRepository();
|
||||
final warehouseRepository = _MockWarehouseRepository();
|
||||
_registerDependencies(
|
||||
@@ -178,7 +182,6 @@ void main() {
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await binding.setSurfaceSize(null);
|
||||
await GetIt.I.reset();
|
||||
});
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@ import 'package:superport_v2/features/inventory/summary/presentation/pages/inven
|
||||
import 'package:superport_v2/features/masters/warehouse/domain/entities/warehouse.dart';
|
||||
import 'package:superport_v2/features/masters/warehouse/domain/repositories/warehouse_repository.dart';
|
||||
|
||||
import '../../../../../helpers/test_permissions.dart';
|
||||
|
||||
class _MockInventoryRepository extends Mock implements InventoryRepository {}
|
||||
|
||||
class _MockWarehouseRepository extends Mock implements WarehouseRepository {}
|
||||
@@ -149,6 +151,11 @@ InventoryDetail _buildDetail() {
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _tapVisible(WidgetTester tester, Finder finder) async {
|
||||
await tester.ensureVisible(finder);
|
||||
await tester.tap(finder);
|
||||
}
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
@@ -157,6 +164,10 @@ void main() {
|
||||
registerFallbackValue(const InventoryDetailFilter());
|
||||
});
|
||||
|
||||
setUp(() {
|
||||
grantTestPermissions();
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await GetIt.I.reset();
|
||||
});
|
||||
@@ -201,7 +212,7 @@ void main() {
|
||||
|
||||
expect(listCallCount, 2);
|
||||
|
||||
await tester.tap(find.bySemanticsLabel('자동 새로고침 전환'));
|
||||
await _tapVisible(tester, find.bySemanticsLabel('자동 새로고침 전환'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await tester.pump(const Duration(seconds: 31));
|
||||
@@ -236,13 +247,16 @@ void main() {
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await tester.tap(find.text('테스트 장비'));
|
||||
await _tapVisible(tester, find.text('테스트 장비'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('창고 잔량'), findsOneWidget);
|
||||
expect(find.byType(LinearProgressIndicator), findsWidgets);
|
||||
expect(find.text('최근 이벤트'), findsOneWidget);
|
||||
expect(find.textContaining('거래처: QA 파트너'), findsOneWidget);
|
||||
expect(
|
||||
find.textContaining('거래처: QA 파트너'),
|
||||
findsAtLeastNWidgets(1),
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('권한 오류가 발생하면 경고 배너를 노출한다', (tester) async {
|
||||
@@ -311,7 +325,7 @@ void main() {
|
||||
);
|
||||
await tester.pump();
|
||||
|
||||
await tester.tap(find.byKey(const Key('inventory_filter_apply')));
|
||||
await _tapVisible(tester, find.byKey(const Key('inventory_filter_apply')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(capturedFilters.length, greaterThanOrEqualTo(2));
|
||||
@@ -393,14 +407,14 @@ void main() {
|
||||
|
||||
expect(recordedFilters, isNotEmpty);
|
||||
// 첫 정렬: 총 수량 헤더 탭 → 오름차순
|
||||
await tester.tap(find.text('총 수량').first);
|
||||
await _tapVisible(tester, find.text('총 수량').first);
|
||||
await tester.pumpAndSettle();
|
||||
final ascFilter = recordedFilters.last;
|
||||
expect(ascFilter.sort, 'total_quantity');
|
||||
expect(ascFilter.order, 'asc');
|
||||
|
||||
// 두 번째 탭 → 내림차순
|
||||
await tester.tap(find.text('총 수량').first);
|
||||
await _tapVisible(tester, find.text('총 수량').first);
|
||||
await tester.pumpAndSettle();
|
||||
final descFilter = recordedFilters.last;
|
||||
expect(descFilter.sort, 'total_quantity');
|
||||
|
||||
Reference in New Issue
Block a user