Files
order_site/apps/frontend/tests/consignment-pending-match-select.test.ts
T
zhaoxing 866f0d37fd feat(consignment): 匹配弹窗增加付款金额与售价差价
一键查询待匹配订单与手动匹配寄卖新增「工单用户付款金额」列,
售价后括号显示「用户付款金额 - 售价」差价:正数绿、负数红、
0 黄;拼单不显示差价,付款未知显示 -。
2026-11-16 14:38:45 +08:00

72 lines
3.7 KiB
TypeScript

import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import { fileURLToPath } from 'node:url'
import test from 'node:test'
function readSource(relativePath: string): string {
return readFileSync(fileURLToPath(new URL(relativePath, import.meta.url)), 'utf8')
}
test('一键查询待匹配订单:每行提供「选择」,打开手动匹配并预选该库存', () => {
const source = readSource('../src/components/admin/ConsignmentPendingMatchModal.tsx')
assert.ok(source.includes("title: '操作'"), '必须新增操作列')
assert.ok(source.includes('选择'), '操作列按钮文案必须是「选择」')
assert.ok(source.includes('setSelectTarget({'), '点击选择必须记录订单与库存')
assert.ok(source.includes('<ConsignmentWorkOrderMatchModal'), '必须挂载手动匹配弹窗')
assert.ok(source.includes('initialInventoryIds'), '必须把选中的库存传给手动匹配弹窗')
assert.ok(source.includes('workOrderId={selectTarget?.workOrderId ?? null}'))
})
test('一键查询待匹配订单:快速匹配按履约权限门控,成功后刷新看板与库存', () => {
const modal = readSource('../src/components/admin/ConsignmentPendingMatchModal.tsx')
const panel = readSource('../src/pages/admin/panels/ConsignmentInventoryPanel.tsx')
assert.ok(modal.includes('canMatch = false'), '默认无权限时不给操作入口')
assert.ok(modal.includes('void query.refetch()'), '匹配成功后必须刷新看板')
assert.ok(modal.includes('onMatched?.()'), '匹配成功后必须通知外层刷新库存')
assert.ok(
panel.includes('canMatch={canFulfillConsignment}'),
'仓库面板必须按 consignment.fulfill 权限传入 canMatch',
)
assert.ok(
panel.includes('onMatched={() => void inventoriesQuery.refetch()}'),
'仓库面板必须刷新库存列表',
)
})
test('一键查询待匹配订单:说明文案不再声称「不直接改单」', () => {
const source = readSource('../src/components/admin/ConsignmentPendingMatchModal.tsx')
assert.ok(!source.includes('不直接改单'), '新增选择匹配后必须去掉只读文案')
assert.ok(source.includes('「手动匹配方式」') || source.includes('手动匹配'))
})
test('一键查询待匹配订单:默认展示全部配对并按枪型/钻石/璀璨排序', () => {
const source = readSource('../src/components/admin/ConsignmentPendingMatchModal.tsx')
assert.ok(source.includes('includeConflicts: true'), '默认必须包含冲突(0 分)配对')
assert.ok(!source.includes('显示 0 分不匹配项'), '旧的勾选框必须删除')
assert.ok(
!source.includes('right.score - left.score'),
'不得在前端只按分数重排,否则会覆盖后端的「枪型/钻石/璀璨」优先级',
)
assert.ok(source.includes('不匹配 {data?.conflictCount ?? 0}'), '必须展示不匹配数量')
assert.ok(source.includes('默认展示全部配对,按 枪型 → 钻石 → 璀璨 排序'), '界面必须说明默认口径')
})
test('一键查询 / 手动匹配:展示工单用户付款金额与售价差价', () => {
const pending = readSource('../src/components/admin/ConsignmentPendingMatchModal.tsx')
const manual = readSource('../src/components/admin/ConsignmentWorkOrderMatchModal.tsx')
for (const source of [pending, manual]) {
assert.ok(source.includes("title: '工单用户付款金额'"), '两个弹窗都必须有用户付款金额列')
assert.ok(source.includes('ConsignmentPriceWithDiff'), '售价列必须带差价展示')
}
assert.ok(pending.includes('sharingEnabled={record.sharingEnabled}'), '拼单不展示差价')
assert.ok(
manual.includes('sharingEnabled={sharingEnabled && totalQuantity > 1}'),
'拼单不展示差价',
)
})