review: format check precedes limits, INVALID_IMAGE/IMAGE_TYPE_MISMATCH as format copy, tile-sized retry control

This commit is contained in:
creatixchu
2026-08-12 13:50:07 +08:00
parent c9a536e0c8
commit 8d4c3f8a0a
7 changed files with 52 additions and 1 deletions
@@ -109,6 +109,13 @@ describe('MessageImage', () => {
expect(frame.getAttribute('style')).toBeNull()
})
it('keeps the tile variant on the failed-load retry control', async () => {
const load = vi.fn().mockRejectedValue(new Error('offline'))
const view = render(<MessageImage attachment={attachment} load={load} variant="tile" labels={labels} />)
const retry = await view.findByRole('button', { name: '图片加载失败,点击重试' })
expect(retry.getAttribute('data-variant')).toBe('tile')
})
it('ignores a load settling after unmount', async () => {
let resolve: ((url: string) => void) | undefined
const load = vi.fn(() => new Promise<string>((r) => { resolve = r }))