43 lines
1.3 KiB
JavaScript
43 lines
1.3 KiB
JavaScript
|
|
import assert from 'node:assert/strict'
|
|||
|
|
import test from 'node:test'
|
|||
|
|
|
|||
|
|
import {
|
|||
|
|
buildLocalExtractionProgressMessages,
|
|||
|
|
buildLocalIntentPreview,
|
|||
|
|
inferLocalFlowCandidates,
|
|||
|
|
summarizeSemanticIntentDetail
|
|||
|
|
} from '../src/utils/reimbursementTextInference.js'
|
|||
|
|
|
|||
|
|
const ridingFareMessage = '业务发生时间:2026-03-04,送客户去林萃小区办事,请报销乘车费用'
|
|||
|
|
|
|||
|
|
test('local flow intent preview names transport expense for riding fare text', () => {
|
|||
|
|
const candidates = inferLocalFlowCandidates(ridingFareMessage)
|
|||
|
|
|
|||
|
|
assert.equal(candidates.time, '2026-03-04')
|
|||
|
|
assert.equal(candidates.event, '交通出行')
|
|||
|
|
assert.equal(candidates.expenseType, '交通费')
|
|||
|
|
assert.match(buildLocalIntentPreview(ridingFareMessage), /交通费/)
|
|||
|
|
assert.ok(
|
|||
|
|
buildLocalExtractionProgressMessages(ridingFareMessage).some(
|
|||
|
|
(item) => item.includes('交通出行') && item.includes('交通费')
|
|||
|
|
)
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
|
|||
|
|
test('semantic intent detail includes recognized expense type', () => {
|
|||
|
|
assert.equal(
|
|||
|
|
summarizeSemanticIntentDetail({
|
|||
|
|
scenario: 'expense',
|
|||
|
|
intent: 'draft',
|
|||
|
|
entities_json: [
|
|||
|
|
{
|
|||
|
|
type: 'expense_type',
|
|||
|
|
value: '交通',
|
|||
|
|
normalized_value: 'transport'
|
|||
|
|
}
|
|||
|
|
]
|
|||
|
|
}),
|
|||
|
|
'已识别为报销场景,当前目标是草稿生成,费用类型为交通费'
|
|||
|
|
)
|
|||
|
|
})
|