cmvr-wms/ruoyi-ui-vue3/tests/unit/assistant-reference-summary.test.mjs

29 lines
1.6 KiB
JavaScript
Raw Normal View History

import test from 'node:test'
import assert from 'node:assert/strict'
import { assistantReferenceConditions, assistantQueryConditions, assistantQueryPrompt } from '../../src/utils/business-assistant.js'
test('unresolved BOM conditions and follow-up prompts retain the explicit version and scope', () => {
const query = {
label: 'BOM用料明细', fields: [{ key: 'id', label: 'BOM版本', ref: 'bom' }],
rows: [{ id: { keyword: '黑盒测试成品1017', versionTag: 'BB-NOT-EXISTS', scopeType: 'PUBLIC' } }]
}
const value = assistantQueryConditions(query)[0].value
assert.match(value, /名称:黑盒测试成品1017/)
assert.match(value, /BOM版本:BB-NOT-EXISTS/)
assert.match(value, /BOM范围:公共版本/)
assert.match(assistantQueryPrompt(query), /BB-NOT-EXISTS/)
})
test('version-only and project/task-scope references remain readable without inventing a name', () => {
assert.deepEqual(assistantReferenceConditions({ versionTag: 'V2', scopeType: 'PROJECT' }), [
{ label: 'BOM版本', value: 'V2' }, { label: 'BOM范围', value: '项目版本' }
])
assert.deepEqual(assistantReferenceConditions({ scopeType: 'TASK' }), [{ label: 'BOM范围', value: '任务快照' }])
assert.deepEqual(assistantReferenceConditions({ id: 3, unknown: 'do not display' }), [])
})
test('resolved labels still take precedence over raw reference metadata', () => {
const query = { fields: [{ key: 'id', label: 'BOM版本', ref: 'bom' }], rows: [{ id: 3, _labels: { id: '成品 / BB-V1' } }] }
assert.equal(assistantQueryConditions(query)[0].value, '成品 / BB-V1')
})