import { describe, it, expect, beforeEach } from 'vitest';
import { screen } from '@testing-library/react';
import { renderWithProviders } from '../test/utils';
import SettingsMenuPage from './SettingsMenuPage';
import { menuForRole } from '../components/layout/SettingsLayout';
import { useAuthStore } from '../stores/authStore';
beforeEach(() => {
useAuthStore.setState({ primaryRole: 'doctor' });
});
describe('SettingsMenuPage', () => {
it('lists the settings sections available to the current role', () => {
renderWithProviders();
for (const item of menuForRole('doctor')) {
expect(screen.getByText(item.label)).toBeInTheDocument();
}
// clinic-only section is not shown to a doctor
expect(screen.queryByText('پزشکان کلینیک')).not.toBeInTheDocument();
});
it('links every section to its route', () => {
renderWithProviders();
expect(screen.getByText('خرید اشتراک').closest('a')).toHaveAttribute('href', '/admin/subscription');
expect(screen.getByText('مدیریت نوبت دهی').closest('a')).toHaveAttribute('href', '/admin/appointment-settings');
expect(screen.getByText('حساب کاربری').closest('a')).toHaveAttribute('href', '/admin/account-settings');
});
});