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>
48 lines
2.0 KiB
TypeScript
48 lines
2.0 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { screen, fireEvent } from '@testing-library/react';
|
|
import { renderWithProviders } from '../../test/utils';
|
|
import SettingsLayout, { SETTINGS_MENU } from './SettingsLayout';
|
|
|
|
describe('SettingsLayout', () => {
|
|
it('renders every settings menu item and the section content', () => {
|
|
renderWithProviders(
|
|
<SettingsLayout active="subscription">
|
|
<div>محتوای اشتراک</div>
|
|
</SettingsLayout>,
|
|
);
|
|
|
|
for (const item of SETTINGS_MENU) {
|
|
expect(screen.getByText(item.label)).toBeInTheDocument();
|
|
}
|
|
expect(screen.getByText('محتوای اشتراک')).toBeInTheDocument();
|
|
});
|
|
|
|
it('marks the active item with aria-current=page', () => {
|
|
renderWithProviders(
|
|
<SettingsLayout active="subscription"><div /></SettingsLayout>,
|
|
);
|
|
const active = screen.getByText('خرید اشتراک').closest('a');
|
|
expect(active).toHaveAttribute('aria-current', 'page');
|
|
expect(active).toHaveAttribute('href', '/admin/subscription');
|
|
});
|
|
|
|
it('renders every menu item as a navigable link', () => {
|
|
renderWithProviders(
|
|
<SettingsLayout active="subscription"><div /></SettingsLayout>,
|
|
);
|
|
// all items are now wired to a route
|
|
expect(screen.getByText('مدیریت نوبت دهی').closest('a')).toHaveAttribute('href', '/admin/appointment-settings');
|
|
expect(screen.getByText('برچسبها').closest('a')).toHaveAttribute('href', '/admin/tags-settings');
|
|
expect(screen.queryByText('بهزودی')).not.toBeInTheDocument();
|
|
});
|
|
|
|
it('filters the menu by the search query', () => {
|
|
renderWithProviders(
|
|
<SettingsLayout active="subscription"><div /></SettingsLayout>,
|
|
);
|
|
fireEvent.change(screen.getByLabelText('جستجو در تنظیمات'), { target: { value: 'اشتراک' } });
|
|
expect(screen.getByText('خرید اشتراک')).toBeInTheDocument();
|
|
expect(screen.queryByText('خدمات')).not.toBeInTheDocument();
|
|
});
|
|
});
|