mirror of
https://wget.la/https://github.com/Wxw-Gu/WechatExplorer
synced 2026-10-03 18:33:14 +08:00
refactor: 重构一下档案搜索功能 支持拼音微信号等
This commit is contained in:
@@ -57,4 +57,35 @@ describe('ConversationSidebar', () => {
|
||||
await userEvent.click(screen.getByRole('button', { name: '公众号 (1)' }))
|
||||
expect(screen.getByText('测试公众号')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('reveals contact results when searching a collapsed contact section', async () => {
|
||||
render(
|
||||
<TooltipProvider>
|
||||
<ConversationSidebar
|
||||
contacts={[
|
||||
{
|
||||
m_nsUsrName: 'wxid_fixture',
|
||||
m_nsNickName: '微信昵称',
|
||||
md5: 'contact-md5',
|
||||
type: 'user',
|
||||
remark: '小号'
|
||||
}
|
||||
]}
|
||||
selectedContact={null}
|
||||
onSelectContact={vi.fn()}
|
||||
onSearch={vi.fn()}
|
||||
onContentFilter={vi.fn()}
|
||||
width={320}
|
||||
selfInfo={null}
|
||||
dbReady
|
||||
onOpenSettings={vi.fn()}
|
||||
onRefresh={vi.fn(async () => undefined)}
|
||||
/>
|
||||
</TooltipProvider>
|
||||
)
|
||||
|
||||
expect(screen.queryByText('微信昵称')).not.toBeInTheDocument()
|
||||
await userEvent.type(screen.getByRole('searchbox', { name: '搜索会话' }), 'xiaohao')
|
||||
expect(screen.getByText('微信昵称')).toBeInTheDocument()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -14,7 +14,7 @@ const contact: Contact = {
|
||||
}
|
||||
|
||||
describe('filterContacts', () => {
|
||||
it.each(['Shinven', '小号', '工作', 'abc123', 'WECHAT_ABC', 'WXID_xxy']) (
|
||||
it.each(['Shinven', '小号', '工作', 'gongzuoshouji', 'gzsj', 'abc123', 'WECHAT_ABC', 'WXID_xxy'])(
|
||||
'matches all contact identity fields with %s',
|
||||
(query) => {
|
||||
expect(filterContacts([contact], ` ${query} `)).toEqual([contact])
|
||||
@@ -26,4 +26,18 @@ describe('filterContacts', () => {
|
||||
expect(filterContacts(list, ' ')).toBe(list)
|
||||
expect(filterContacts(list, 'not-found')).toEqual([])
|
||||
})
|
||||
|
||||
it('matches pinyin when the Chinese name is stored in m_nsNickName', () => {
|
||||
const list = [{ ...contact, remark: '', wechatNickname: '' }]
|
||||
|
||||
expect(filterContacts(list, 'xiaohao')).toEqual(list)
|
||||
expect(filterContacts(list, 'xh')).toEqual(list)
|
||||
})
|
||||
|
||||
it('matches pinyin for a dedicated Chinese remark', () => {
|
||||
const list = [{ ...contact, m_nsNickName: 'Shinven', remark: '小号' }]
|
||||
|
||||
expect(filterContacts(list, 'xiaohao')).toEqual(list)
|
||||
expect(filterContacts(list, 'xh')).toEqual(list)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user