fix(notifications): refine bell notification center
This commit is contained in:
@@ -85,6 +85,24 @@ test('document center sidebar inbox shares source scoped document keys', () => {
|
||||
assert.deepEqual(rows.map((row) => resolveDocumentNewKey(row)), ['approval:claim-1', 'archive:claim-2'])
|
||||
})
|
||||
|
||||
test('document center inbox rows expose real notification metadata', () => {
|
||||
const rows = buildDocumentInboxRows({
|
||||
ownedClaims: [{
|
||||
id: 'claim-1',
|
||||
claim_no: 'EXP-1',
|
||||
title: '差旅报销',
|
||||
status: 'draft',
|
||||
created_at: '2026-06-03T09:10:00+08:00'
|
||||
}]
|
||||
})
|
||||
|
||||
assert.equal(rows[0].documentNo, 'EXP-1')
|
||||
assert.equal(rows[0].sourceLabel, '我的单据')
|
||||
assert.equal(rows[0].title, '差旅报销')
|
||||
assert.equal(rows[0].createdAt, '2026-06-03T09:10:00+08:00')
|
||||
assert.equal(Number.isFinite(rows[0].sortTime), true)
|
||||
})
|
||||
|
||||
test('document center scope state restores only allowed tabs', () => {
|
||||
const storage = createMemoryStorage()
|
||||
const scopes = ['全部', '申请单', '报销单', '审核单', '归档']
|
||||
|
||||
@@ -52,22 +52,30 @@ test('sidebar no longer renders document center unread indicators', () => {
|
||||
|
||||
test('topbar bell owns document center unread notifications', () => {
|
||||
assert.match(topbar, /useDocumentCenterInbox/)
|
||||
assert.match(topbar, /unreadCount: documentInboxUnreadCount/)
|
||||
assert.match(topbar, /const workbenchNotificationCount = computed/)
|
||||
assert.match(topbar, /const count = workbenchNotificationCount\.value \+ Number\(documentInboxUnreadCount\.value \|\| 0\)/)
|
||||
assert.match(topbar, /const documentInboxNotification = computed/)
|
||||
assert.match(topbar, /id: 'document-center-unread'/)
|
||||
assert.match(topbar, /title: '单据中心有新单据'/)
|
||||
assert.match(topbar, /target: \{ type: 'documents-center' \}/)
|
||||
assert.match(topbar, /emit\('navigate', 'documents'\)/)
|
||||
assert.match(topbar, /notificationRows: documentInboxNotificationRows/)
|
||||
assert.match(topbar, /const documentNotificationItems = computed/)
|
||||
assert.match(topbar, /title: `\$\{row\.documentTypeLabel \|\| '单据'\} \$\{row\.documentNo \|\| row\.claimId \|\| '待生成'\}`/)
|
||||
assert.match(topbar, /description: resolveDocumentNotificationDescription\(row\)/)
|
||||
assert.match(topbar, /markDocumentInboxRowRead\(item\.documentRow\)/)
|
||||
assert.match(topbar, /markDocumentInboxRowsRead\(documentRows\)/)
|
||||
assert.match(topbar, /const topbarNotificationCount = computed\(\(\) => \{[\s\S]*const count = unreadNotifications\.value\.length/)
|
||||
assert.doesNotMatch(topbar, /document-center-unread/)
|
||||
assert.doesNotMatch(topbar, /target: \{ type: 'documents-center' \}/)
|
||||
assert.doesNotMatch(topbar, /emit\('navigate', 'documents'\)/)
|
||||
assert.match(appShellRouteView, /@navigate="handleNavigate"/)
|
||||
assert.match(topbar, /startDocumentInboxPolling\(\)/)
|
||||
assert.match(topbar, /stopDocumentInboxPolling\(\)/)
|
||||
assert.match(topbar, /class="notification-clear-btn"/)
|
||||
assert.match(topbar, /function clearAllNotifications\(\)/)
|
||||
assert.match(topbar, /function markNotificationRead\(item\)/)
|
||||
assert.match(topbar, /class="notification-type-icon" :class="item\.tone"/)
|
||||
assert.match(topbarStyles, /\.notification-head-copy\s*\{[\s\S]*display:\s*grid;/)
|
||||
assert.match(topbarStyles, /\.notification-head-actions\s*\{[\s\S]*display:\s*inline-flex;/)
|
||||
assert.match(topbarStyles, /\.notification-close-btn span::before\s*\{[\s\S]*rotate\(45deg\);/)
|
||||
assert.match(topbarStyles, /\.notification-close-btn span::after\s*\{[\s\S]*rotate\(-45deg\);/)
|
||||
assert.match(topbarStyles, /\.notification-list\s*\{[\s\S]*max-height:\s*244px;[\s\S]*overflow-y:\s*auto;/)
|
||||
assert.match(topbarStyles, /\.notification-tabs button em\s*\{[\s\S]*border-radius:\s*999px;/)
|
||||
assert.match(topbarStyles, /\.notification-row\s*\{[\s\S]*grid-template-columns:\s*34px minmax\(0,\s*1fr\) 16px;/)
|
||||
assert.match(topbarStyles, /\.notification-type-icon\.danger\s*\{[\s\S]*background:\s*#fff5f5;/)
|
||||
assert.doesNotMatch(topbarStyles, /\.notification-dot/)
|
||||
})
|
||||
|
||||
@@ -75,6 +83,10 @@ test('document inbox reuses document center viewed-key state', () => {
|
||||
assert.match(documentInbox, /DOCUMENT_VIEWED_KEYS_CHANGE_EVENT/)
|
||||
assert.match(documentInbox, /readViewedDocumentKeys/)
|
||||
assert.match(documentInbox, /countNewDocuments\(documentRows\.value, viewedDocumentKeys\.value\)/)
|
||||
assert.match(documentInbox, /const notificationRows = computed/)
|
||||
assert.match(documentInbox, /isUnread: isNewDocument\(row, viewedDocumentKeys\.value\)/)
|
||||
assert.match(documentInbox, /function markDocumentInboxRowRead\(row\)/)
|
||||
assert.match(documentInbox, /function markDocumentInboxRowsRead\(rows = documentRows\.value\)/)
|
||||
assert.match(documentInbox, /fetchExpenseClaims/)
|
||||
assert.match(documentInbox, /fetchApprovalExpenseClaims/)
|
||||
assert.match(documentInbox, /fetchArchivedExpenseClaims/)
|
||||
|
||||
Reference in New Issue
Block a user