fix(documents): move unread notice into bell

This commit is contained in:
caoxiaozhu
2026-06-03 17:05:34 +08:00
parent 8c2f301d85
commit c73178b65d
8 changed files with 342 additions and 180 deletions

View File

@@ -198,8 +198,12 @@ test('documents center category tabs render bubble counts for new documents', ()
documentsCenterView,
/const scopeTabItems = computed\(\(\) =>[\s\S]*badgeCount: scopeNewCountMap\.value\[tab\] \|\| 0/
)
assert.match(documentListSharedStyles, /\.scope-tab-label\s*\{[\s\S]*position:\s*relative;/)
assert.match(documentListSharedStyles, /\.scope-tab-badge\s*\{[\s\S]*position:\s*absolute;[\s\S]*top:\s*-8px;[\s\S]*height:\s*15px;/)
const scopeTabBadgeBlock = documentListSharedStyles.match(/\.scope-tab-badge\s*\{[^}]*\}/)?.[0] || ''
assert.match(documentListSharedStyles, /\.scope-tab-label\s*\{[\s\S]*align-items:\s*flex-start;[\s\S]*gap:\s*4px;/)
assert.match(scopeTabBadgeBlock, /position:\s*static;/)
assert.match(scopeTabBadgeBlock, /height:\s*14px;/)
assert.match(scopeTabBadgeBlock, /margin-top:\s*-5px;/)
assert.doesNotMatch(scopeTabBadgeBlock, /position:\s*absolute;/)
})
test('documents center can mark all unread documents as read from toolbar', () => {

View File

@@ -13,6 +13,21 @@ const sidebarStyles = readFileSync(
'utf8'
)
const topbar = readFileSync(
fileURLToPath(new URL('../src/components/layout/TopBar.vue', import.meta.url)),
'utf8'
)
const topbarStyles = readFileSync(
fileURLToPath(new URL('../src/assets/styles/components/top-bar.css', import.meta.url)),
'utf8'
)
const appShellRouteView = readFileSync(
fileURLToPath(new URL('../src/views/AppShellRouteView.vue', import.meta.url)),
'utf8'
)
const documentInbox = readFileSync(
fileURLToPath(new URL('../src/composables/useDocumentCenterInbox.js', import.meta.url)),
'utf8'
@@ -23,19 +38,37 @@ const documentNewState = readFileSync(
'utf8'
)
test('sidebar renders a red dot for unread document center rows', () => {
assert.match(sidebar, /useDocumentCenterInbox/)
assert.match(sidebar, /hasUnread: documentInboxHasUnread/)
assert.match(sidebar, /class="nav-label-text"[\s\S]*class="nav-unread-dot nav-unread-dot-label"/)
assert.match(sidebar, /class="nav-unread-dot nav-unread-dot-collapsed"/)
assert.match(sidebar, /hasNewMessage: item\.id === 'documents' \? documentInboxHasUnread\.value : false/)
assert.match(sidebar, /void refreshDocumentInbox\(\)/)
assert.match(sidebar, /startDocumentInboxPolling\(\)/)
assert.match(sidebar, /stopDocumentInboxPolling\(\)/)
assert.match(sidebarStyles, /\.nav-label-text\s*\{[\s\S]*position:\s*relative;/)
assert.match(sidebarStyles, /\.nav-unread-dot\s*\{[\s\S]*background:\s*#ef4444;/)
assert.match(sidebarStyles, /\.nav-unread-dot-label\s*\{[\s\S]*position:\s*absolute;[\s\S]*top:\s*-8px;/)
assert.match(sidebarStyles, /\.rail-collapsed \.nav-unread-dot-collapsed\s*\{[\s\S]*position:\s*absolute;/)
test('sidebar no longer renders document center unread indicators', () => {
assert.doesNotMatch(sidebar, /useDocumentCenterInbox/)
assert.doesNotMatch(sidebar, /hasUnread: documentInboxHasUnread/)
assert.doesNotMatch(sidebar, /hasNewMessage/)
assert.doesNotMatch(sidebar, /nav-label-text/)
assert.doesNotMatch(sidebar, /nav-unread-dot/)
assert.match(sidebar, /<span class="nav-label">\{\{ item\.displayLabel \}\}<\/span>/)
assert.doesNotMatch(sidebarStyles, /\.nav-label-text\s*\{/)
assert.doesNotMatch(sidebarStyles, /\.nav-unread-dot/)
assert.match(sidebarStyles, /\.nav-label\s*\{[\s\S]*overflow:\s*hidden;[\s\S]*text-overflow:\s*ellipsis;/)
})
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(appShellRouteView, /@navigate="handleNavigate"/)
assert.match(topbar, /startDocumentInboxPolling\(\)/)
assert.match(topbar, /stopDocumentInboxPolling\(\)/)
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-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/)
})
test('document inbox reuses document center viewed-key state', () => {