diff --git a/app/Utilities/SidebarPermissions.php b/app/Utilities/SidebarPermissions.php index cf73893d..e69db684 100644 --- a/app/Utilities/SidebarPermissions.php +++ b/app/Utilities/SidebarPermissions.php @@ -427,6 +427,11 @@ class SidebarPermissions $normalized[] = 'fee-ratio-monitoring/refund-pending/export-details'; $normalized[] = 'fee-ratio-monitoring/cost-freight-anomaly'; } + + if ($key === 'order-data' || str_starts_with($key, 'order-data/')) { + $normalized[] = 'order-profit'; + $normalized[] = 'order-profit/order-profit-list'; + } } return array_values(array_unique($normalized)); diff --git a/tests/Feature/Settings/NavigationTest.php b/tests/Feature/Settings/NavigationTest.php index 19c276b1..5d566ec5 100644 --- a/tests/Feature/Settings/NavigationTest.php +++ b/tests/Feature/Settings/NavigationTest.php @@ -369,6 +369,25 @@ class NavigationTest extends FeatureTestCase ); } + public function testOrderProfitInheritsLegacyOrderDataPermission(): void + { + $this->user->roles()->sync([Role::where('name', 'user')->firstOrFail()->id]); + $subject = 'user_' . $this->user->id; + setting()->set('system.sidebar_permissions', [ + 'configured' => [$subject], + 'subjects' => [$subject => [ + 'order-data', + 'order-data/raw-data', + ]], + ]); + setting()->save(); + + $allowed = SidebarPermissions::allowedKeys($this->user); + + $this->assertContains('order-profit', $allowed); + $this->assertContains('order-profit/order-profit-list', $allowed); + } + public function testPrototypeSidebarDoesNotDuplicateOtherDirectoryPages(): void { $prototypePages = collect(SidebarMenu::groups($this->user))