2026-06-15 22:55:18 +08:00
|
|
|
import assert from 'node:assert/strict'
|
|
|
|
|
import test from 'node:test'
|
|
|
|
|
|
|
|
|
|
import {
|
2026-06-18 22:12:24 +08:00
|
|
|
buildStewardPlanMessageText,
|
2026-06-15 22:55:18 +08:00
|
|
|
buildStewardSuggestedActions
|
|
|
|
|
} from '../src/views/scripts/stewardPlanModel.js'
|
|
|
|
|
|
2026-06-18 22:12:24 +08:00
|
|
|
test('steward pending flow confirmation renders extracted fields as table', () => {
|
|
|
|
|
const message = buildStewardPlanMessageText({
|
|
|
|
|
plan_id: 'steward-plan-pending-flow',
|
|
|
|
|
plan_status: 'needs_flow_confirmation',
|
|
|
|
|
next_action: 'confirm_flow',
|
|
|
|
|
pending_flow_confirmation: {
|
|
|
|
|
status: 'pending',
|
|
|
|
|
reason: '已先查询可关联申请单,当前仍需确认下一步。',
|
|
|
|
|
candidate_flows: [
|
|
|
|
|
{
|
|
|
|
|
flow_id: 'travel_application',
|
|
|
|
|
label: '先发起出差申请',
|
|
|
|
|
confidence: 0.82,
|
|
|
|
|
ontology_fields: {
|
|
|
|
|
time_range: '2026-02-20',
|
|
|
|
|
location: '上海',
|
|
|
|
|
expense_type: 'travel',
|
|
|
|
|
reason: '辅助国网仿生产服务器部署'
|
|
|
|
|
},
|
|
|
|
|
missing_fields: ['transport_mode']
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
assert.match(message, /\| 字段 \| 内容 \|/)
|
|
|
|
|
assert.match(message, /\| 费用类型 \| 差旅 \|/)
|
|
|
|
|
assert.match(message, /\| 发生时间 \| 2026-02-20 \|/)
|
|
|
|
|
assert.match(message, /\| 地点 \| 上海 \|/)
|
|
|
|
|
assert.match(message, /\| 事由 \| 辅助国网仿生产服务器部署 \|/)
|
|
|
|
|
assert.doesNotMatch(message, /已提取到:\*\*/)
|
|
|
|
|
assert.match(message, /请先点击下方/)
|
|
|
|
|
})
|
|
|
|
|
|
2026-06-15 22:55:18 +08:00
|
|
|
test('steward pending flow confirmation builds candidate actions', () => {
|
|
|
|
|
const actions = buildStewardSuggestedActions({
|
|
|
|
|
plan_id: 'steward-plan-pending-flow',
|
|
|
|
|
plan_status: 'needs_flow_confirmation',
|
|
|
|
|
next_action: 'confirm_flow',
|
|
|
|
|
pending_flow_confirmation: {
|
|
|
|
|
status: 'pending',
|
|
|
|
|
reason: '缺少申请或报销动作词。',
|
|
|
|
|
candidate_flows: [
|
|
|
|
|
{
|
|
|
|
|
flow_id: 'travel_application',
|
|
|
|
|
label: '补办出差申请',
|
|
|
|
|
confidence: 0.52,
|
|
|
|
|
ontology_fields: {
|
|
|
|
|
time_range: '2026-02-20',
|
|
|
|
|
location: '上海',
|
|
|
|
|
expense_type: 'travel',
|
|
|
|
|
reason: '辅助国网仿生产环境部署'
|
|
|
|
|
},
|
|
|
|
|
missing_fields: ['transport_mode']
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
flow_id: 'travel_reimbursement',
|
|
|
|
|
label: '发起费用报销',
|
|
|
|
|
confidence: 0.48,
|
|
|
|
|
ontology_fields: {
|
|
|
|
|
time_range: '2026-02-20',
|
|
|
|
|
location: '上海',
|
|
|
|
|
expense_type: 'travel',
|
|
|
|
|
reason: '辅助国网仿生产环境部署'
|
|
|
|
|
},
|
|
|
|
|
missing_fields: []
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
assert.equal(actions.length, 2)
|
|
|
|
|
assert.deepEqual(actions.map((item) => item.label), ['补办出差申请', '发起费用报销'])
|
|
|
|
|
assert.equal(actions[0].payload.steward_confirm_flow, true)
|
|
|
|
|
assert.equal(actions[0].payload.flow_id, 'travel_application')
|
|
|
|
|
assert.equal(actions[1].payload.flow_id, 'travel_reimbursement')
|
|
|
|
|
})
|