fix: 完善聊天解析与导出体验

- 修复引用消息名称和图片布局
- 明确单会话图片测试日志范围
- 支持导出文件附件
- 完善图片批测、会话刷新和安全退出
This commit is contained in:
Wxw-Gu
2026-08-04 12:03:07 +08:00
parent d76727875d
commit c70e49bf16
41 changed files with 2320 additions and 221 deletions
+32 -1
View File
@@ -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()
})
})