mirror of
https://wget.la/https://github.com/Wxw-Gu/WechatExplorer
synced 2026-12-01 17:25:15 +08:00
feat: 扩展中心支持多模态消息、HTML 渲染、一级导航与应用内通知
This commit is contained in:
1 parent
b20e514c90
commit
4ea73c3414
63 files changed
+8360
-644
No files matched your search
@@ -0,0 +1,55 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { render, waitFor } from '@testing-library/react'
|
||||
import { PrimaryNavigation } from '../../src/renderer/src/components/layout/PrimaryNavigation'
|
||||
import type {
|
||||
ExtensionNotificationSummary,
|
||||
PinnedExtensionNavItem
|
||||
} from '../../src/shared/extensions/types'
|
||||
|
||||
describe('PrimaryNavigation 通知角标与发送异常提示区分', () => {
|
||||
it('固定扩展显示独立未读角标,未固定扩展通知聚合至扩展中心且与发送异常 ! 区分显示', async () => {
|
||||
const pinned: PinnedExtensionNavItem[] = [
|
||||
{
|
||||
extensionId: 'com.example.digest',
|
||||
extensionName: 'AI 晨报',
|
||||
label: '晨报',
|
||||
icon: 'digest',
|
||||
pageId: 'main',
|
||||
order: 0,
|
||||
enabled: true
|
||||
}
|
||||
]
|
||||
const summary: ExtensionNotificationSummary = {
|
||||
totalUnread: 5,
|
||||
unpinnedUnread: 3,
|
||||
unreadByExtension: {
|
||||
'com.example.digest': 2,
|
||||
'com.example.other': 3
|
||||
}
|
||||
}
|
||||
|
||||
;(window as unknown as { api?: Record<string, unknown> }).api = {
|
||||
getPersonalWechatSendCapability: vi.fn(async () => ({ ready: false, message: '暂无发送能力' }))
|
||||
}
|
||||
|
||||
const { container } = render(
|
||||
<PrimaryNavigation
|
||||
activePage="archive"
|
||||
onPageChange={vi.fn()}
|
||||
pinnedExtensions={pinned}
|
||||
notificationSummary={summary}
|
||||
/>
|
||||
)
|
||||
|
||||
// 固定扩展角标显示 2。
|
||||
const pinnedBadge = container.querySelector('[data-badge-kind="pinned-unread"]')
|
||||
expect(pinnedBadge?.textContent).toBe('2')
|
||||
|
||||
// 扩展中心同时展示未固定通知聚合角标 (3) 与发送能力异常告警 (!),两者清晰区分。
|
||||
await waitFor(() => {
|
||||
expect(container.querySelector('[data-badge-kind="send-warning"]')?.textContent).toBe('!')
|
||||
})
|
||||
const extensionUnreadBadge = container.querySelector('[data-badge-kind="extension-unread"]')
|
||||
expect(extensionUnreadBadge?.textContent).toBe('3')
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user