51 lines
1.6 KiB
JavaScript
51 lines
1.6 KiB
JavaScript
|
|
import assert from 'node:assert/strict'
|
||
|
|
import test from 'node:test'
|
||
|
|
|
||
|
|
import {
|
||
|
|
buildStewardSuggestedActions
|
||
|
|
} from '../src/views/scripts/stewardPlanModel.js'
|
||
|
|
|
||
|
|
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')
|
||
|
|
})
|