- aiConversationHtmlRenderer 识别单据记录类表格并渲染为卡片列表,新增删除申请单详情的禁用占位链接 - aiWorkbenchConversationStore 增加草稿删除后会话链接失效处理,避免点击已删除单据跳转 - aiApplicationPreviewActions 调整提交/草稿调用路径,PersonalWorkbenchAiMode 接入新的会话存储与渲染 - ConfirmDialog/TravelRequestDeleteDialog/useAppShell/AppShellRouteView 配套适配,同步更新相关前端测试
108 lines
3.1 KiB
JavaScript
108 lines
3.1 KiB
JavaScript
import assert from 'node:assert/strict'
|
|
|
|
import {
|
|
AI_APPLICATION_ACTION_SAVE_DRAFT,
|
|
AI_APPLICATION_ACTION_SUBMIT,
|
|
runAiApplicationPreviewAction
|
|
} from '../src/services/aiApplicationPreviewActions.js'
|
|
|
|
async function testSubmitActionUsesFastPreviewEndpoint() {
|
|
let capturedUrl = ''
|
|
let capturedOptions = null
|
|
|
|
global.fetch = async (url, options) => {
|
|
capturedUrl = String(url)
|
|
capturedOptions = options
|
|
return {
|
|
ok: true,
|
|
async json() {
|
|
return {
|
|
status: 'succeeded',
|
|
result: {
|
|
draft_payload: {
|
|
claim_id: 'claim-fast-submit',
|
|
claim_no: 'AP-20260620-FAST',
|
|
status: 'submitted',
|
|
approval_stage: '直属领导审批'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
await runAiApplicationPreviewAction({
|
|
actionType: AI_APPLICATION_ACTION_SUBMIT,
|
|
applicationPreview: {
|
|
fields: {
|
|
applicationType: '差旅费用申请',
|
|
time: '2026-07-01 至 2026-07-03',
|
|
location: '北京',
|
|
reason: '项目实施',
|
|
days: '3天',
|
|
transportMode: '火车',
|
|
amount: '1000元'
|
|
}
|
|
},
|
|
currentUser: { username: 'zhangsan@example.com', name: '张三' },
|
|
conversationId: 'conversation-fast-submit'
|
|
})
|
|
|
|
assert.equal(capturedUrl, '/api/v1/reimbursements/application-preview-action')
|
|
assert.equal(capturedOptions.method, 'POST')
|
|
const body = JSON.parse(capturedOptions.body)
|
|
assert.equal(body.context_json.session_type, 'application')
|
|
assert.equal(body.context_json.application_stage, 'expense_application')
|
|
assert.equal(body.context_json.application_preview.fields.transportMode, '火车')
|
|
}
|
|
|
|
async function testSaveDraftActionUsesFastPreviewEndpoint() {
|
|
let capturedUrl = ''
|
|
let capturedOptions = null
|
|
|
|
global.fetch = async (url, options) => {
|
|
capturedUrl = String(url)
|
|
capturedOptions = options
|
|
return {
|
|
ok: true,
|
|
async json() {
|
|
return {
|
|
status: 'succeeded',
|
|
result: {
|
|
draft_payload: {
|
|
claim_id: 'claim-fast-draft',
|
|
claim_no: 'AP-20260620-DRAFT',
|
|
status: 'draft',
|
|
approval_stage: '待提交'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
await runAiApplicationPreviewAction({
|
|
actionType: AI_APPLICATION_ACTION_SAVE_DRAFT,
|
|
applicationPreview: { fields: { reason: '项目实施' } },
|
|
currentUser: { username: 'zhangsan@example.com', name: '张三' }
|
|
})
|
|
|
|
assert.equal(capturedUrl, '/api/v1/reimbursements/application-preview-action')
|
|
assert.equal(capturedOptions.method, 'POST')
|
|
const body = JSON.parse(capturedOptions.body)
|
|
assert.equal(body.context_json.application_action, 'save_draft')
|
|
assert.equal(body.context_json.application_save_mode, true)
|
|
assert.equal(body.context_json.application_stage, 'expense_application')
|
|
}
|
|
|
|
async function run() {
|
|
await testSubmitActionUsesFastPreviewEndpoint()
|
|
await testSaveDraftActionUsesFastPreviewEndpoint()
|
|
console.log('ai-application-preview-actions tests passed')
|
|
}
|
|
|
|
run().catch((error) => {
|
|
console.error(error)
|
|
process.exit(1)
|
|
})
|