Files
order_site/apps/frontend/tests/worker-acceptance-submit-guard.test.ts

26 lines
1.0 KiB
TypeScript

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))}'),
'表单提交也必须走在途锁',
)
})