fix: 订单利润继承订单数据权限 #977

Merged
renshen merged 1 commits from fix/renshen-order-profit-permission into main 2026-11-07 14:47:52 +08:00
2 changed files with 24 additions and 0 deletions

View File

@ -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));

View File

@ -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))