Fill the three previously-placeholder settings sections so every menu item is now a real page inside the settings shell: - حساب کاربری: new authenticated POST /api/v1/user/change-password (verifies current password, ≥8 chars, must differ) + account page with a profile summary and change-password form. - برچسبها: new per-tenant TenantTag domain (entity/repo/controller + migration) with tenant-scoped CRUD at /api/v1/tenant-tag(s), plus a tags management page (list + color + add/edit/delete). - مدیریت نوبت دهی: export the existing WeeklyScheduleTab from DoctorDetailPage and reuse it in a standalone AppointmentSettingsPage (current doctor's uuid + addresses). Wire all three menu entries to their routes. Backend covered by PHPUnit (change-password, tenant-tag CRUD + ownership); FE covered by Vitest. API docs updated (auth.md, tag.md). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
35 lines
1.5 KiB
TypeScript
35 lines
1.5 KiB
TypeScript
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
|
import { screen } from '@testing-library/react';
|
|
import { renderWithProviders } from '../test/utils';
|
|
|
|
vi.mock('sonner', () => ({ toast: { success: vi.fn(), error: vi.fn() } }));
|
|
vi.mock('../lib/api', () => ({
|
|
api: { get: vi.fn(), post: vi.fn(), patch: vi.fn(), put: vi.fn(), delete: vi.fn() },
|
|
ApiError: class extends Error {},
|
|
}));
|
|
|
|
import { api } from '../lib/api';
|
|
import { useAuthStore } from '../stores/authStore';
|
|
import AppointmentSettingsPage from './AppointmentSettingsPage';
|
|
|
|
const get = api.get as ReturnType<typeof vi.fn>;
|
|
|
|
beforeEach(() => {
|
|
get.mockReset();
|
|
useAuthStore.setState({ primaryRole: 'doctor', doctorUuid: 'doc-1', dbUuid: 'doc-1' });
|
|
get.mockImplementation((url: string) => {
|
|
if (url.includes('/doctor/doc-1')) return Promise.resolve({ success: true, data: { data: { address: [] } } });
|
|
if (url.includes('/weekly-schedule')) return Promise.resolve({ success: true, data: {} });
|
|
return Promise.resolve({ success: true, data: {} });
|
|
});
|
|
});
|
|
|
|
describe('AppointmentSettingsPage', () => {
|
|
it('renders the weekly-schedule section inside the settings shell', async () => {
|
|
renderWithProviders(<AppointmentSettingsPage />, { route: '/admin/appointment-settings' });
|
|
// appears in the shell menu and as the page heading
|
|
expect((await screen.findAllByText('مدیریت نوبت دهی')).length).toBeGreaterThan(1);
|
|
expect(screen.getByText('خرید اشتراک')).toBeInTheDocument(); // shell menu
|
|
});
|
|
});
|