feat: 报销审批流重构与管家计划全链路贯通
- 重构报销状态注册表、审批流路由与平台风险标记 - 完善管家意图规划器与模型计划构建器全链路 - 新增 OCR Worker 脚本、数据库会话管理与通知状态 - 优化文档中心、日志视图、预算中心与员工管理交互 - 增强工作台摘要、图标资源与全局主题样式 - 补充审批路由、状态注册、OCR 服务与管家规划器测试覆盖
This commit is contained in:
@@ -2,13 +2,17 @@ import assert from 'node:assert/strict'
|
||||
import test from 'node:test'
|
||||
|
||||
import {
|
||||
buildDocumentViewedStatePatch,
|
||||
buildDocumentsViewedStatePatches,
|
||||
countNewDocuments,
|
||||
isNewDocument,
|
||||
markDocumentViewed,
|
||||
markDocumentsViewed,
|
||||
mergeNotificationStatesIntoViewedDocumentKeys,
|
||||
readDocumentScope,
|
||||
readViewedDocumentKeys,
|
||||
resolveDocumentNewKey,
|
||||
resolveDocumentNotificationId,
|
||||
writeDocumentScope
|
||||
} from '../src/utils/documentCenterNewState.js'
|
||||
import { buildDocumentInboxRows } from '../src/composables/useDocumentCenterInbox.js'
|
||||
@@ -28,6 +32,38 @@ function createMemoryStorage(initial = {}) {
|
||||
test('document center new state resolves source scoped document keys', () => {
|
||||
assert.equal(resolveDocumentNewKey({ source: 'archive', claimId: 'claim-1' }), 'archive:claim-1')
|
||||
assert.equal(resolveDocumentNewKey({ source: 'approval', documentNo: 'EXP-1' }), 'approval:EXP-1')
|
||||
assert.equal(
|
||||
resolveDocumentNotificationId({ source: 'owned', claimId: 'claim-1', documentKey: 'owned:claim-1' }),
|
||||
'document:owned:claim-1'
|
||||
)
|
||||
})
|
||||
|
||||
test('document center merges backend notification states into viewed keys', () => {
|
||||
const storage = createMemoryStorage()
|
||||
const viewedKeys = mergeNotificationStatesIntoViewedDocumentKeys([
|
||||
{ notification_id: 'document:owned:claim-1', read_at: '2026-06-05T09:00:00+08:00' },
|
||||
{ notificationId: 'document:approval:claim-2', hiddenAt: '2026-06-05T09:01:00+08:00' },
|
||||
{ notification_id: 'workbench:todo:claim-3', read_at: '2026-06-05T09:02:00+08:00' }
|
||||
], readViewedDocumentKeys(storage), storage)
|
||||
|
||||
assert.equal(isNewDocument({ source: 'owned', claimId: 'claim-1' }, viewedKeys), false)
|
||||
assert.equal(isNewDocument({ source: 'approval', claimId: 'claim-2' }, viewedKeys), false)
|
||||
assert.deepEqual([...readViewedDocumentKeys(storage)], ['owned:claim-1', 'approval:claim-2'])
|
||||
})
|
||||
|
||||
test('document center builds backend viewed-state patches for unread rows', () => {
|
||||
const rows = [
|
||||
{ source: 'owned', claimId: 'claim-1', documentKey: 'owned:claim-1' },
|
||||
{ source: 'approval', claimId: 'claim-2', documentKey: 'approval:claim-2' },
|
||||
{ source: 'archive', claimId: 'claim-3', documentKey: 'archive:claim-3' }
|
||||
]
|
||||
const patches = buildDocumentsViewedStatePatches(rows, new Set(['owned:claim-1']))
|
||||
|
||||
assert.deepEqual(patches.map((patch) => patch.notification_id), ['document:approval:claim-2'])
|
||||
assert.equal(patches[0].read, true)
|
||||
assert.equal(patches[0].hidden, false)
|
||||
assert.equal(patches[0].context_json.kind, 'document')
|
||||
assert.equal(buildDocumentViewedStatePatch(rows[2]), null)
|
||||
})
|
||||
|
||||
test('document center new state counts unseen documents and persists viewed rows', () => {
|
||||
|
||||
Reference in New Issue
Block a user