- authUser 抽出 resolveAuthUserAdminFlag,统一 isAdmin 解析(含 superadmin、role_codes、中英文角色名),accessControl 复用同一逻辑 - 登录态、应用外壳路由、系统状态接入统一管理员判定,LoginView 与相关 composable 配套调整 - AI 工作台申请提交改为调用新的 /application-preview-action 接口,草稿保存仍走 orchestrator;预审模型补充重叠冲突提示与阻断判断 - 同步更新 accessControl/api-request/ai 预览动作等前端测试
91 lines
2.5 KiB
JavaScript
91 lines
2.5 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 testSaveDraftActionKeepsOrchestratorPath() {
|
|
let capturedUrl = ''
|
|
|
|
global.fetch = async (url) => {
|
|
capturedUrl = String(url)
|
|
return {
|
|
ok: true,
|
|
async json() {
|
|
return { status: 'succeeded', result: {} }
|
|
}
|
|
}
|
|
}
|
|
|
|
await runAiApplicationPreviewAction({
|
|
actionType: AI_APPLICATION_ACTION_SAVE_DRAFT,
|
|
applicationPreview: { fields: { reason: '项目实施' } },
|
|
currentUser: { username: 'zhangsan@example.com', name: '张三' }
|
|
})
|
|
|
|
assert.equal(capturedUrl, '/api/v1/orchestrator/run')
|
|
}
|
|
|
|
async function run() {
|
|
await testSubmitActionUsesFastPreviewEndpoint()
|
|
await testSaveDraftActionKeepsOrchestratorPath()
|
|
console.log('ai-application-preview-actions tests passed')
|
|
}
|
|
|
|
run().catch((error) => {
|
|
console.error(error)
|
|
process.exit(1)
|
|
})
|