refactor: update pricing input handling to use PriceInput component
- Replaced raw input fields for pricing with PriceInput component across various forms and modals to ensure consistent formatting and accessibility. - Updated tests to reflect changes in pricing input handling, ensuring values are displayed in toman with proper formatting. - Enhanced accessibility by adding aria-labels and aria-invalid attributes to PriceInput components. - Adjusted UI elements to improve layout and user experience, particularly in forms related to service items and scheduling. - Changed labels from "نمایش در نوبتدهی" to "نمایش در نوبتدهی آنلاین" for clarity.
This commit is contained in:
@@ -28,7 +28,10 @@ describe('FreeVisitPrice — الزامی کردن هزینه ویزیت', () =>
|
||||
it('toggle فعال + قیمت صفر → خطای inline و عدم ارسال درخواست', async () => {
|
||||
get.mockResolvedValue(pricing(0, false));
|
||||
renderWithProviders(<FreeVisitPrice />);
|
||||
await waitFor(() => expect(screen.getByRole('textbox')).toHaveValue('0'));
|
||||
// PriceInput صفر را خالی نشان میدهد، پس خالیبودن فیلد نشانهٔ «داده رسید» نیست؛
|
||||
// انتظار روی خودِ فراخوانی بسته میشود تا کلیک قبل از بارگذاری نیفتد.
|
||||
await waitFor(() => expect(get).toHaveBeenCalled());
|
||||
await waitFor(() => expect(screen.getByRole('textbox')).toHaveValue(''));
|
||||
|
||||
fireEvent.click(screen.getByRole('switch', { name: 'الزامی کردن هزینه ویزیت' }));
|
||||
fireEvent.click(screen.getByText('ذخیره'));
|
||||
@@ -40,7 +43,10 @@ describe('FreeVisitPrice — الزامی کردن هزینه ویزیت', () =>
|
||||
it('toggle فعال + قیمت معتبر → PUT با هر دو کلید (تومان → ریال)', async () => {
|
||||
get.mockResolvedValue(pricing(0, false));
|
||||
renderWithProviders(<FreeVisitPrice />);
|
||||
await waitFor(() => expect(screen.getByRole('textbox')).toHaveValue('0'));
|
||||
// PriceInput صفر را خالی نشان میدهد، پس خالیبودن فیلد نشانهٔ «داده رسید» نیست؛
|
||||
// انتظار روی خودِ فراخوانی بسته میشود تا کلیک قبل از بارگذاری نیفتد.
|
||||
await waitFor(() => expect(get).toHaveBeenCalled());
|
||||
await waitFor(() => expect(screen.getByRole('textbox')).toHaveValue(''));
|
||||
|
||||
fireEvent.click(screen.getByRole('switch', { name: 'الزامی کردن هزینه ویزیت' }));
|
||||
fireEvent.change(screen.getByRole('textbox'), { target: { value: '50000' } });
|
||||
@@ -55,7 +61,10 @@ describe('FreeVisitPrice — الزامی کردن هزینه ویزیت', () =>
|
||||
it('toggle غیرفعال + قیمت صفر → رفتار قبلی حفظ میشود (ارسال مجاز)', async () => {
|
||||
get.mockResolvedValue(pricing(0, false));
|
||||
renderWithProviders(<FreeVisitPrice />);
|
||||
await waitFor(() => expect(screen.getByRole('textbox')).toHaveValue('0'));
|
||||
// PriceInput صفر را خالی نشان میدهد، پس خالیبودن فیلد نشانهٔ «داده رسید» نیست؛
|
||||
// انتظار روی خودِ فراخوانی بسته میشود تا کلیک قبل از بارگذاری نیفتد.
|
||||
await waitFor(() => expect(get).toHaveBeenCalled());
|
||||
await waitFor(() => expect(screen.getByRole('textbox')).toHaveValue(''));
|
||||
|
||||
fireEvent.click(screen.getByText('ذخیره'));
|
||||
|
||||
@@ -71,6 +80,8 @@ describe('FreeVisitPrice — الزامی کردن هزینه ویزیت', () =>
|
||||
|
||||
await waitFor(() => expect(screen.getByRole('switch', { name: 'الزامی کردن هزینه ویزیت' })).toBeChecked());
|
||||
expect(screen.getByText('قیمت (تومان)').querySelector('span')?.textContent).toContain('*');
|
||||
expect(screen.getByRole('textbox')).toHaveValue('50000');
|
||||
await waitFor(() => expect(screen.getByRole('textbox')).toHaveValue(
|
||||
new Intl.NumberFormat('fa-IR').format(50_000),
|
||||
));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user