fix(semi-auto): 刷新绑定二维码 5 秒内复用当前码

This commit is contained in:
2026-11-19 12:34:55 +08:00
parent 87c7cc267c
commit 7f74772dab
4 changed files with 68 additions and 1 deletions
@@ -56,3 +56,18 @@ test('上一步修改资料会清空换绑状态并保留已填资料', () => {
// 重置失败不阻断客户修改资料。
assert.ok(source.includes('重置绑定状态失败,请稍后重试'))
})
test('刷新二维码有 3 秒冷却并提示操作频繁', () => {
assert.ok(source.includes('BINDING_REFRESH_COOLDOWN_MS = 3_000'))
assert.ok(source.includes('lastBindingRefreshAtRef'))
assert.ok(source.includes("message.warning('操作频繁,请稍后再试')"))
// 首次二维码出现不设置冷却,只有手动刷新才计时。
assert.ok(!source.includes('lastBindingRefreshAtRef.current = Date.now()'))
assert.ok(source.includes('lastBindingRefreshAtRef.current = now'))
// 冷却判断必须在真正发起 startCustomerBinding 之前。
const guardIndex = source.indexOf('操作频繁,请稍后再试')
const startIndex = source.indexOf(
'await startCustomerBinding(orderNo, selectedTask.id, { forceRebind })',
)
assert.ok(guardIndex > 0 && startIndex > guardIndex)
})