feat(payment): prefill amount field with remaining balance and cap wallet prefill
This commit is contained in:
@@ -97,6 +97,24 @@ describe('SessionPaymentPage (تکمیل پرداخت مراجعه)', () => {
|
||||
expect(typeof (body as any).paid_at).toBe('number');
|
||||
});
|
||||
|
||||
it('prefills the amount field with the remaining balance when a method is opened', async () => {
|
||||
// مانده ۲,۳۰۰,۰۰۰ ریال → ۲۳۰,۰۰۰ تومان در فیلد مبلغ
|
||||
mockGets([session({ remaining_rials: 2_300_000 })]);
|
||||
renderPage();
|
||||
|
||||
fireEvent.click(await screen.findByText('پرداخت نقدی'));
|
||||
expect(screen.getByPlaceholderText('مبلغ (تومان)')).toHaveValue('230,000');
|
||||
});
|
||||
|
||||
it('caps the wallet prefill at the wallet balance', async () => {
|
||||
// موجودی کیف پول ۳۰۰,۰۰۰ ریال < مانده ۲,۳۰۰,۰۰۰ ریال → ۳۰,۰۰۰ تومان
|
||||
mockGets([session({ remaining_rials: 2_300_000 })]);
|
||||
renderPage();
|
||||
|
||||
fireEvent.click(await screen.findByText('پرداخت از طریق کیف پول'));
|
||||
expect(screen.getByPlaceholderText('مبلغ (تومان)')).toHaveValue('30,000');
|
||||
});
|
||||
|
||||
it('applies and removes settlement discount (PATCH /session/{uuid})', async () => {
|
||||
mockGets([session()]);
|
||||
patch.mockResolvedValue({ success: true, data: session() });
|
||||
|
||||
Reference in New Issue
Block a user