fix(settings): one menu list behind both settings navigations

The desktop sidebar kept its own copy of the item list, so the entries added
to the mobile settings menu — Resources, Categories, Branches, Holidays,
Price lists — never appeared in it. Adding a settings page meant editing two
files, and forgetting one was silent.

settingsMenu.ts is now the single source; the sidebar derives from it with
its two deliberate differences stated in code: no "manage doctor" entry, and
a disabled "security" row at the end. Labels follow the mobile list, which
uses the correct zero-width joiner spelling.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
hamed
2026-08-02 13:57:59 +03:30
co-authored by Claude Opus 5
parent 4380e64a5d
commit eeb9ae851a
4 changed files with 113 additions and 121 deletions
@@ -26,14 +26,28 @@ describe('SettingsLayout', () => {
expect(active).toHaveAttribute('href', '/admin/subscription');
});
it('renders the tauri-sourced items as navigable links', () => {
it('renders the shared menu items as navigable links', () => {
renderWithProviders(<SettingsLayout active="subscription"><div /></SettingsLayout>);
expect(screen.getByText('مدیریت نوبت دهی').closest('a')).toHaveAttribute('href', '/admin/appointment-settings');
expect(screen.getByText('تگ ها').closest('a')).toHaveAttribute('href', '/admin/tags-settings');
expect(screen.getByText('برچسب‌ها').closest('a')).toHaveAttribute('href', '/admin/tags-settings');
// 'مدیریت پزشک' lives in the main nav, not the settings menu
expect(screen.queryByText('مدیریت پزشک')).not.toBeInTheDocument();
});
/**
* سایدبار و فهرست موبایل یک منبع دارند؛ آیتمی که به منو اضافه می‌شود باید در هر دو
* دیده شود. قبلاً دو کپی بود و «منابع»/«دسته‌بندی‌ها» فقط در موبایل ظاهر شدند.
*/
it('shows the resource-first entries in the desktop sidebar too', () => {
useAuthStore.setState({ primaryRole: 'clinic' });
renderWithProviders(<SettingsLayout active="resources"><div /></SettingsLayout>);
expect(screen.getByText('منابع').closest('a')).toHaveAttribute('href', '/admin/resources');
expect(screen.getByText('دسته‌بندی‌ها').closest('a')).toHaveAttribute('href', '/admin/service-categories');
expect(screen.getByText('شعبه‌ها و اتاق‌ها').closest('a')).toHaveAttribute('href', '/admin/branches');
expect(screen.getByText('منابع').closest('a')).toHaveAttribute('aria-current', 'page');
});
it('role-gates the desktop sidebar: a doctor does not see the clinic-doctors tab', () => {
renderWithProviders(<SettingsLayout active="subscription"><div /></SettingsLayout>);
expect(screen.queryByText('پزشکان کلینیک')).not.toBeInTheDocument();