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(' { 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('默认展示全部配对(含不匹配项)'), '界面必须说明默认口径') })