Add tests and implementation for ServiceDetailPage and PriceInput components
- Implement PriceInput component tests to validate Persian and Arabic numeral handling, input formatting, and controlled behavior. - Create ServiceDetailPage component with detailed service information, including pricing, insurance coverage, and editing capabilities. - Add API tests for service item detail retrieval and coverage synchronization with insurance contracts. - Ensure proper error handling and user feedback for service item retrieval and coverage management.
This commit is contained in:
@@ -68,4 +68,54 @@ describe('ClinicServicesPage (خدمات)', () => {
|
||||
expect(screen.getByText('تعرفههای سالانه')).toBeInTheDocument();
|
||||
expect(screen.getByText('پوشش بیمه')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('فرم ویرایش سرویس دیگر سوییچ بیمه ندارد و به بخش پوشش بیمه ارجاع میدهد', async () => {
|
||||
renderWithProviders(<ClinicServicesPage />, { route: '/admin/clinic-services' });
|
||||
fireEvent.click(await screen.findByText('کندلا ۲۰۲۱'));
|
||||
fireEvent.click(await screen.findByTitle('عملیات'));
|
||||
fireEvent.click(await screen.findByText('ویرایش'));
|
||||
|
||||
expect(await screen.findByText('ویرایش سرویس')).toBeInTheDocument();
|
||||
expect(screen.queryByText('این خدمت شامل بیمه میشود')).not.toBeInTheDocument();
|
||||
expect(screen.queryByText('قیمت تقریبی با بیمه (تومان)')).not.toBeInTheDocument();
|
||||
expect(screen.getByText(/در بخش «پوشش بیمه» تنظیم میشود/)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('ذخیرهی سرویس فیلدهای بیمه را نمیفرستد', async () => {
|
||||
const patch = api.patch as ReturnType<typeof vi.fn>;
|
||||
patch.mockResolvedValue({ success: true, data: {} });
|
||||
|
||||
renderWithProviders(<ClinicServicesPage />, { route: '/admin/clinic-services' });
|
||||
fireEvent.click(await screen.findByText('کندلا ۲۰۲۱'));
|
||||
fireEvent.click(await screen.findByTitle('عملیات'));
|
||||
fireEvent.click(await screen.findByText('ویرایش'));
|
||||
fireEvent.click(await screen.findByText('ذخیره سرویس'));
|
||||
|
||||
await vi.waitFor(() => expect(patch).toHaveBeenCalled());
|
||||
const body = patch.mock.calls[0][1];
|
||||
expect(body).not.toHaveProperty('insurance_covered');
|
||||
expect(body).not.toHaveProperty('insurance_price_rials');
|
||||
});
|
||||
|
||||
it('کارت سرویسِ تحت پوشش، نشان «تحت پوشش» را نمایش میدهد', async () => {
|
||||
get.mockImplementation((url: string) => {
|
||||
if (url.includes('/subscription/my')) return Promise.resolve({ success: true, data: {
|
||||
subscription: null, used_trial: false,
|
||||
effective_plan: { name: 'professional', level: 2, max_secretaries: 10, features: { services: true } },
|
||||
} });
|
||||
if (url.includes('/payment/config')) return Promise.resolve({ success: true, data: { test_mode: true, gateways: [] } });
|
||||
if (url.includes('/service-sections')) return Promise.resolve({ success: true, data: [
|
||||
{ uuid: 'sec1', name: 'کندلا ۲۰۲۱', active: true, items_count: 1 },
|
||||
] });
|
||||
if (url.includes('/service-items/sec1')) return Promise.resolve({ success: true, data: [
|
||||
{ uuid: 'it1', name: 'فول بادی', price_rials: 35_000_000, active: true, insurance_covered: true },
|
||||
] });
|
||||
return Promise.resolve({ success: true, data: [] });
|
||||
});
|
||||
|
||||
renderWithProviders(<ClinicServicesPage />, { route: '/admin/clinic-services' });
|
||||
fireEvent.click(await screen.findByText('کندلا ۲۰۲۱'));
|
||||
|
||||
expect(await screen.findByText('تحت پوشش')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user