mirror of
https://wget.la/https://github.com/Wxw-Gu/WechatExplorer
synced 2026-08-17 11:37:06 +08:00
fix: 完善聊天解析与导出体验
- 修复引用消息名称和图片布局 - 明确单会话图片测试日志范围 - 支持导出文件附件 - 完善图片批测、会话刷新和安全退出
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import type { WechatDb } from '../../src/main/wechat-db'
|
||||
import { listContactsAsync, setChatDb } from '../../src/main/services/chat-service'
|
||||
import {
|
||||
closeChatDbForQuit,
|
||||
isReady,
|
||||
listContactsAsync,
|
||||
setChatDb
|
||||
} from '../../src/main/services/chat-service'
|
||||
|
||||
describe('chat service contacts', () => {
|
||||
afterEach(() => setChatDb(null))
|
||||
@@ -36,4 +41,30 @@ describe('chat service contacts', () => {
|
||||
})
|
||||
expect(contacts[0]?.m_nsNickName).toBe('测试群聊')
|
||||
})
|
||||
|
||||
it('detaches the database immediately and awaits native cleanup on quit', async () => {
|
||||
let finishClose: ((value: boolean) => void) | undefined
|
||||
const closeAsync = vi.fn(
|
||||
() =>
|
||||
new Promise<boolean>((resolve) => {
|
||||
finishClose = resolve
|
||||
})
|
||||
)
|
||||
const fakeDb = {
|
||||
close: vi.fn(),
|
||||
closeAsync
|
||||
} as unknown as WechatDb
|
||||
|
||||
setChatDb(fakeDb)
|
||||
const closing = closeChatDbForQuit()
|
||||
|
||||
expect(isReady()).toBe(false)
|
||||
expect(closeAsync).toHaveBeenCalledOnce()
|
||||
finishClose?.(true)
|
||||
await expect(closing).resolves.toBe(true)
|
||||
|
||||
const lateDb = { close: vi.fn() } as unknown as WechatDb
|
||||
expect(setChatDb(lateDb)).toBe(false)
|
||||
expect(lateDb.close).toHaveBeenCalledOnce()
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user