feat: wire editable «اطلاعات پرونده» form into patient case-file info tab
Port tauri /files-services FileInfoSection into PatientDetailPage's info
tab. The tab previously rendered a stripped read-only InfoRow list; it now
renders the inline editable PatientRecordInfoForm (18 fields + ثبت اطلاعات),
matching the tauri source. Reuses the existing form component, patientForm
helpers, and the already-present patient/provinces/cities/insurance-pricing
endpoints (no new API). PATCH /api/v1/patient/{uuid} on submit.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -20,7 +20,16 @@ beforeEach(() => {
|
||||
if (url === '/api/v1/patient/r1') return Promise.resolve({ success: true, data: {
|
||||
uuid: 'r1', user_name: 'ساغر صابری', record_number: 'P-1001', created_at: 1700000000,
|
||||
user_mobile: '09120000000', user_national_code: '1234567890', tags: [],
|
||||
profile: { gender: 'female', referral_source: 'اینستاگرام', address: 'یزد', description: 'یادداشت' },
|
||||
profile: {
|
||||
name: 'ساغر صابری', national_code: '1234567890', mobile: '09120000000',
|
||||
gender: 'female', fathers_name: 'رضا', job: 'مهندس',
|
||||
referral_source: 'اینستاگرام', address: 'یزد', description: 'یادداشت',
|
||||
},
|
||||
} });
|
||||
if (url === '/api/v1/provinces') return Promise.resolve({ success: true, data: [{ id: 10, name: 'یزد' }] });
|
||||
if (url.startsWith('/api/v1/cities')) return Promise.resolve({ success: true, data: [{ id: 100, name: 'یزد' }] });
|
||||
if (url === '/api/v1/insurance-pricing') return Promise.resolve({ success: true, data: {
|
||||
insurances: [{ insurance_id: 1, insurance_name: 'تأمین اجتماعی', type: 'basic' }],
|
||||
} });
|
||||
if (url === '/api/v1/patient/r1/sessions') return Promise.resolve({ success: true, data: [
|
||||
{ uuid: 's1', services: [{ service_name: 'اسکیلینگ' }], doctor_name: 'دکتر فتحی', final_price_rials: 2500000, is_paid: false, patient_debt_rials: 1500000, notes: 'یادداشت', created_at: 1700000000, visit_price_rials: 0 },
|
||||
@@ -88,13 +97,32 @@ describe('PatientDetailPage (پرونده تبدار)', () => {
|
||||
expect(await screen.findByText('اطلاعات فاکتور')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('shows patient info on the info tab', async () => {
|
||||
it('renders the editable «اطلاعات پرونده» form prefilled from the profile', async () => {
|
||||
renderDetail();
|
||||
await loaded();
|
||||
fireEvent.click(screen.getByText('اطلاعات پرونده'));
|
||||
expect(screen.getByText('کد ملی')).toBeInTheDocument();
|
||||
expect(screen.getByText('1234567890')).toBeInTheDocument();
|
||||
expect(screen.getByText('اینستاگرام')).toBeInTheDocument();
|
||||
// لیبل فیلدهای فرم (معادل tauri FileInfoSection)
|
||||
expect(await screen.findByText('نام و نام خانوادگی مراجعه کننده')).toBeInTheDocument();
|
||||
expect(screen.getByText('کدملی')).toBeInTheDocument();
|
||||
// مقادیر پیشپرشده از پروفایل
|
||||
expect(screen.getByDisplayValue('1234567890')).toBeInTheDocument();
|
||||
expect(screen.getByDisplayValue('ساغر صابری')).toBeInTheDocument();
|
||||
expect(screen.getByDisplayValue('P-1001')).toBeInTheDocument(); // شماره پرونده readonly
|
||||
// دکمهٔ ثبت
|
||||
expect(screen.getByRole('button', { name: 'ثبت اطلاعات' })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders the info form with placeholders when the profile is empty', async () => {
|
||||
get.mockImplementation((url: string) => {
|
||||
if (url === '/api/v1/patient/r1') return Promise.resolve({ success: true, data: {
|
||||
uuid: 'r1', user_name: 'بدون پروفایل', record_number: 'P-9', created_at: 1700000000, profile: null,
|
||||
} });
|
||||
return Promise.resolve({ success: true, data: [] });
|
||||
});
|
||||
renderDetail();
|
||||
fireEvent.click(await screen.findByText('اطلاعات پرونده'));
|
||||
expect(await screen.findByPlaceholderText('نام و نام خانوادگی')).toBeInTheDocument();
|
||||
expect(screen.getByRole('button', { name: 'ثبت اطلاعات' })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders the call-center tab with a register form and history', async () => {
|
||||
|
||||
Reference in New Issue
Block a user