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:
@@ -7,6 +7,7 @@ import 'package:shadcn_ui/shadcn_ui.dart';
|
||||
|
||||
import '../../../../../helpers/tester_extensions.dart';
|
||||
import 'package:superport_v2/core/common/models/paginated_result.dart';
|
||||
import 'package:superport_v2/core/navigation/route_paths.dart';
|
||||
import 'package:superport_v2/features/masters/customer/domain/entities/customer.dart';
|
||||
import 'package:superport_v2/features/masters/customer/domain/repositories/customer_repository.dart';
|
||||
import 'package:superport_v2/features/masters/customer/presentation/pages/customer_page.dart';
|
||||
@@ -43,7 +44,7 @@ void main() {
|
||||
dotenv.testLoad(fileInput: 'FEATURE_CUSTOMERS_ENABLED=false\n');
|
||||
|
||||
await tester.pumpWidget(
|
||||
_buildApp(CustomerPage(routeUri: Uri(path: '/masters/customers'))),
|
||||
_buildApp(CustomerPage(routeUri: Uri(path: inventoryCustomersRoutePath))),
|
||||
);
|
||||
await tester.pump();
|
||||
|
||||
@@ -89,7 +90,7 @@ void main() {
|
||||
);
|
||||
|
||||
await tester.pumpWidget(
|
||||
_buildApp(CustomerPage(routeUri: Uri(path: '/masters/customers'))),
|
||||
_buildApp(CustomerPage(routeUri: Uri(path: inventoryCustomersRoutePath))),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -126,7 +127,7 @@ void main() {
|
||||
);
|
||||
|
||||
await tester.pumpWidget(
|
||||
_buildApp(CustomerPage(routeUri: Uri(path: '/masters/customers'))),
|
||||
_buildApp(CustomerPage(routeUri: Uri(path: inventoryCustomersRoutePath))),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -159,7 +160,7 @@ void main() {
|
||||
);
|
||||
|
||||
await tester.pumpWidget(
|
||||
_buildApp(CustomerPage(routeUri: Uri(path: '/masters/customers'))),
|
||||
_buildApp(CustomerPage(routeUri: Uri(path: inventoryCustomersRoutePath))),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -232,7 +233,7 @@ void main() {
|
||||
});
|
||||
|
||||
await tester.pumpWidget(
|
||||
_buildApp(CustomerPage(routeUri: Uri(path: '/masters/customers'))),
|
||||
_buildApp(CustomerPage(routeUri: Uri(path: inventoryCustomersRoutePath))),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -297,7 +298,7 @@ void main() {
|
||||
Center(
|
||||
child: SizedBox(
|
||||
width: 320,
|
||||
child: CustomerPage(routeUri: Uri(path: '/masters/customers')),
|
||||
child: CustomerPage(routeUri: Uri(path: inventoryCustomersRoutePath)),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -144,7 +144,7 @@ void main() {
|
||||
page: any(named: 'page'),
|
||||
pageSize: any(named: 'pageSize'),
|
||||
groupId: any(named: 'groupId'),
|
||||
menuId: any(named: 'menuId'),
|
||||
menuCode: any(named: 'menuCode'),
|
||||
isActive: any(named: 'isActive'),
|
||||
includeDeleted: any(named: 'includeDeleted'),
|
||||
),
|
||||
@@ -183,7 +183,7 @@ void main() {
|
||||
page: any(named: 'page'),
|
||||
pageSize: any(named: 'pageSize'),
|
||||
groupId: sampleGroup.id,
|
||||
menuId: any(named: 'menuId'),
|
||||
menuCode: any(named: 'menuCode'),
|
||||
isActive: any(named: 'isActive'),
|
||||
includeDeleted: any(named: 'includeDeleted'),
|
||||
),
|
||||
|
||||
@@ -2,11 +2,15 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
|
||||
import 'package:superport_v2/core/common/models/paginated_result.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/permissions/permission_resources.dart';
|
||||
import 'package:superport_v2/features/masters/group_permission/application/permission_synchronizer.dart';
|
||||
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 'package:superport_v2/features/masters/menu/domain/entities/menu.dart';
|
||||
import 'package:superport_v2/features/masters/menu/domain/repositories/menu_repository.dart';
|
||||
|
||||
class _MockGroupPermissionRepository extends Mock
|
||||
implements GroupPermissionRepository {}
|
||||
@@ -29,9 +33,9 @@ void main() {
|
||||
group: GroupPermissionGroup(id: 1, groupName: '관리자'),
|
||||
menu: GroupPermissionMenu(
|
||||
id: 10,
|
||||
menuCode: 'INBOUND',
|
||||
menuCode: 'inventory.receipts',
|
||||
menuName: '입고',
|
||||
path: '/inventory/inbound',
|
||||
path: inventoryReceiptsRoutePath,
|
||||
),
|
||||
canCreate: true,
|
||||
canRead: true,
|
||||
@@ -44,9 +48,9 @@ void main() {
|
||||
group: GroupPermissionGroup(id: 1, groupName: '관리자'),
|
||||
menu: GroupPermissionMenu(
|
||||
id: 11,
|
||||
menuCode: 'OUTBOUND',
|
||||
menuCode: 'inventory.issues',
|
||||
menuName: '출고',
|
||||
path: '/inventory/outbound',
|
||||
path: inventoryIssuesRoutePath,
|
||||
),
|
||||
canCreate: false,
|
||||
canRead: true,
|
||||
@@ -59,7 +63,7 @@ void main() {
|
||||
page: any(named: 'page'),
|
||||
pageSize: any(named: 'pageSize'),
|
||||
groupId: any(named: 'groupId'),
|
||||
menuId: any(named: 'menuId'),
|
||||
menuCode: any(named: 'menuCode'),
|
||||
isActive: any(named: 'isActive'),
|
||||
includeDeleted: any(named: 'includeDeleted'),
|
||||
),
|
||||
@@ -88,7 +92,7 @@ void main() {
|
||||
page: any(named: 'page'),
|
||||
pageSize: 1,
|
||||
groupId: 1,
|
||||
menuId: null,
|
||||
menuCode: null,
|
||||
isActive: true,
|
||||
includeDeleted: false,
|
||||
),
|
||||
@@ -131,7 +135,7 @@ void main() {
|
||||
page: any(named: 'page'),
|
||||
pageSize: any(named: 'pageSize'),
|
||||
groupId: any(named: 'groupId'),
|
||||
menuId: any(named: 'menuId'),
|
||||
menuCode: any(named: 'menuCode'),
|
||||
isActive: any(named: 'isActive'),
|
||||
includeDeleted: any(named: 'includeDeleted'),
|
||||
),
|
||||
@@ -166,5 +170,160 @@ void main() {
|
||||
contains(PermissionAction.view),
|
||||
);
|
||||
});
|
||||
|
||||
test('menu_code 경로 불일치는 Catalog 기준으로 보정한다', () async {
|
||||
const legacyPath = '/legacy/inbound';
|
||||
final repository = _MockGroupPermissionRepository();
|
||||
final manager = PermissionManager();
|
||||
final catalog = MenuCatalog(repository: _DummyMenuRepository());
|
||||
catalog.replaceAll([
|
||||
MenuItem(
|
||||
id: 10,
|
||||
menuCode: 'inventory.receipts',
|
||||
menuName: '입고',
|
||||
path: inventoryReceiptsRoutePath,
|
||||
),
|
||||
]);
|
||||
final synchronizer = PermissionSynchronizer(
|
||||
repository: repository,
|
||||
manager: manager,
|
||||
menuCatalog: catalog,
|
||||
);
|
||||
|
||||
when(
|
||||
() => repository.list(
|
||||
page: any(named: 'page'),
|
||||
pageSize: any(named: 'pageSize'),
|
||||
groupId: any(named: 'groupId'),
|
||||
menuCode: any(named: 'menuCode'),
|
||||
isActive: any(named: 'isActive'),
|
||||
includeDeleted: any(named: 'includeDeleted'),
|
||||
),
|
||||
).thenAnswer((_) async {
|
||||
return PaginatedResult<GroupPermission>(
|
||||
items: [
|
||||
GroupPermission(
|
||||
id: 1,
|
||||
group: GroupPermissionGroup(id: 1, groupName: '관리자'),
|
||||
menu: GroupPermissionMenu(
|
||||
id: 10,
|
||||
menuCode: 'inventory.receipts',
|
||||
menuName: '입고',
|
||||
path: legacyPath,
|
||||
),
|
||||
canRead: true,
|
||||
),
|
||||
],
|
||||
page: 1,
|
||||
pageSize: 20,
|
||||
total: 1,
|
||||
);
|
||||
});
|
||||
|
||||
await synchronizer.syncForGroup(1);
|
||||
|
||||
expect(
|
||||
manager.can(inventoryReceiptsRoutePath, PermissionAction.view),
|
||||
isTrue,
|
||||
);
|
||||
expect(
|
||||
manager.can(legacyPath, PermissionAction.view),
|
||||
isFalse,
|
||||
);
|
||||
});
|
||||
|
||||
test('menu path가 비어도 Catalog 경로를 적용한다', () async {
|
||||
final repository = _MockGroupPermissionRepository();
|
||||
final manager = PermissionManager();
|
||||
final catalog = MenuCatalog(repository: _DummyMenuRepository());
|
||||
catalog.replaceAll([
|
||||
MenuItem(
|
||||
id: 20,
|
||||
menuCode: 'inventory.issues',
|
||||
menuName: '출고',
|
||||
path: inventoryIssuesRoutePath,
|
||||
),
|
||||
]);
|
||||
final synchronizer = PermissionSynchronizer(
|
||||
repository: repository,
|
||||
manager: manager,
|
||||
menuCatalog: catalog,
|
||||
);
|
||||
|
||||
when(
|
||||
() => repository.list(
|
||||
page: any(named: 'page'),
|
||||
pageSize: any(named: 'pageSize'),
|
||||
groupId: any(named: 'groupId'),
|
||||
menuCode: any(named: 'menuCode'),
|
||||
isActive: any(named: 'isActive'),
|
||||
includeDeleted: any(named: 'includeDeleted'),
|
||||
),
|
||||
).thenAnswer((_) async {
|
||||
return PaginatedResult<GroupPermission>(
|
||||
items: [
|
||||
GroupPermission(
|
||||
id: 2,
|
||||
group: GroupPermissionGroup(id: 1, groupName: '관리자'),
|
||||
menu: GroupPermissionMenu(
|
||||
id: 20,
|
||||
menuCode: 'inventory.issues',
|
||||
menuName: '출고',
|
||||
),
|
||||
canRead: true,
|
||||
),
|
||||
],
|
||||
page: 1,
|
||||
pageSize: 20,
|
||||
total: 1,
|
||||
);
|
||||
});
|
||||
|
||||
await synchronizer.syncForGroup(1);
|
||||
|
||||
expect(
|
||||
manager.can(inventoryIssuesRoutePath, PermissionAction.view),
|
||||
isTrue,
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
class _DummyMenuRepository implements MenuRepository {
|
||||
@override
|
||||
Future<MenuItem> create(MenuInput input) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> delete(int id) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<PaginatedResult<MenuItem>> list({
|
||||
int page = 1,
|
||||
int pageSize = 20,
|
||||
String? query,
|
||||
int? parentId,
|
||||
bool? isActive,
|
||||
bool includeDeleted = false,
|
||||
}) async {
|
||||
return PaginatedResult<MenuItem>(
|
||||
items: const [],
|
||||
page: page,
|
||||
pageSize: pageSize,
|
||||
total: 0,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<MenuItem> restore(int id) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<MenuItem> update(int id, MenuInput input) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import 'package:superport_v2/core/navigation/route_paths.dart';
|
||||
import 'package:superport_v2/core/permissions/permission_manager.dart';
|
||||
import 'package:superport_v2/core/permissions/permission_resources.dart';
|
||||
import 'package:superport_v2/features/masters/group_permission/domain/entities/group_permission.dart';
|
||||
@@ -13,9 +14,9 @@ void main() {
|
||||
group: GroupPermissionGroup(id: 1, groupName: '관리자'),
|
||||
menu: GroupPermissionMenu(
|
||||
id: 10,
|
||||
menuCode: 'INBOUND',
|
||||
menuCode: 'inventory.receipts',
|
||||
menuName: '입고',
|
||||
path: '/inventory/inbound',
|
||||
path: inventoryReceiptsRoutePath,
|
||||
),
|
||||
canCreate: true,
|
||||
canRead: true,
|
||||
@@ -27,9 +28,9 @@ void main() {
|
||||
group: GroupPermissionGroup(id: 1, groupName: '관리자'),
|
||||
menu: GroupPermissionMenu(
|
||||
id: 11,
|
||||
menuCode: 'OUTBOUND',
|
||||
menuCode: 'inventory.issues',
|
||||
menuName: '출고',
|
||||
path: '/inventory/outbound',
|
||||
path: inventoryIssuesRoutePath,
|
||||
),
|
||||
canCreate: false,
|
||||
canRead: true,
|
||||
|
||||
@@ -65,7 +65,7 @@ void main() {
|
||||
page: any(named: 'page'),
|
||||
pageSize: any(named: 'pageSize'),
|
||||
groupId: any(named: 'groupId'),
|
||||
menuId: any(named: 'menuId'),
|
||||
menuCode: any(named: 'menuCode'),
|
||||
isActive: any(named: 'isActive'),
|
||||
includeDeleted: any(named: 'includeDeleted'),
|
||||
),
|
||||
@@ -136,7 +136,7 @@ void main() {
|
||||
page: any(named: 'page'),
|
||||
pageSize: any(named: 'pageSize'),
|
||||
groupId: any(named: 'groupId'),
|
||||
menuId: any(named: 'menuId'),
|
||||
menuCode: any(named: 'menuCode'),
|
||||
isActive: any(named: 'isActive'),
|
||||
includeDeleted: any(named: 'includeDeleted'),
|
||||
),
|
||||
@@ -152,7 +152,7 @@ void main() {
|
||||
|
||||
test('필터 값을 전달한다', () async {
|
||||
controller.updateGroupFilter(2);
|
||||
controller.updateMenuFilter(5);
|
||||
controller.updateMenuFilter('MENU005');
|
||||
controller.updateStatusFilter(GroupPermissionStatusFilter.inactiveOnly);
|
||||
controller.updateIncludeDeleted(true);
|
||||
|
||||
@@ -163,7 +163,7 @@ void main() {
|
||||
page: 3,
|
||||
pageSize: 20,
|
||||
groupId: 2,
|
||||
menuId: 5,
|
||||
menuCode: 'MENU005',
|
||||
isActive: false,
|
||||
includeDeleted: true,
|
||||
),
|
||||
@@ -176,7 +176,7 @@ void main() {
|
||||
page: any(named: 'page'),
|
||||
pageSize: any(named: 'pageSize'),
|
||||
groupId: any(named: 'groupId'),
|
||||
menuId: any(named: 'menuId'),
|
||||
menuCode: any(named: 'menuCode'),
|
||||
isActive: any(named: 'isActive'),
|
||||
includeDeleted: any(named: 'includeDeleted'),
|
||||
),
|
||||
@@ -190,12 +190,12 @@ void main() {
|
||||
|
||||
test('필터 업데이트 메서드', () {
|
||||
controller.updateGroupFilter(3);
|
||||
controller.updateMenuFilter(7);
|
||||
controller.updateMenuFilter('MENU007');
|
||||
controller.updateStatusFilter(GroupPermissionStatusFilter.activeOnly);
|
||||
controller.updateIncludeDeleted(true);
|
||||
|
||||
expect(controller.groupFilter, 3);
|
||||
expect(controller.menuFilter, 7);
|
||||
expect(controller.menuFilter, 'MENU007');
|
||||
expect(controller.statusFilter, GroupPermissionStatusFilter.activeOnly);
|
||||
expect(controller.includeDeleted, isTrue);
|
||||
});
|
||||
@@ -207,14 +207,14 @@ void main() {
|
||||
page: any(named: 'page'),
|
||||
pageSize: any(named: 'pageSize'),
|
||||
groupId: any(named: 'groupId'),
|
||||
menuId: any(named: 'menuId'),
|
||||
menuCode: any(named: 'menuCode'),
|
||||
isActive: any(named: 'isActive'),
|
||||
includeDeleted: any(named: 'includeDeleted'),
|
||||
),
|
||||
).thenAnswer((_) async => createResult([samplePermission]));
|
||||
});
|
||||
|
||||
final input = GroupPermissionInput(groupId: 1, menuId: 2);
|
||||
final input = GroupPermissionInput(groupId: 1, menuCode: 'MENU002');
|
||||
|
||||
test('create 성공', () async {
|
||||
when(
|
||||
@@ -265,7 +265,7 @@ void main() {
|
||||
page: any(named: 'page'),
|
||||
pageSize: any(named: 'pageSize'),
|
||||
groupId: any(named: 'groupId'),
|
||||
menuId: any(named: 'menuId'),
|
||||
menuCode: any(named: 'menuCode'),
|
||||
isActive: any(named: 'isActive'),
|
||||
includeDeleted: any(named: 'includeDeleted'),
|
||||
),
|
||||
@@ -282,7 +282,7 @@ void main() {
|
||||
page: any(named: 'page'),
|
||||
pageSize: any(named: 'pageSize'),
|
||||
groupId: any(named: 'groupId'),
|
||||
menuId: any(named: 'menuId'),
|
||||
menuCode: any(named: 'menuCode'),
|
||||
isActive: any(named: 'isActive'),
|
||||
includeDeleted: true,
|
||||
),
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'package:shadcn_ui/shadcn_ui.dart';
|
||||
|
||||
import '../../../../../helpers/tester_extensions.dart';
|
||||
import 'package:superport_v2/core/common/models/paginated_result.dart';
|
||||
import 'package:superport_v2/core/navigation/menu_catalog.dart';
|
||||
import 'package:superport_v2/core/permissions/permission_manager.dart';
|
||||
import 'package:superport_v2/features/masters/group/domain/entities/group.dart';
|
||||
import 'package:superport_v2/features/masters/group/domain/repositories/group_repository.dart';
|
||||
@@ -26,15 +27,23 @@ class _MockMenuRepository extends Mock implements MenuRepository {}
|
||||
class _FakeGroupPermissionInput extends Fake implements GroupPermissionInput {}
|
||||
|
||||
Widget _buildApp(Widget child) {
|
||||
final menuRepository = GetIt.I.isRegistered<MenuRepository>()
|
||||
? GetIt.I<MenuRepository>()
|
||||
: _MockMenuRepository();
|
||||
final catalog = MenuCatalog(repository: menuRepository);
|
||||
addTearDown(catalog.dispose);
|
||||
return PermissionScope(
|
||||
manager: PermissionManager(),
|
||||
child: MaterialApp(
|
||||
home: ShadTheme(
|
||||
data: ShadThemeData(
|
||||
colorScheme: const ShadSlateColorScheme.light(),
|
||||
brightness: Brightness.light,
|
||||
child: MenuCatalogScope(
|
||||
catalog: catalog,
|
||||
child: MaterialApp(
|
||||
home: ShadTheme(
|
||||
data: ShadThemeData(
|
||||
colorScheme: const ShadSlateColorScheme.light(),
|
||||
brightness: Brightness.light,
|
||||
),
|
||||
child: Scaffold(body: child),
|
||||
),
|
||||
child: Scaffold(body: child),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -122,7 +131,7 @@ void main() {
|
||||
page: any(named: 'page'),
|
||||
pageSize: any(named: 'pageSize'),
|
||||
groupId: any(named: 'groupId'),
|
||||
menuId: any(named: 'menuId'),
|
||||
menuCode: any(named: 'menuCode'),
|
||||
isActive: any(named: 'isActive'),
|
||||
includeDeleted: any(named: 'includeDeleted'),
|
||||
),
|
||||
@@ -161,7 +170,7 @@ void main() {
|
||||
page: any(named: 'page'),
|
||||
pageSize: any(named: 'pageSize'),
|
||||
groupId: any(named: 'groupId'),
|
||||
menuId: any(named: 'menuId'),
|
||||
menuCode: any(named: 'menuCode'),
|
||||
isActive: any(named: 'isActive'),
|
||||
includeDeleted: any(named: 'includeDeleted'),
|
||||
),
|
||||
@@ -194,7 +203,7 @@ void main() {
|
||||
page: any(named: 'page'),
|
||||
pageSize: any(named: 'pageSize'),
|
||||
groupId: any(named: 'groupId'),
|
||||
menuId: any(named: 'menuId'),
|
||||
menuCode: any(named: 'menuCode'),
|
||||
isActive: any(named: 'isActive'),
|
||||
includeDeleted: any(named: 'includeDeleted'),
|
||||
),
|
||||
@@ -242,8 +251,8 @@ void main() {
|
||||
groupName: '관리자',
|
||||
),
|
||||
menu: GroupPermissionMenu(
|
||||
id: capturedInput!.menuId,
|
||||
menuCode: 'DASHBOARD',
|
||||
id: 10,
|
||||
menuCode: capturedInput!.menuCode,
|
||||
menuName: '대시보드',
|
||||
path: '/dashboard',
|
||||
),
|
||||
@@ -292,7 +301,7 @@ void main() {
|
||||
|
||||
expect(capturedInput, isNotNull);
|
||||
expect(capturedInput?.groupId, 1);
|
||||
expect(capturedInput?.menuId, 10);
|
||||
expect(capturedInput?.menuCode, 'MENU001');
|
||||
expect(capturedInput?.canCreate, isTrue);
|
||||
expect(capturedInput?.canUpdate, isTrue);
|
||||
expect(find.byType(Dialog), findsNothing);
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'package:shadcn_ui/shadcn_ui.dart';
|
||||
|
||||
import '../../../../../helpers/tester_extensions.dart';
|
||||
import 'package:superport_v2/core/common/models/paginated_result.dart';
|
||||
import 'package:superport_v2/core/navigation/menu_catalog.dart';
|
||||
import 'package:superport_v2/features/masters/menu/domain/entities/menu.dart';
|
||||
import 'package:superport_v2/features/masters/menu/domain/repositories/menu_repository.dart';
|
||||
import 'package:superport_v2/features/masters/menu/presentation/pages/menu_page.dart';
|
||||
@@ -16,13 +17,21 @@ class _MockMenuRepository extends Mock implements MenuRepository {}
|
||||
class _FakeMenuInput extends Fake implements MenuInput {}
|
||||
|
||||
Widget _buildApp(Widget child) {
|
||||
final menuRepository = GetIt.I.isRegistered<MenuRepository>()
|
||||
? GetIt.I<MenuRepository>()
|
||||
: _MockMenuRepository();
|
||||
final catalog = MenuCatalog(repository: menuRepository);
|
||||
addTearDown(catalog.dispose);
|
||||
return MaterialApp(
|
||||
home: ShadTheme(
|
||||
data: ShadThemeData(
|
||||
colorScheme: const ShadSlateColorScheme.light(),
|
||||
brightness: Brightness.light,
|
||||
home: MenuCatalogScope(
|
||||
catalog: catalog,
|
||||
child: ShadTheme(
|
||||
data: ShadThemeData(
|
||||
colorScheme: const ShadSlateColorScheme.light(),
|
||||
brightness: Brightness.light,
|
||||
),
|
||||
child: Scaffold(body: child),
|
||||
),
|
||||
child: Scaffold(body: child),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'package:shadcn_ui/shadcn_ui.dart';
|
||||
|
||||
import '../../../../../helpers/tester_extensions.dart';
|
||||
import 'package:superport_v2/core/common/models/paginated_result.dart';
|
||||
import 'package:superport_v2/core/navigation/route_paths.dart';
|
||||
import 'package:superport_v2/features/masters/product/domain/entities/product.dart';
|
||||
import 'package:superport_v2/features/masters/product/domain/repositories/product_repository.dart';
|
||||
import 'package:superport_v2/features/masters/product/presentation/pages/product_page.dart';
|
||||
@@ -51,7 +52,7 @@ void main() {
|
||||
dotenv.testLoad(fileInput: 'FEATURE_PRODUCTS_ENABLED=false\n');
|
||||
|
||||
await tester.pumpWidget(
|
||||
_buildApp(ProductPage(routeUri: Uri(path: '/masters/products'))),
|
||||
_buildApp(ProductPage(routeUri: Uri(path: inventoryProductsRoutePath))),
|
||||
);
|
||||
await tester.pump();
|
||||
|
||||
@@ -138,7 +139,7 @@ void main() {
|
||||
);
|
||||
|
||||
await tester.pumpWidget(
|
||||
_buildApp(ProductPage(routeUri: Uri(path: '/masters/products'))),
|
||||
_buildApp(ProductPage(routeUri: Uri(path: inventoryProductsRoutePath))),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -175,7 +176,7 @@ void main() {
|
||||
);
|
||||
|
||||
await tester.pumpWidget(
|
||||
_buildApp(ProductPage(routeUri: Uri(path: '/masters/products'))),
|
||||
_buildApp(ProductPage(routeUri: Uri(path: inventoryProductsRoutePath))),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -202,7 +203,7 @@ void main() {
|
||||
);
|
||||
|
||||
await tester.pumpWidget(
|
||||
_buildApp(ProductPage(routeUri: Uri(path: '/masters/products'))),
|
||||
_buildApp(ProductPage(routeUri: Uri(path: inventoryProductsRoutePath))),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -278,7 +279,7 @@ void main() {
|
||||
});
|
||||
|
||||
await tester.pumpWidget(
|
||||
_buildApp(ProductPage(routeUri: Uri(path: '/masters/products'))),
|
||||
_buildApp(ProductPage(routeUri: Uri(path: inventoryProductsRoutePath))),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -349,7 +350,7 @@ void main() {
|
||||
Center(
|
||||
child: SizedBox(
|
||||
width: 320,
|
||||
child: ProductPage(routeUri: Uri(path: '/masters/products')),
|
||||
child: ProductPage(routeUri: Uri(path: inventoryProductsRoutePath)),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -59,7 +59,7 @@ void main() {
|
||||
page: any(named: 'page'),
|
||||
pageSize: any(named: 'pageSize'),
|
||||
groupId: any(named: 'groupId'),
|
||||
menuId: any(named: 'menuId'),
|
||||
menuCode: any(named: 'menuCode'),
|
||||
isActive: any(named: 'isActive'),
|
||||
includeDeleted: any(named: 'includeDeleted'),
|
||||
),
|
||||
@@ -252,7 +252,7 @@ void main() {
|
||||
page: any(named: 'page'),
|
||||
pageSize: any(named: 'pageSize'),
|
||||
groupId: sampleUser.group!.id,
|
||||
menuId: any(named: 'menuId'),
|
||||
menuCode: any(named: 'menuCode'),
|
||||
isActive: any(named: 'isActive'),
|
||||
includeDeleted: any(named: 'includeDeleted'),
|
||||
),
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'package:get_it/get_it.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
import 'package:shadcn_ui/shadcn_ui.dart';
|
||||
|
||||
import '../../../../../helpers/test_app.dart';
|
||||
import '../../../../../helpers/tester_extensions.dart';
|
||||
import 'package:superport_v2/core/common/models/paginated_result.dart';
|
||||
import 'package:superport_v2/core/permissions/permission_manager.dart';
|
||||
@@ -28,20 +29,7 @@ class _MockGroupPermissionRepository extends Mock
|
||||
|
||||
class _FakeUserInput extends Fake implements UserInput {}
|
||||
|
||||
Widget _buildApp(Widget child) {
|
||||
return PermissionScope(
|
||||
manager: PermissionManager(),
|
||||
child: MaterialApp(
|
||||
home: ShadTheme(
|
||||
data: ShadThemeData(
|
||||
colorScheme: const ShadSlateColorScheme.light(),
|
||||
brightness: Brightness.light,
|
||||
),
|
||||
child: Scaffold(body: child),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
Widget _buildApp(Widget child) => buildTestApp(child);
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
@@ -59,7 +47,7 @@ void main() {
|
||||
dotenv.testLoad(fileInput: 'FEATURE_USERS_ENABLED=false\n');
|
||||
|
||||
await tester.pumpWidget(_buildApp(const UserPage()));
|
||||
await tester.pump();
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('사용자(사원) 관리'), findsOneWidget);
|
||||
expect(find.text('테이블 리스트'), findsOneWidget);
|
||||
@@ -104,7 +92,7 @@ void main() {
|
||||
page: any(named: 'page'),
|
||||
pageSize: any(named: 'pageSize'),
|
||||
groupId: any(named: 'groupId'),
|
||||
menuId: any(named: 'menuId'),
|
||||
menuCode: any(named: 'menuCode'),
|
||||
isActive: any(named: 'isActive'),
|
||||
includeDeleted: any(named: 'includeDeleted'),
|
||||
),
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'package:shadcn_ui/shadcn_ui.dart';
|
||||
|
||||
import '../../../../../helpers/tester_extensions.dart';
|
||||
import 'package:superport_v2/core/common/models/paginated_result.dart';
|
||||
import 'package:superport_v2/core/navigation/route_paths.dart';
|
||||
import 'package:superport_v2/features/masters/vendor/domain/entities/vendor.dart';
|
||||
import 'package:superport_v2/features/masters/vendor/domain/repositories/vendor_repository.dart';
|
||||
import 'package:superport_v2/features/masters/vendor/presentation/pages/vendor_page.dart';
|
||||
@@ -43,7 +44,7 @@ void main() {
|
||||
dotenv.testLoad(fileInput: 'FEATURE_VENDORS_ENABLED=false\n');
|
||||
|
||||
await tester.pumpWidget(
|
||||
_buildApp(VendorPage(routeUri: Uri(path: '/masters/vendors'))),
|
||||
_buildApp(VendorPage(routeUri: Uri(path: inventoryVendorsRoutePath))),
|
||||
);
|
||||
await tester.pump();
|
||||
|
||||
@@ -75,7 +76,7 @@ void main() {
|
||||
);
|
||||
|
||||
await tester.pumpWidget(
|
||||
_buildApp(VendorPage(routeUri: Uri(path: '/masters/vendors'))),
|
||||
_buildApp(VendorPage(routeUri: Uri(path: inventoryVendorsRoutePath))),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -107,7 +108,7 @@ void main() {
|
||||
);
|
||||
|
||||
await tester.pumpWidget(
|
||||
_buildApp(VendorPage(routeUri: Uri(path: '/masters/vendors'))),
|
||||
_buildApp(VendorPage(routeUri: Uri(path: inventoryVendorsRoutePath))),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -136,7 +137,7 @@ void main() {
|
||||
);
|
||||
|
||||
await tester.pumpWidget(
|
||||
_buildApp(VendorPage(routeUri: Uri(path: '/masters/vendors'))),
|
||||
_buildApp(VendorPage(routeUri: Uri(path: inventoryVendorsRoutePath))),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -192,7 +193,7 @@ void main() {
|
||||
});
|
||||
|
||||
await tester.pumpWidget(
|
||||
_buildApp(VendorPage(routeUri: Uri(path: '/masters/vendors'))),
|
||||
_buildApp(VendorPage(routeUri: Uri(path: inventoryVendorsRoutePath))),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -244,7 +245,7 @@ void main() {
|
||||
Center(
|
||||
child: SizedBox(
|
||||
width: 320,
|
||||
child: VendorPage(routeUri: Uri(path: '/masters/vendors')),
|
||||
child: VendorPage(routeUri: Uri(path: inventoryVendorsRoutePath)),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'package:shadcn_ui/shadcn_ui.dart';
|
||||
|
||||
import '../../../../../helpers/tester_extensions.dart';
|
||||
import 'package:superport_v2/core/common/models/paginated_result.dart';
|
||||
import 'package:superport_v2/core/navigation/route_paths.dart';
|
||||
import 'package:superport_v2/features/masters/warehouse/domain/entities/warehouse.dart';
|
||||
import 'package:superport_v2/features/masters/warehouse/domain/repositories/warehouse_repository.dart';
|
||||
import 'package:superport_v2/features/masters/warehouse/presentation/pages/warehouse_page.dart';
|
||||
@@ -48,7 +49,7 @@ void main() {
|
||||
dotenv.testLoad(fileInput: 'FEATURE_WAREHOUSES_ENABLED=false\n');
|
||||
|
||||
await tester.pumpWidget(
|
||||
_buildApp(WarehousePage(routeUri: Uri(path: '/masters/warehouses'))),
|
||||
_buildApp(WarehousePage(routeUri: Uri(path: inventoryWarehousesRoutePath))),
|
||||
);
|
||||
await tester.pump();
|
||||
|
||||
@@ -112,7 +113,7 @@ void main() {
|
||||
);
|
||||
|
||||
await tester.pumpWidget(
|
||||
_buildApp(WarehousePage(routeUri: Uri(path: '/masters/warehouses'))),
|
||||
_buildApp(WarehousePage(routeUri: Uri(path: inventoryWarehousesRoutePath))),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -147,7 +148,7 @@ void main() {
|
||||
);
|
||||
|
||||
await tester.pumpWidget(
|
||||
_buildApp(WarehousePage(routeUri: Uri(path: '/masters/warehouses'))),
|
||||
_buildApp(WarehousePage(routeUri: Uri(path: inventoryWarehousesRoutePath))),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -205,7 +206,7 @@ void main() {
|
||||
});
|
||||
|
||||
await tester.pumpWidget(
|
||||
_buildApp(WarehousePage(routeUri: Uri(path: '/masters/warehouses'))),
|
||||
_buildApp(WarehousePage(routeUri: Uri(path: inventoryWarehousesRoutePath))),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -278,7 +279,7 @@ void main() {
|
||||
Center(
|
||||
child: SizedBox(
|
||||
width: 320,
|
||||
child: WarehousePage(routeUri: Uri(path: '/masters/warehouses')),
|
||||
child: WarehousePage(routeUri: Uri(path: inventoryWarehousesRoutePath)),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user