2026-05-20 21:00:47 +08:00
|
|
|
import assert from 'node:assert/strict'
|
2026-06-02 14:01:51 +08:00
|
|
|
import { readFileSync, statSync } from 'node:fs'
|
2026-05-20 21:00:47 +08:00
|
|
|
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'
|
|
|
|
|
)
|
2026-06-02 14:01:51 +08:00
|
|
|
const workbenchStyles = readFileSync(
|
|
|
|
|
fileURLToPath(new URL('../src/assets/styles/components/personal-workbench.css', import.meta.url)),
|
|
|
|
|
'utf8'
|
|
|
|
|
)
|
|
|
|
|
const workbenchGlassStyles = readFileSync(
|
|
|
|
|
fileURLToPath(new URL('../src/assets/styles/components/personal-workbench-glass.css', import.meta.url)),
|
|
|
|
|
'utf8'
|
|
|
|
|
)
|
|
|
|
|
const workbenchCardStyles = `${workbenchStyles}\n${workbenchGlassStyles}`
|
|
|
|
|
const workbenchResponsiveStyles = readFileSync(
|
|
|
|
|
fileURLToPath(new URL('../src/assets/styles/components/personal-workbench-responsive.css', import.meta.url)),
|
|
|
|
|
'utf8'
|
|
|
|
|
)
|
|
|
|
|
const workbenchInsightStyles = readFileSync(
|
|
|
|
|
fileURLToPath(new URL('../src/assets/styles/components/personal-workbench-insights.css', import.meta.url)),
|
|
|
|
|
'utf8'
|
|
|
|
|
)
|
|
|
|
|
const heroBackgroundAsset = fileURLToPath(
|
|
|
|
|
new URL('../src/assets/personal-workbench-hero-bg-theme-base.webp', import.meta.url)
|
|
|
|
|
)
|
|
|
|
|
const capabilityGlassAsset = fileURLToPath(
|
|
|
|
|
new URL('../src/assets/personal-workbench-card-glass-capability.webp', import.meta.url)
|
|
|
|
|
)
|
|
|
|
|
const panelGlassAsset = fileURLToPath(
|
|
|
|
|
new URL('../src/assets/personal-workbench-card-glass-panel.webp', import.meta.url)
|
|
|
|
|
)
|
2026-05-20 21:00:47 +08:00
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
})
|
|
|
|
|
|
2026-06-02 14:01:51 +08:00
|
|
|
test('workbench hero uses theme-tintable background image', () => {
|
|
|
|
|
assert.match(workbench, /personal-workbench-hero-bg-theme-base\.webp/)
|
|
|
|
|
assert.doesNotMatch(workbench, /personal-workbench-hero-bg-theme-base\.png/)
|
|
|
|
|
assert.match(workbench, /--assistant-bg-image.*workbenchHeroBackground/)
|
|
|
|
|
assert.match(workbenchStyles, /--assistant-theme-tint:[\s\S]*--theme-primary-rgb/)
|
|
|
|
|
assert.match(workbenchStyles, /var\(--assistant-bg-image\) var\(--assistant-bg-position\) \/ var\(--assistant-bg-size\) no-repeat/)
|
|
|
|
|
assert.match(workbenchStyles, /background-blend-mode:\s*normal,\s*color,\s*luminosity;/)
|
|
|
|
|
assert.match(workbenchStyles, /\.assistant-hero::after\s*\{[\s\S]*content:\s*none;/)
|
|
|
|
|
assert.match(workbenchResponsiveStyles, /--assistant-bg-position:\s*68% center;/)
|
|
|
|
|
assert.doesNotMatch(workbenchResponsiveStyles, /homepage_backgraound/)
|
|
|
|
|
assert.ok(statSync(heroBackgroundAsset).size < 120 * 1024)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('workbench cards use layered glass material instead of texture-led cards', () => {
|
|
|
|
|
assert.match(workbench, /personal-workbench-glass\.css/)
|
|
|
|
|
assert.match(workbenchGlassStyles, /--workbench-capability-bg-image:\s*url\("\.\.\/\.\.\/personal-workbench-card-glass-capability\.webp"\)/)
|
|
|
|
|
assert.match(workbenchGlassStyles, /--workbench-panel-bg-image:\s*url\("\.\.\/\.\.\/personal-workbench-card-glass-panel\.webp"\)/)
|
|
|
|
|
assert.match(workbenchGlassStyles, /--workbench-glass-base:/)
|
|
|
|
|
assert.match(workbenchGlassStyles, /--workbench-glass-highlight:/)
|
|
|
|
|
assert.match(workbenchGlassStyles, /--workbench-glass-noise-opacity:\s*0\.012;/)
|
|
|
|
|
assert.match(workbenchGlassStyles, /--workbench-glass-blur:\s*blur\(18px\) saturate\(1\.28\);/)
|
|
|
|
|
assert.match(workbenchGlassStyles, /\.capability-card\s*\{[\s\S]*background-color:\s*rgba\(255,\s*255,\s*255,\s*0\.64\);[\s\S]*backdrop-filter:\s*var\(--workbench-glass-blur\)/)
|
|
|
|
|
assert.match(workbenchGlassStyles, /\.workbench-card\s*\{[\s\S]*background-color:\s*rgba\(255,\s*255,\s*255,\s*0\.66\);[\s\S]*backdrop-filter:\s*var\(--workbench-glass-blur\)/)
|
|
|
|
|
assert.match(workbenchGlassStyles, /\.capability-card::before,[\s\S]*\.capability-card::after/)
|
|
|
|
|
assert.match(workbenchGlassStyles, /\.capability-card::before\s*\{[\s\S]*var\(--workbench-capability-bg-image\) 0 0 \/ var\(--workbench-capability-tile-size\) repeat;[\s\S]*opacity:\s*var\(--workbench-glass-noise-opacity\);/)
|
|
|
|
|
assert.match(workbenchGlassStyles, /\.workbench-card::before\s*\{[\s\S]*var\(--workbench-panel-bg-image\) 0 0 \/ var\(--workbench-panel-tile-size\) repeat;[\s\S]*opacity:\s*calc\(var\(--workbench-glass-noise-opacity\) \* 0\.8\);/)
|
|
|
|
|
assert.match(workbenchGlassStyles, /\.capability-card::after\s*\{[\s\S]*var\(--workbench-glass-highlight\)/)
|
|
|
|
|
assert.match(workbenchGlassStyles, /\.workbench-card::after\s*\{[\s\S]*var\(--workbench-glass-highlight\)/)
|
|
|
|
|
assert.doesNotMatch(workbenchGlassStyles, /\.capability-card::after\s*\{[^}]*radial-gradient/)
|
|
|
|
|
assert.doesNotMatch(workbenchGlassStyles, /\.workbench-card::after\s*\{[^}]*radial-gradient/)
|
|
|
|
|
assert.match(workbenchGlassStyles, /\.workbench-card > \*\s*\{[\s\S]*z-index:\s*1;/)
|
|
|
|
|
assert.match(workbenchGlassStyles, /--workbench-capability-tile-size:\s*384px 384px;/)
|
|
|
|
|
assert.match(workbenchGlassStyles, /--workbench-panel-tile-size:\s*512px 512px;/)
|
|
|
|
|
assert.doesNotMatch(workbenchCardStyles, /var\(--workbench-capability-bg-image\)[^;]*cover no-repeat/)
|
|
|
|
|
assert.doesNotMatch(workbenchCardStyles, /var\(--workbench-panel-bg-image\)[^;]*cover no-repeat/)
|
|
|
|
|
assert.match(workbenchGlassStyles, /--workbench-glass-theme-tint:[\s\S]*--theme-primary-rgb/)
|
|
|
|
|
assert.doesNotMatch(workbenchCardStyles, /background-blend-mode:\s*normal,\s*color,\s*normal;/)
|
|
|
|
|
assert.match(workbenchResponsiveStyles, /--workbench-glass-noise-opacity:\s*0\.008;/)
|
|
|
|
|
assert.match(workbenchResponsiveStyles, /--workbench-glass-blur:\s*blur\(14px\) saturate\(1\.2\);/)
|
2026-06-03 09:25:23 +08:00
|
|
|
assert.match(workbenchGlassStyles, /\.progress-row\s*\{[\s\S]*background:\s*transparent;[\s\S]*box-shadow:\s*inset 0 1px 0 rgba\(var\(--theme-primary-rgb/)
|
|
|
|
|
assert.doesNotMatch(workbench, /<h2>我的待办<\/h2>/)
|
|
|
|
|
assert.doesNotMatch(workbench, /<h2>关键动作<\/h2>/)
|
|
|
|
|
assert.doesNotMatch(workbenchGlassStyles, /\.todo-row/)
|
2026-06-02 14:01:51 +08:00
|
|
|
assert.doesNotMatch(workbenchGlassStyles, /\.progress-row\s*\{[\s\S]*border-top:\s*1px solid var\(--workbench-line-soft\)/)
|
|
|
|
|
assert.match(workbenchInsightStyles, /\.insight-metric-row,[\s\S]*\.insight-profile-card\s*\{[\s\S]*backdrop-filter:\s*blur\(10px\) saturate\(1\.16\)/)
|
|
|
|
|
assert.doesNotMatch(workbenchInsightStyles, /background:\s*#ffffff;/)
|
|
|
|
|
assert.ok(statSync(capabilityGlassAsset).size > 1024)
|
|
|
|
|
assert.ok(statSync(panelGlassAsset).size > 1024)
|
|
|
|
|
assert.ok(statSync(capabilityGlassAsset).size < 24 * 1024)
|
|
|
|
|
assert.ok(statSync(panelGlassAsset).size < 24 * 1024)
|
|
|
|
|
})
|
|
|
|
|
|
2026-05-30 15:46:51 +08:00
|
|
|
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"/)
|
|
|
|
|
})
|
2026-06-03 12:28:21 +08:00
|
|
|
|
|
|
|
|
test('workbench progress rows show update time first', () => {
|
|
|
|
|
assert.match(workbench, /class="progress-time"/)
|
2026-06-03 15:14:44 +08:00
|
|
|
assert.match(workbench, /class="progress-type"/)
|
|
|
|
|
assert.match(workbench, /费用类型/)
|
|
|
|
|
assert.match(workbench, /\{\{ item\.expenseTypeLabel \|\| '其他费用' \}\}/)
|
|
|
|
|
assert.match(workbench, /source:\s*'workbench'/)
|
|
|
|
|
assert.match(workbench, /returnTo:\s*'workbench'/)
|
2026-06-03 12:38:17 +08:00
|
|
|
assert.match(workbench, /has-long-duration-divider/)
|
|
|
|
|
assert.match(workbench, /hasLongDurationDivider/)
|
|
|
|
|
assert.match(workbench, /const LONG_DURATION_DAYS = 10/)
|
|
|
|
|
assert.match(workbench, /isLongDurationProgress\(item\?\.updatedAt\)/)
|
2026-06-03 12:28:21 +08:00
|
|
|
assert.match(workbench, /<time :datetime="item\.updatedAt \|\| ''">\{\{ item\.displayTime \}\}<\/time>/)
|
|
|
|
|
assert.match(workbench, /displayTime: formatProgressTime\(item\?\.updatedAt\)/)
|
|
|
|
|
assert.match(workbench, /function formatProgressTime\(value\)/)
|
2026-06-03 14:59:55 +08:00
|
|
|
assert.doesNotMatch(workbench, />全部进度/)
|
2026-06-03 15:14:44 +08:00
|
|
|
assert.match(workbenchStyles, /\.progress-row\s*\{[\s\S]*grid-template-columns:\s*minmax\(78px,\s*0\.42fr\)[\s\S]*minmax\(84px,\s*0\.42fr\)/)
|
2026-06-03 15:21:38 +08:00
|
|
|
assert.match(workbenchStyles, /\.progress-type\s*\{[\s\S]*justify-self:\s*stretch;[\s\S]*justify-items:\s*center;[\s\S]*text-align:\s*center;/)
|
|
|
|
|
assert.match(workbenchStyles, /\.progress-type strong\s*\{[\s\S]*justify-content:\s*center;/)
|
2026-06-03 15:14:44 +08:00
|
|
|
assert.match(workbenchStyles, /\.progress-type strong\s*\{[\s\S]*var\(--workbench-primary-active\)/)
|
2026-06-03 12:38:17 +08:00
|
|
|
assert.match(workbenchStyles, /\.progress-row\.has-long-duration-divider::before\s*\{[\s\S]*content:\s*"10日以上"/)
|
2026-06-03 14:59:55 +08:00
|
|
|
assert.match(workbenchStyles, /\.progress-row\.has-long-duration-divider::before\s*\{[\s\S]*left:\s*50%;[\s\S]*transform:\s*translateX\(-50%\);/)
|
|
|
|
|
assert.match(workbenchStyles, /\.progress-row\.has-long-duration-divider::before\s*\{[\s\S]*color:\s*var\(--theme-primary-active\);/)
|
|
|
|
|
assert.match(workbenchStyles, /\.progress-row\.has-long-duration-divider::after\s*\{[\s\S]*rgba\(var\(--theme-primary-rgb/)
|
2026-06-03 12:28:21 +08:00
|
|
|
assert.match(workbenchStyles, /\.progress-time\s*\{[\s\S]*color:\s*var\(--workbench-muted\);/)
|
2026-06-03 15:14:44 +08:00
|
|
|
assert.match(workbenchResponsiveStyles, /grid-template-areas:[\s\S]*"time identity result"[\s\S]*"type type type"[\s\S]*"steps steps steps"/)
|
|
|
|
|
assert.match(workbenchResponsiveStyles, /\.progress-type\s*\{[\s\S]*grid-area:\s*type;/)
|
2026-06-03 12:28:21 +08:00
|
|
|
})
|
2026-06-03 14:59:55 +08:00
|
|
|
|
|
|
|
|
test('workbench expense stats detail opens a local modal instead of the assistant', () => {
|
|
|
|
|
assert.match(workbench, /import ExpenseStatsDetailModal from '\.\/ExpenseStatsDetailModal\.vue'/)
|
|
|
|
|
assert.match(workbench, /<ExpenseStatsDetailModal/)
|
|
|
|
|
assert.match(workbench, /const expenseStatsModalOpen = ref\(false\)/)
|
|
|
|
|
assert.match(workbench, /const expenseStatsDetail = computed\(\(\) => props\.workbenchSummary\.expenseStatsDetail \|\| \{\}\)/)
|
|
|
|
|
assert.match(workbench, /@click="openExpenseStatsModal"/)
|
|
|
|
|
assert.match(workbench, /:aria-expanded="expenseStatsModalOpen"/)
|
|
|
|
|
assert.match(workbench, /function openExpenseStatsModal\(\)/)
|
|
|
|
|
assert.match(workbench, /function closeExpenseStatsModal\(\)/)
|
|
|
|
|
assert.doesNotMatch(workbench, /查看我的费用统计详情/)
|
|
|
|
|
})
|