Files
order_site/apps/frontend/tests/consignment-pending-match-select.test.ts
T

61 lines
3.1 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 modal = readSource('../src/components/admin/ConsignmentPendingMatchModal.tsx')
const panel = readSource('../src/pages/admin/panels/ConsignmentInventoryPanel.tsx')
assert.ok(modal.includes('fetchPendingSuernanPistolMatches'), '必须调用简单手枪匹配接口')
assert.ok(modal.includes('不直接改单'), '一键查询必须是只读看板')
assert.ok(!modal.includes('<ConsignmentWorkOrderMatchModal'), '不得再嵌套手动匹配弹窗')
assert.ok(!modal.includes('setSelectTarget('), '不得恢复二级选择流程')
assert.ok(!modal.includes('ConsignmentPriceWithDiff'), '简单看板不展示付款差价')
assert.ok(
panel.includes('<ConsignmentPendingMatchModal\n open={pendingMatchOpen}'),
'仓库面板只传入开关状态',
)
assert.ok(
!panel.includes('categoryId={categoryId}\n categoryName='),
'不得隐式继承库存分类',
)
})
test('一键查询待匹配订单:默认隐藏冲突,可显式查看', () => {
const source = readSource('../src/components/admin/ConsignmentPendingMatchModal.tsx')
assert.ok(source.includes('useState(false)'), '冲突项默认关闭')
assert.ok(source.includes('includeConflicts,'), '查询必须透传冲突开关')
assert.ok(source.includes('显示 0 分不匹配项'), '必须保留冲突查看开关')
assert.ok(source.includes('系统 20 / 区服 20 / 系列 20 / 钻级 25 / 璀璨 15'), '必须说明固定权重')
assert.ok(source.includes('同分时录单更早的订单优先'), '积压订单必须优先')
})
test('一键查询待匹配订单:后端读取全部 open 工单并按剩余数量统计库存', () => {
const source = readSource(
'../../backend/src/services/worker-platform/consignment-pending-match-service.ts',
)
assert.ok(source.includes('listAllOpenWorkOrdersForPistolBoard'), '必须提供简单手枪查询入口')
assert.ok(source.includes('while (items.length < total)'), '不得只读取最近 500 单')
assert.ok(
source.includes('sum + Math.max(0, Number(inventory.remaining_quantity ?? 1))'),
'在库件数必须按 remaining_quantity 汇总',
)
assert.ok(source.includes('listPendingSuernanPistolMatches'), '必须导出简单手枪查询服务')
})
test('一键查询待匹配订单:不得影响库存侧完整匹配引擎', () => {
const service = readSource('../src/services/admin/consignment.ts')
const inventoryModal = readSource('../src/components/admin/ConsignmentInventoryMatchModal.tsx')
assert.ok(service.includes('fetchPendingPistolMatches'), '库存侧完整匹配接口必须保留')
assert.ok(service.includes('/consignment/pending-pistol-matches'), '库存侧继续使用原完整匹配接口')
assert.ok(inventoryModal.includes('fetchPendingPistolMatches'), '库存侧弹窗不得改用简单看板接口')
})