feat: mac 档案与导出支持加载原图原视频

This commit is contained in:
Wxw-Gu committed 2026-12-01 10:40:58 +08:00
1 parent fccca5b459
commit b20e514c90
31 files changed
+1884 -111

No files matched your search

@@ -70,4 +70,62 @@ describe('ChatImageViewer', () => {
await waitFor(() => expect(opener).toHaveFocus())
expect(onClose).toHaveBeenCalledTimes(2)
})
it('loads the original image from the top toolbar and updates the displayed src', async () => {
const user = userEvent.setup()
const hdUrl = `${imageUrl}#hd`
const onDownloadOriginal = vi.fn().mockResolvedValue({ success: true, data: hdUrl })
const onImageChange = vi.fn()
render(
<TooltipProvider>
<ChatImageViewer
imageUrl={imageUrl}
onDownloadOriginal={onDownloadOriginal}
onImageChange={onImageChange}
onClose={vi.fn()}
/>
</TooltipProvider>
)
const loadButton = screen.getByRole('button', { name: '加载原图' })
await user.click(loadButton)
await waitFor(() => expect(onDownloadOriginal).toHaveBeenCalledTimes(1))
expect(screen.getByAltText('图片预览')).toHaveAttribute('src', hdUrl)
expect(onImageChange).toHaveBeenCalledWith(hdUrl)
expect(screen.getByRole('button', { name: '已加载原图' })).toBeVisible()
})
it('surfaces an inline error when loading the original image fails', async () => {
const user = userEvent.setup()
const onDownloadOriginal = vi.fn().mockResolvedValue({
success: false,
error: '图片已在微信服务器过期'
})
render(
<TooltipProvider>
<ChatImageViewer
imageUrl={imageUrl}
onDownloadOriginal={onDownloadOriginal}
onClose={vi.fn()}
/>
</TooltipProvider>
)
await user.click(screen.getByRole('button', { name: '加载原图' }))
expect(await screen.findByRole('alert')).toHaveTextContent('图片已在微信服务器过期')
expect(screen.getByAltText('图片预览')).toHaveAttribute('src', imageUrl)
})
it('hides the load-original button when send/runtime capability is unavailable', () => {
render(
<TooltipProvider>
<ChatImageViewer imageUrl={imageUrl} onClose={vi.fn()} />
</TooltipProvider>
)
expect(screen.queryByRole('button', { name: '加载原图' })).not.toBeInTheDocument()
})
})