2026-05-20 21:00:47 +08:00
|
|
|
import assert from 'node:assert/strict'
|
|
|
|
|
import { readFileSync } from 'node:fs'
|
|
|
|
|
import test from 'node:test'
|
|
|
|
|
import { fileURLToPath } from 'node:url'
|
|
|
|
|
|
2026-05-30 15:46:51 +08:00
|
|
|
import { assistantCapabilities } from '../src/data/personalWorkbench.js'
|
|
|
|
|
import {
|
|
|
|
|
buildWorkbenchCapabilityAssistantPayload,
|
|
|
|
|
resolveWorkbenchCapabilityAssistantEntry
|
|
|
|
|
} from '../src/utils/personalWorkbenchAssistantEntry.js'
|
|
|
|
|
|
2026-05-20 21:00:47 +08:00
|
|
|
const workbench = readFileSync(
|
|
|
|
|
fileURLToPath(new URL('../src/components/business/PersonalWorkbench.vue', import.meta.url)),
|
|
|
|
|
'utf8'
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
test('workbench assistant greets the current employee without the old helper tag', () => {
|
|
|
|
|
assert.doesNotMatch(workbench, /assistant-tag/)
|
|
|
|
|
assert.doesNotMatch(workbench, /AI 报销助手/)
|
2026-05-30 15:46:51 +08:00
|
|
|
assert.match(workbench, /嗨,\{\{ displayUserName \}\},我是您的 <span>AI 费用助手<\/span>/)
|
|
|
|
|
assert.match(workbench, /placeholder="请输入费用申请、报销问题、预算查询或制度问答\.\.\."/)
|
|
|
|
|
assert.match(workbench, /const displayUserName = computed/)
|
2026-05-20 21:00:47 +08:00
|
|
|
assert.match(workbench, /user\.name/)
|
|
|
|
|
})
|
2026-05-30 15:46:51 +08:00
|
|
|
|
|
|
|
|
test('workbench capability cards open assistant without injecting canned prompts', () => {
|
|
|
|
|
assert.match(workbench, /@click="openCapabilityAssistant\(item\)"/)
|
|
|
|
|
assert.doesNotMatch(workbench, /openPromptAssistant\(item\.prompt\)/)
|
|
|
|
|
|
|
|
|
|
for (const item of assistantCapabilities) {
|
|
|
|
|
const payload = buildWorkbenchCapabilityAssistantPayload(item, {
|
|
|
|
|
prompt: '',
|
|
|
|
|
source: 'workbench',
|
|
|
|
|
files: []
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
assert.equal(payload.prompt, '')
|
|
|
|
|
assert.equal(payload.conversation, null)
|
|
|
|
|
assert.notEqual(payload.prompt, item.prompt)
|
|
|
|
|
assert.ok(resolveWorkbenchCapabilityAssistantEntry(item).sessionType)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('workbench capability cards keep user-entered context only', () => {
|
|
|
|
|
const [expenseApplication] = assistantCapabilities
|
|
|
|
|
const files = [{ name: 'invoice.pdf' }]
|
|
|
|
|
const payload = buildWorkbenchCapabilityAssistantPayload(expenseApplication, {
|
|
|
|
|
prompt: '我需要申请下周出差费用',
|
|
|
|
|
source: 'workbench',
|
|
|
|
|
files
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
assert.equal(payload.prompt, '我需要申请下周出差费用')
|
|
|
|
|
assert.equal(payload.source, 'application')
|
|
|
|
|
assert.equal(payload.sessionType, 'application')
|
|
|
|
|
assert.equal(payload.files, files)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('workbench submit shows intent recognition feedback before assistant opens', () => {
|
|
|
|
|
assert.match(workbench, /class="assistant-intent-status"/)
|
|
|
|
|
assert.match(workbench, /aria-live="polite"/)
|
|
|
|
|
assert.match(workbench, /正在识别意图,准备进入对应助手/)
|
|
|
|
|
assert.match(workbench, /startPendingAction\('intent'\)/)
|
|
|
|
|
assert.match(workbench, /if \(open\) \{\s*clearPendingAction\(\)/)
|
|
|
|
|
assert.match(workbench, /:readonly="isComposerPending"/)
|
|
|
|
|
})
|