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

@@ -6,7 +6,8 @@ import 'package:mocktail/mocktail.dart';
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/constants/app_sections.dart';
import 'package:superport_v2/core/navigation/menu_catalog.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/core/services/token_storage.dart';
@@ -21,6 +22,8 @@ import 'package:superport_v2/features/masters/group/domain/repositories/group_re
import 'package:superport_v2/features/masters/group_permission/domain/entities/group_permission.dart';
import 'package:superport_v2/features/masters/group_permission/domain/repositories/group_permission_repository.dart';
import '../helpers/test_app.dart';
GoRouter _createTestRouter() {
return GoRouter(
initialLocation: loginRoutePath,
@@ -34,15 +37,15 @@ GoRouter _createTestRouter() {
builder: (context, state) => const _TestDashboardPage(),
),
GoRoute(
path: '/inventory/inbound',
path: inventoryReceiptsRoutePath,
builder: (context, state) => const _PlaceholderPage(title: '입고 화면'),
),
GoRoute(
path: '/inventory/outbound',
path: inventoryIssuesRoutePath,
builder: (context, state) => const _PlaceholderPage(title: '출고 화면'),
),
GoRoute(
path: '/inventory/rental',
path: inventoryRentalsRoutePath,
builder: (context, state) => const _PlaceholderPage(title: '대여 화면'),
),
],
@@ -50,19 +53,23 @@ GoRouter _createTestRouter() {
}
class _TestApp extends StatelessWidget {
const _TestApp({required this.router});
const _TestApp({required this.router, required this.catalog});
final GoRouter router;
final MenuCatalog catalog;
@override
Widget build(BuildContext context) {
return PermissionScope(
manager: PermissionManager(),
child: ShadApp.router(
routerConfig: router,
debugShowCheckedModeBanner: false,
theme: SuperportShadTheme.light(),
darkTheme: SuperportShadTheme.dark(),
child: MenuCatalogScope(
catalog: catalog,
child: ShadApp.router(
routerConfig: router,
debugShowCheckedModeBanner: false,
theme: SuperportShadTheme.light(),
darkTheme: SuperportShadTheme.dark(),
),
),
);
}
@@ -90,15 +97,15 @@ class _TestDashboardPage extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextButton(
onPressed: () => context.go('/inventory/inbound'),
onPressed: () => context.go(inventoryReceiptsRoutePath),
child: const Text('입고로 이동'),
),
TextButton(
onPressed: () => context.go('/inventory/outbound'),
onPressed: () => context.go(inventoryIssuesRoutePath),
child: const Text('출고로 이동'),
),
TextButton(
onPressed: () => context.go('/inventory/rental'),
onPressed: () => context.go(inventoryRentalsRoutePath),
child: const Text('대여로 이동'),
),
],
@@ -191,7 +198,7 @@ class _StubGroupPermissionRepository implements GroupPermissionRepository {
int page = 1,
int pageSize = 20,
int? groupId,
int? menuId,
String? menuCode,
bool? isActive,
bool includeDeleted = false,
}) async {
@@ -320,7 +327,8 @@ void main() {
);
final router = _createTestRouter();
await tester.pumpWidget(_TestApp(router: router));
final catalog = createTestMenuCatalog();
await tester.pumpWidget(_TestApp(router: router, catalog: catalog));
await tester.pumpAndSettle();
expect(find.text('Superport v2 로그인'), findsOneWidget);