cmvr-wms/ruoyi-ui-vue3/tests/unit/assistant-reference-summary.test.mjs
lixiaolong 149bde836f feat(assistant): 扩展业务助手功能支持更多文档类型和业务场景
- 新增 PDF 文档支持,包括格式校验和完整性检查
- 扩展 Word、TXT 和 ZIP 格式附件处理能力
- 添加 Excel 附件可选择仅作为业务文件不解析行数据
- 实现业务助手表格布局配置新增库存和预算字段
- 集成通知、反馈通知等新的业务助手动作类型
- 完善部门管理包含父级部门和排序字段支持
- 增强业务规则校验涵盖更多系统管理场景
- 优化附件上传限制提示信息更准确
- 添加生成文件下载的安全性校验机制
- 扩展测试覆盖确保各业务动作规则正确性
2026-10-18 08:49:30 +08:00

29 lines
1.6 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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')
})