Files
clinicpro/assets/admin/components/ui/InputField.test.tsx
T
hamedandClaude Opus 4.8 580bc983b3 feat(patient): complete "اطلاعات پرونده" demographic form
Backend:
- Add profile columns field_of_study, province_id, city_id, postal_code,
  referral_source (UserProfile + migration).
- Extend PATCH /api/v1/patient/{uuid} to persist all demographic fields
  and return them in the patient profile payload.
- Support editable mobile (login identifier): validation, uniqueness,
  User.setMobileNumber, new ERR_PROFILE_002.
- Update docs/api/patient.md.

Frontend:
- New reusable Input, Field, and PatientRecordInfoForm (RHF + Zod).
- usePatient/useUpdatePatient hooks and patientForm mapping helpers.
- Extend the existing "info" tab in MyPatientsPage to the full field set
  via the shared form (province/city/insurance options, Jalali date).

Tests: Patient entity + PATCH integration (PHPUnit); form, hooks, and
mapping helpers (Vitest).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-13 11:51:18 +03:30

41 lines
1.7 KiB
TypeScript

import { describe, it, expect } from 'vitest';
import { render, screen } from '@testing-library/react';
import Input from '@/components/ui/Input';
import Field from '@/components/ui/Field';
describe('Input', () => {
it('مقدار و placeholder را رندر می‌کند', () => {
render(<Input defaultValue="ساغر" placeholder="نام" />);
const el = screen.getByPlaceholderText('نام') as HTMLInputElement;
expect(el.value).toBe('ساغر');
expect(el.className).toBe('cp-input');
});
it('در حالت hasError قاب قرمز می‌گیرد', () => {
render(<Input placeholder="کدملی" hasError />);
const el = screen.getByPlaceholderText('کدملی') as HTMLInputElement;
expect(el.style.borderColor).toBe('var(--danger)');
});
});
describe('Field', () => {
it('برچسب و فرزند را نشان می‌دهد و بدون خطا پیام خطا ندارد', () => {
render(
<Field label="نام پدر">
<Input placeholder="نام پدر را وارد کنید" />
</Field>,
);
expect(screen.getByText('نام پدر')).toBeInTheDocument();
expect(screen.getByPlaceholderText('نام پدر را وارد کنید')).toBeInTheDocument();
});
it('پیام خطا را وقتی error داده شود نمایش می‌دهد', () => {
render(
<Field label="کدملی" error="کد ملی باید ۱۰ رقم باشد">
<Input />
</Field>,
);
expect(screen.getByText('کد ملی باید ۱۰ رقم باشد')).toBeInTheDocument();
});
});