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,59 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { fireEvent, render, screen } from '@testing-library/react'
|
||||
import { PrimaryNavigation } from '../../src/renderer/src/components/layout/PrimaryNavigation'
|
||||
import type { PinnedExtensionNavItem } from '../../src/shared/extensions/types'
|
||||
|
||||
describe('PrimaryNavigation 动态固定扩展入口', () => {
|
||||
it('在「设置」上方按顺序渲染已固定扩展,点击后触发打开扩展回调', () => {
|
||||
const onPageChange = vi.fn()
|
||||
const onOpenPinnedExtension = vi.fn()
|
||||
const pinned: PinnedExtensionNavItem[] = [
|
||||
{
|
||||
extensionId: 'com.example.digest',
|
||||
extensionName: 'AI 晨报',
|
||||
label: '晨报',
|
||||
icon: 'digest',
|
||||
pageId: 'main',
|
||||
order: 0,
|
||||
enabled: true
|
||||
},
|
||||
{
|
||||
extensionId: 'com.example.group-chat-bot',
|
||||
extensionName: '群聊机器人',
|
||||
label: '机器人',
|
||||
icon: 'bot',
|
||||
pageId: 'main',
|
||||
order: 1,
|
||||
enabled: true
|
||||
}
|
||||
]
|
||||
|
||||
const { container } = render(
|
||||
<PrimaryNavigation
|
||||
activePage="archive"
|
||||
onPageChange={onPageChange}
|
||||
pinnedExtensions={pinned}
|
||||
activePinnedExtensionId="com.example.digest"
|
||||
onOpenPinnedExtension={onOpenPinnedExtension}
|
||||
/>
|
||||
)
|
||||
|
||||
const buttons = Array.from(container.querySelectorAll('button.primary-nav-item'))
|
||||
const labels = buttons.map((btn) => btn.textContent?.trim())
|
||||
const digestIndex = labels.indexOf('晨报')
|
||||
const botIndex = labels.indexOf('机器人')
|
||||
const settingsIndex = labels.indexOf('设置')
|
||||
|
||||
expect(digestIndex).toBeGreaterThan(-1)
|
||||
expect(botIndex).toBe(digestIndex + 1)
|
||||
expect(settingsIndex).toBeGreaterThan(botIndex)
|
||||
|
||||
// 当前打开的固定扩展高亮,且「档案」不再高亮。
|
||||
expect(buttons[digestIndex].className).toContain('active')
|
||||
expect(buttons[0].className).not.toContain('active')
|
||||
|
||||
fireEvent.click(screen.getByText('机器人'))
|
||||
expect(onOpenPinnedExtension).toHaveBeenCalledWith(pinned[1])
|
||||
expect(onPageChange).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user