- 新增 PersonalWorkbenchAiMode 组件、AI 侧边栏与 orb 机器人视觉资源 - 新增 aiApplicationDraftModel / aiExpenseDraftModel / aiWorkbenchConversationStore 及业务准入 aiSidebarBusinessAccess,支撑 AI 模式下的申请与报销草稿 - 顶栏、侧边栏、工作台样式重构,适配 AI 模式切换与响应式布局 - 同步 steward plan/off_topic、差旅报销引导流、风险建议卡片等测试
67 lines
1.9 KiB
JavaScript
67 lines
1.9 KiB
JavaScript
import assert from 'node:assert/strict'
|
||
import test from 'node:test'
|
||
|
||
import {
|
||
ASSISTANT_SCOPE_ACTION_FILL_COMPOSER
|
||
} from '../src/utils/assistantSessionScope.js'
|
||
import {
|
||
mergeComposerPrefill,
|
||
resolveSuggestedActionPrefill
|
||
} from '../src/utils/assistantSuggestedActionPrefill.js'
|
||
|
||
test('suggested action prefill uses backend prompt payload', () => {
|
||
assert.equal(
|
||
resolveSuggestedActionPrefill({
|
||
action_type: 'prefill_composer',
|
||
payload: {
|
||
application_field: 'time',
|
||
prompt_prefill: '申请时间段:'
|
||
}
|
||
}),
|
||
'申请时间段:'
|
||
)
|
||
})
|
||
|
||
test('suggested action prefill falls back to application field templates', () => {
|
||
assert.equal(
|
||
resolveSuggestedActionPrefill({
|
||
action_type: 'prefill_composer',
|
||
payload: { application_field: 'amount' }
|
||
}),
|
||
'用户预估费用:'
|
||
)
|
||
assert.equal(
|
||
resolveSuggestedActionPrefill({
|
||
action_type: 'ask_clarification',
|
||
payload: { application_field: 'amount' }
|
||
}),
|
||
''
|
||
)
|
||
})
|
||
|
||
test('composer prefill appends to existing draft without duplication', () => {
|
||
assert.equal(mergeComposerPrefill('', '事由:'), '事由:')
|
||
assert.equal(mergeComposerPrefill('地点:上海', '事由:'), '地点:上海\n事由:')
|
||
assert.equal(mergeComposerPrefill('地点:上海\n事由:', '事由:'), '地点:上海\n事由:')
|
||
})
|
||
|
||
test('fill_composer action resolves payload.fill_text as prefill', () => {
|
||
assert.equal(
|
||
resolveSuggestedActionPrefill({
|
||
action_type: ASSISTANT_SCOPE_ACTION_FILL_COMPOSER,
|
||
payload: { fill_text: '我想要申请明天去北京出差3天' }
|
||
}),
|
||
'我想要申请明天去北京出差3天'
|
||
)
|
||
})
|
||
|
||
test('fill_composer action without fill_text falls back to empty (no application_field lookup)', () => {
|
||
assert.equal(
|
||
resolveSuggestedActionPrefill({
|
||
action_type: ASSISTANT_SCOPE_ACTION_FILL_COMPOSER,
|
||
payload: {}
|
||
}),
|
||
''
|
||
)
|
||
})
|