修复(充值弹层): 下单进行中禁用泥点结算入口
- 会员订单提交时泥点结算 CTA 仍可点,点击后会被宿主 buyRechargeProduct 守卫静默丢弃 - 泥点结算弹层传 ctaDisabled,底部「充值」CTA 也在任意提交进行中禁用 - 保留上一轮「会员提交不波及泥点档位可选性」的既有行为,仅收口下单动作;补回归测试
This commit is contained in:
@@ -480,6 +480,56 @@ describe('PlatformProfileRechargeModal', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('会员订单提交中时泥点档位仍可选,但下单入口禁用', async () => {
|
||||
const user = userEvent.setup();
|
||||
const renderModal = (submittingProductId: string | null) => (
|
||||
<PlatformProfileRechargeModal
|
||||
center={{
|
||||
mudPointBalance: buildMudPointBalance(29),
|
||||
membership: buildNormalMembership(),
|
||||
pointProducts: buildPointProducts(),
|
||||
membershipPlans: [STARTER_PLAN],
|
||||
latestOrder: null,
|
||||
hasPointsRecharged: false,
|
||||
}}
|
||||
isLoading={false}
|
||||
error={null}
|
||||
submittingProductId={submittingProductId}
|
||||
nativePayment={null}
|
||||
membershipQuote={null}
|
||||
isLoadingMembershipQuote={false}
|
||||
membershipQuoteError={null}
|
||||
onClose={vi.fn()}
|
||||
onRetry={vi.fn()}
|
||||
onBuy={vi.fn()}
|
||||
onRequestMembershipQuote={vi.fn()}
|
||||
onSubmitMembershipCheckout={vi.fn()}
|
||||
onConfirmNativePayment={vi.fn()}
|
||||
onCloseNativePayment={vi.fn()}
|
||||
/>
|
||||
);
|
||||
|
||||
const { rerender } = render(renderModal(null));
|
||||
await user.click(screen.getByRole('tab', { name: '泥点充值' }));
|
||||
const product = within(
|
||||
screen.getByRole('radiogroup', { name: '泥点充值档位' }),
|
||||
).getByRole('radio', { name: '60泥点 ¥6' });
|
||||
// 既有行为:会员订单提交不波及泥点档位的可选状态。
|
||||
expect(product).not.toHaveProperty('disabled', true);
|
||||
|
||||
await user.click(product);
|
||||
await user.click(screen.getByRole('button', { name: '充值 ¥6' }));
|
||||
|
||||
// 会员订单提交中:泥点结算 CTA 禁用,避免被宿主守卫静默丢弃。
|
||||
rerender(renderModal('membership-pro-monthly'));
|
||||
expect(
|
||||
within(screen.getByRole('dialog', { name: '确认订单' })).getByRole(
|
||||
'button',
|
||||
{ name: '充值 ¥6' },
|
||||
),
|
||||
).toHaveProperty('disabled', true);
|
||||
});
|
||||
|
||||
test('shows the empty state when the recharge tab has no point product', async () => {
|
||||
const user = userEvent.setup();
|
||||
|
||||
|
||||
@@ -1019,6 +1019,7 @@ function PlatformRechargeCheckoutDialog({
|
||||
submitting={submitting}
|
||||
amountCents={product.priceCents}
|
||||
ctaLabel={`充值 ${formatRechargePrice(product.priceCents)}`}
|
||||
ctaDisabled={Boolean(submittingProductId)}
|
||||
onClose={onClose}
|
||||
onSubmit={() => {
|
||||
onBuy(product);
|
||||
@@ -1575,7 +1576,9 @@ export function PlatformProfileRechargeModal({
|
||||
/>
|
||||
<PlatformRechargeActionButton
|
||||
className="w-full disabled:cursor-not-allowed"
|
||||
disabled={!selectedPointProduct}
|
||||
disabled={
|
||||
!selectedPointProduct || Boolean(submittingProductId)
|
||||
}
|
||||
onClick={() => {
|
||||
if (selectedPointProduct) {
|
||||
setCheckout({
|
||||
|
||||
Reference in New Issue
Block a user