Files
order_site/apps/frontend/tests/worker-order-acceptance.test.ts
T
zhaoxing db3f477ab3 fix(worker): 整单指派拼单订单无法验收
- 前端:拼单订单整单指派给本人时放行验收
- 后端:整单指派清掉 sharing_enabled;已有有效份额则拒绝
2026-11-02 12:02:24 +08:00

77 lines
1.7 KiB
TypeScript

import assert from 'node:assert/strict'
import test from 'node:test'
import { shouldBlockAcceptanceForMissingShares } from '../src/utils/worker-order-acceptance.ts'
test('拼单缺份额:整单指派给当前打手时放行', () => {
assert.equal(
shouldBlockAcceptanceForMissingShares({
shareCount: 0,
sharingEnabled: true,
assignedWorkerId: 1013,
currentWorkerId: 1013,
}),
false,
)
})
test('拼单缺份额:指派给其他打手时拦截', () => {
assert.equal(
shouldBlockAcceptanceForMissingShares({
shareCount: 0,
sharingEnabled: true,
assignedWorkerId: 999,
currentWorkerId: 1013,
}),
true,
)
})
test('拼单缺份额:没有接单人时拦截', () => {
assert.equal(
shouldBlockAcceptanceForMissingShares({
shareCount: 0,
sharingEnabled: true,
assignedWorkerId: null,
currentWorkerId: 1013,
}),
true,
)
})
test('有份额时按正常份额流程处理,不拦截', () => {
assert.equal(
shouldBlockAcceptanceForMissingShares({
shareCount: 1,
sharingEnabled: true,
assignedWorkerId: 1013,
currentWorkerId: 1013,
}),
false,
)
})
test('非拼单整单没有份额,不拦截', () => {
assert.equal(
shouldBlockAcceptanceForMissingShares({
shareCount: 0,
sharingEnabled: false,
assignedWorkerId: 1013,
currentWorkerId: 1013,
}),
false,
)
})
test('本地取不到当前打手 ID 时保持旧行为(拦截)', () => {
assert.equal(
shouldBlockAcceptanceForMissingShares({
shareCount: 0,
sharingEnabled: true,
assignedWorkerId: 1013,
currentWorkerId: 0,
}),
true,
)
})