mirror of
https://wget.la/https://github.com/Wxw-Gu/WechatExplorer
synced 2026-08-17 11:37:06 +08:00
1. 拆分读取、解析、转写、媒体处理、写入和压缩阶段,完善任务进度展示。 2. 增量导出复用语音资源与转写结果,并为缺失转写补充识别。 3. 稳定远程头像文件名并保留同源头像版本更新。 4. 支持音频附件直接播放、新窗口打开附件,并解码分享标题 XML 实体。 5. 补充导出进度、语音、头像、附件和消息解析回归测试。
77 lines
2.4 KiB
TypeScript
77 lines
2.4 KiB
TypeScript
import { render, screen, waitFor } from '@testing-library/react'
|
|
import userEvent from '@testing-library/user-event'
|
|
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
import { ExportWorkspace } from '../../src/renderer/src/components/export/ExportWorkspace'
|
|
import type { VoiceModelStatus } from '../../src/shared/voice-recognition'
|
|
|
|
const readyStatus: VoiceModelStatus = {
|
|
modelId: 'sensevoice-small-int8',
|
|
version: '2024-07-17',
|
|
state: 'ready',
|
|
downloadedBytes: 239_549_735,
|
|
totalBytes: 239_549_735,
|
|
progress: 1,
|
|
platform: 'win32',
|
|
architecture: 'x64',
|
|
supported: true
|
|
}
|
|
|
|
describe('export voice transcripts', () => {
|
|
beforeEach(() => {
|
|
window.api = {
|
|
getVoiceModelStatus: vi.fn().mockResolvedValue(readyStatus),
|
|
onExportProgress: vi.fn(() => vi.fn())
|
|
} as typeof window.api
|
|
})
|
|
|
|
it('enables voice transcription by default for a ready HTML voice export', async () => {
|
|
const onStartExport = vi.fn().mockResolvedValue({
|
|
success: true,
|
|
messageCount: 1,
|
|
outputPath: 'C:\\fixture\\index.html'
|
|
})
|
|
render(
|
|
<ExportWorkspace
|
|
contacts={[
|
|
{
|
|
m_nsUsrName: 'filehelper',
|
|
m_nsNickName: '文件传输助手',
|
|
md5: 'fixture-contact',
|
|
type: 'user'
|
|
}
|
|
]}
|
|
initialContact={{
|
|
m_nsUsrName: 'filehelper',
|
|
m_nsNickName: '文件传输助手',
|
|
md5: 'fixture-contact',
|
|
type: 'user'
|
|
}}
|
|
selfInfo={null}
|
|
dbReady
|
|
loadPreviewMessages={vi.fn().mockResolvedValue([])}
|
|
onOpenSettings={vi.fn()}
|
|
exportTasks={[]}
|
|
onStartExport={onStartExport}
|
|
onCancelExport={vi.fn()}
|
|
/>
|
|
)
|
|
|
|
await userEvent.click(screen.getAllByRole('button', { name: /HTML/ })[0])
|
|
await userEvent.click(screen.getByRole('checkbox', { name: '语音' }))
|
|
|
|
const transcriptOption = await screen.findByRole('checkbox', {
|
|
name: '语音转文字,显示在语音条下方'
|
|
})
|
|
expect(transcriptOption).toBeEnabled()
|
|
expect(transcriptOption).toBeChecked()
|
|
|
|
await userEvent.click(screen.getByRole('button', { name: '开始导出' }))
|
|
await waitFor(() => expect(onStartExport).toHaveBeenCalledOnce())
|
|
expect(onStartExport.mock.calls[0][0]).toMatchObject({
|
|
format: 'html',
|
|
includeVoiceTranscripts: true,
|
|
kinds: expect.arrayContaining(['voice'])
|
|
})
|
|
})
|
|
})
|