feat(appointment): add percentage shortcuts for patient share in payment rows
This commit is contained in:
@@ -392,3 +392,70 @@ describe('ConfirmAppointmentModal — ویزارد', () => {
|
||||
expect(screen.getByRole('button', { name: 'تأیید و قطعی کردن' })).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
/** جمع نوبتِ تست: ۲۱۲۰۰۰۰ + ۸۸۰۰۰۰ ریال = ۳۰۰٬۰۰۰ تومان. */
|
||||
describe('ConfirmAppointmentModal — میانبُرهای درصدی', () => {
|
||||
const percentButton = (percent: string) =>
|
||||
screen.getAllByRole('button', { name: `${percent}٪` })[0];
|
||||
|
||||
it('کلیک روی هر درصد، همان کسر از سهم بیمار را در مبلغ میگذارد', () => {
|
||||
render();
|
||||
const [amount] = goToPayment();
|
||||
|
||||
fireEvent.click(percentButton('۲۰'));
|
||||
expect(amount).toHaveValue('۶۰٬۰۰۰');
|
||||
|
||||
fireEvent.click(percentButton('۵۰'));
|
||||
expect(amount).toHaveValue('۱۵۰٬۰۰۰');
|
||||
|
||||
fireEvent.click(percentButton('۷۰'));
|
||||
expect(amount).toHaveValue('۲۱۰٬۰۰۰');
|
||||
|
||||
fireEvent.click(percentButton('۱۰۰'));
|
||||
expect(amount).toHaveValue('۳۰۰٬۰۰۰');
|
||||
});
|
||||
|
||||
it('درصدِ اعمالشده تا مرحلهٔ ثبت میماند و به سرور میرسد', async () => {
|
||||
render();
|
||||
goToPayment();
|
||||
|
||||
fireEvent.click(percentButton('۵۰'));
|
||||
goToReview();
|
||||
fireEvent.click(screen.getByRole('button', { name: 'تأیید و قطعی کردن' }));
|
||||
|
||||
await waitFor(() => expect(post).toHaveBeenCalled());
|
||||
expect(post.mock.calls[0][1].payments).toEqual([
|
||||
{ method: 'cash', amount_rials: 1_500_000 },
|
||||
]);
|
||||
});
|
||||
|
||||
it('هر ردیف درصد خودش را دارد؛ ردیف دیگر دست نمیخورد', () => {
|
||||
render();
|
||||
goToPayment();
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: /افزودن روش/ }));
|
||||
const rows = amountInputs();
|
||||
expect(rows).toHaveLength(2);
|
||||
|
||||
// ۲۰٪ روی ردیف دوم، بدون اثر روی ردیف اول که پیشفرضِ کامل دارد.
|
||||
const secondRowPercent = screen.getAllByRole('button', { name: '۲۰٪' })[1];
|
||||
fireEvent.click(secondRowPercent);
|
||||
|
||||
expect(rows[0]).toHaveValue('۳۰۰٬۰۰۰');
|
||||
expect(rows[1]).toHaveValue('۶۰٬۰۰۰');
|
||||
});
|
||||
|
||||
it('نوبتِ بدون هزینه اصلاً دکمهٔ درصدی ندارد', () => {
|
||||
renderWithProviders(
|
||||
<ConfirmAppointmentModal
|
||||
open
|
||||
appointmentUuid="a2"
|
||||
appointment={{ uuid: 'a2', version: 1, visit_price_rials: 0, service_items: [] }}
|
||||
onClose={() => {}}
|
||||
/>,
|
||||
);
|
||||
nextStep();
|
||||
|
||||
expect(screen.queryByRole('button', { name: '۵۰٪' })).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user