review: format check precedes limits, INVALID_IMAGE/IMAGE_TYPE_MISMATCH as format copy, tile-sized retry control
This commit is contained in:
@@ -58,3 +58,12 @@
|
||||
background: var(--dsw-alias-interactive-bg-hover-danger);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* A failed tile keeps the 64px grid cell instead of growing to its copy. */
|
||||
.error[data-variant='tile'] {
|
||||
width: 64px;
|
||||
height: 64px;
|
||||
padding: 4px;
|
||||
overflow: hidden;
|
||||
border-radius: 16px;
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ export function MessageImage({ attachment, load, variant, labels }: {
|
||||
}, [attachment, load, attempt])
|
||||
|
||||
const label = attachment.name ?? labels.image
|
||||
if (error) return <button type="button" className={css.error} onClick={request}>{labels.loadFailed}</button>
|
||||
if (error) return <button type="button" className={css.error} data-variant={variant} onClick={request}>{labels.loadFailed}</button>
|
||||
return (
|
||||
<>
|
||||
<button
|
||||
|
||||
@@ -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 }))
|
||||
|
||||
Reference in New Issue
Block a user