fix(worker): 验收重复提交幂等,修复卡待验收与手动验收 500

This commit is contained in:
yml2213
2026-10-30 21:33:56 +08:00
parent a6ccb2e2d8
commit 96ae744dbb
6 changed files with 453 additions and 239 deletions
@@ -0,0 +1,25 @@
import assert from 'node:assert/strict'
import { readFile } from 'node:fs/promises'
import test from 'node:test'
/**
* 2026-10-30 生产事故:提交验收按钮没有在途锁,双击会发两个请求;第二个请求
* 把已验收的工单写回待验收并触发重复结算。按钮必须在请求结束前保持 loading/禁用。
*/
test('打手端验收提交按钮有在途锁,双击只会发一个请求', async () => {
const source = await readFile(
new URL('../src/pages/worker/WorkerOrderModals.tsx', import.meta.url),
'utf8',
)
assert.ok(source.includes('acceptanceBusyRef'), '缺少同步在途锁 ref')
assert.ok(source.includes('runAcceptanceAction'), '缺少统一的验收动作包装')
assert.ok(
(source.match(/loading={acceptanceBusy}/g) || []).length >= 2,
'提交验收/补充图片按钮都应显示 loading',
)
assert.ok(
source.includes('onFinish={(values) => runAcceptanceAction(() => onSubmitAcceptance(values))}'),
'表单提交也必须走在途锁',
)
})