fix(worker): 用户付款金额仅待完善可修改并补后端校验
This commit is contained in:
@@ -2,6 +2,7 @@ import assert from 'node:assert/strict'
|
||||
import test from 'node:test'
|
||||
|
||||
import {
|
||||
canEditUserPaymentAmount,
|
||||
getRewardAbovePayment,
|
||||
getUserPaymentFen,
|
||||
} from '../src/pages/admin/panels/work-order-payment.ts'
|
||||
@@ -62,3 +63,31 @@ test('getUserPaymentFen:空值或非法值不误判成 0 元', () => {
|
||||
assert.equal(getUserPaymentFen({ material: { source: { orderAmountFen: 'abc' } } }), null)
|
||||
assert.equal(getUserPaymentFen({ material: {}, sourceOrderAmount: 0 }), null)
|
||||
})
|
||||
|
||||
test('用户付款金额仅在待完善(pending_material)可编辑', () => {
|
||||
assert.equal(canEditUserPaymentAmount({ status: 'pending_material' }), true)
|
||||
assert.equal(
|
||||
canEditUserPaymentAmount({ status: 'pending_material', rawStatus: 'pending_material' }),
|
||||
true,
|
||||
)
|
||||
|
||||
for (const status of [
|
||||
'unassigned',
|
||||
'open',
|
||||
'in_progress',
|
||||
'pending_acceptance',
|
||||
'problem',
|
||||
'accepted',
|
||||
'cancelled',
|
||||
]) {
|
||||
assert.equal(
|
||||
canEditUserPaymentAmount({ status, rawStatus: status }),
|
||||
false,
|
||||
`${status} 不应允许编辑用户付款金额`,
|
||||
)
|
||||
}
|
||||
|
||||
// rawStatus 是后端原始状态,优先级高于运营态 status
|
||||
assert.equal(canEditUserPaymentAmount({ status: 'open', rawStatus: 'pending_material' }), true)
|
||||
assert.equal(canEditUserPaymentAmount({ status: 'pending_material', rawStatus: 'open' }), false)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user