feat: refactor clinic management into a dedicated settings tab
- Removed MyClinicPage and redirected its functionality to a new ClinicDoctorsPage. - Created ClinicDoctorsManager component for managing doctors and invitations within the settings layout. - Updated backend permissions to allow clinic owners to detach doctors, alongside admins. - Adjusted API documentation to reflect new permission structure. - Updated tests to cover new functionality and permissions. - Modified sidebar and settings menu to reflect the new structure and role-based visibility.
This commit is contained in:
@@ -34,10 +34,17 @@ describe('SettingsLayout', () => {
|
||||
expect(screen.queryByText('مدیریت پزشک')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('shows the same menu to every role (ungated, mirroring tauri)', () => {
|
||||
// the desktop sidebar is not role-gated: مدیریت مطب shows even for a doctor
|
||||
it('role-gates the desktop sidebar: a doctor does not see the clinic-doctors tab', () => {
|
||||
renderWithProviders(<SettingsLayout active="subscription"><div /></SettingsLayout>);
|
||||
expect(screen.getByText('مدیریت مطب')).toBeInTheDocument();
|
||||
expect(screen.queryByText('پزشکان کلینیک')).not.toBeInTheDocument();
|
||||
// the removed 'مدیریت مطب' tab must be gone for everyone
|
||||
expect(screen.queryByText('مدیریت مطب')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('shows the clinic-doctors tab to a clinic owner', () => {
|
||||
useAuthStore.setState({ primaryRole: 'clinic' });
|
||||
renderWithProviders(<SettingsLayout active="clinic-doctors"><div /></SettingsLayout>);
|
||||
expect(screen.getByText('پزشکان کلینیک').closest('a')).toHaveAttribute('href', '/admin/settings/clinic-doctors');
|
||||
});
|
||||
|
||||
it('filters the menu by the search query', () => {
|
||||
@@ -49,8 +56,10 @@ describe('SettingsLayout', () => {
|
||||
|
||||
it('menuForRole still role-gates the mobile settings list', () => {
|
||||
// SettingsMenuPage (mobile) keeps using menuForRole / SETTINGS_MENU
|
||||
expect(menuForRole('clinic').map((i) => i.key)).toContain('clinic');
|
||||
expect(menuForRole('clinic').map((i) => i.key)).toContain('clinic-doctors');
|
||||
expect(menuForRole('clinic').map((i) => i.key)).not.toContain('doctor');
|
||||
expect(menuForRole('clinic').map((i) => i.key)).not.toContain('appointment');
|
||||
// a plain doctor must not get the clinic-doctors management tab
|
||||
expect(menuForRole('doctor').map((i) => i.key)).not.toContain('clinic-doctors');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user