Files
clinicpro/assets/admin/components/ui/SearchableSelect.test.tsx
T
hamed 773f9d4d16 feat: update session payment logic to ensure accurate payable amounts and reflect consumables in cost breakdown
- Adjusted the calculation of payable amounts in PaymentStep to align with server logic, ensuring overpayments are handled correctly.
- Enhanced DetailsStep to include consumables in the itemized cost breakdown, ensuring consistency with patient share calculations.
- Updated tests for SessionPaymentPage to validate new behavior regarding overpayments and consumable listings.
- Modified PatientController to register SessionPayment correctly when settling sessions via wallet, preventing double charges.
- Refactored WalletService to remove outdated methods and ensure wallet transactions reflect the correct amounts after discounts.
- Improved accessibility in SearchableSelect component by adding aria labels and ensuring proper role attributes for screen readers.
- Updated styles to ensure minimum touch targets meet WCAG guidelines for mobile usability.
2026-07-19 13:29:46 +03:30

56 lines
2.6 KiB
TypeScript

import { describe, it, expect, vi } from 'vitest';
import { render, screen } from '@testing-library/react';
import SearchableSelect from './SearchableSelect';
vi.mock('../../stores/uiStore', () => ({ useUiStore: () => false }));
const insuranceOpts = [
{ value: '176', label: 'تامین اجتماعی' },
{ value: '178', label: 'بیمه ارتش' },
];
describe('SearchableSelect — تطبیق مقدار', () => {
it('مقدار number با گزینهٔ string تطبیق می‌خورد (id بیمه)', () => {
render(<SearchableSelect options={insuranceOpts} value={176} onChange={() => {}} />);
expect(screen.getByText('تامین اجتماعی')).toBeInTheDocument();
});
it('مقدار string با گزینهٔ string تطبیق می‌خورد', () => {
render(<SearchableSelect options={insuranceOpts} value={'178'} onChange={() => {}} />);
expect(screen.getByText('بیمه ارتش')).toBeInTheDocument();
});
it('مقدار number با گزینهٔ number تطبیق می‌خورد', () => {
render(<SearchableSelect options={[{ value: 9, label: 'یزد' }]} value={9} onChange={() => {}} />);
expect(screen.getByText('یزد')).toBeInTheDocument();
});
it('null/خالی → هیچ گزینه‌ای انتخاب نمی‌شود (placeholder)', () => {
render(<SearchableSelect options={insuranceOpts} value={null} onChange={() => {}} placeholder="انتخاب کنید..." />);
expect(screen.getByText('انتخاب کنید...')).toBeInTheDocument();
expect(screen.queryByText('تامین اجتماعی')).not.toBeInTheDocument();
});
});
describe('SearchableSelect — نام دسترس‌پذیر', () => {
it('در نبود ariaLabel، از placeholder به‌عنوان نام استفاده می‌کند', () => {
render(<SearchableSelect options={insuranceOpts} onChange={() => {}} placeholder="نوع بیمه" />);
expect(screen.getByRole('combobox', { name: 'نوع بیمه' })).toBeInTheDocument();
});
it('ariaLabel بر placeholder اولویت دارد', () => {
render(<SearchableSelect options={insuranceOpts} onChange={() => {}} placeholder="انتخاب کنید..." ariaLabel="بیمه پایه" />);
expect(screen.getByRole('combobox', { name: 'بیمه پایه' })).toBeInTheDocument();
});
it('ariaLabelledBy به label قابل‌مشاهده وصل می‌شود', () => {
render(
<>
<span id="lbl-city">شهر</span>
<SearchableSelect options={[{ value: 9, label: 'یزد' }]} onChange={() => {}} ariaLabelledBy="lbl-city" />
</>,
);
expect(screen.getByRole('combobox', { name: 'شهر' })).toBeInTheDocument();
});
});