mirror of
https://github.com/NanmiCoder/claude-code-haha.git
synced 2026-10-10 03:43:11 +08:00
fix(desktop): compact user message image previews
This commit is contained in:
@@ -306,6 +306,34 @@ describe('AttachmentGallery', () => {
|
||||
expect(view.queryByRole('button', { name: 'Open <h1>' })).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it.each([2, 5])('keeps %i ordinary message images in a bounded thumbnail gallery and opens the selected image', async (imageCount) => {
|
||||
const attachments = Array.from({ length: imageCount }, (_, index) => ({
|
||||
id: `image-${index + 1}`,
|
||||
type: 'image' as const,
|
||||
name: `image-${index + 1}.png`,
|
||||
data: `data:image/svg+xml,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><rect width="16" height="16" fill="hsl(${index * 60} 60% 50%)"/></svg>`)}`,
|
||||
}))
|
||||
const view = render(
|
||||
<AttachmentGallery
|
||||
variant="message"
|
||||
attachments={attachments}
|
||||
/>,
|
||||
)
|
||||
|
||||
const imageButtons = attachments.map(({ name }) =>
|
||||
view.getByRole('button', { name: `Open ${name}` }))
|
||||
const gallery = imageButtons[0]?.parentElement?.parentElement
|
||||
|
||||
expect(gallery).toHaveClass('max-w-full', 'flex-wrap')
|
||||
for (const button of imageButtons) {
|
||||
expect(button.parentElement?.parentElement).toBe(gallery)
|
||||
expect(button.querySelector('img')).toHaveClass('h-28', 'w-28')
|
||||
}
|
||||
|
||||
fireEvent.click(imageButtons[imageCount - 1]!)
|
||||
expect(await view.findByText(`${imageCount} / ${imageCount}`)).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('previews a path-only pasted image instead of a file chip', () => {
|
||||
const path = '/Users/nanmi/Desktop/6代码仓库.png'
|
||||
const view = render(
|
||||
|
||||
@@ -204,7 +204,7 @@ export function AttachmentGallery({ attachments, variant = 'message', onRemove }
|
||||
})}
|
||||
</div>
|
||||
) : (
|
||||
<div className={isComposer ? 'flex flex-wrap items-center gap-2' : 'flex flex-wrap justify-end gap-2'}>
|
||||
<div className={isComposer ? 'flex flex-wrap items-center gap-2' : 'flex max-w-full flex-wrap justify-end gap-2'}>
|
||||
{attachments.map((attachment, index) => {
|
||||
const imageSrc = attachment.type === 'image' ? attachmentImageSource(attachment) : undefined
|
||||
|
||||
@@ -234,7 +234,7 @@ export function AttachmentGallery({ attachments, variant = 'message', onRemove }
|
||||
className={
|
||||
isComposer
|
||||
? 'h-16 w-16 object-cover'
|
||||
: 'max-h-[340px] w-full max-w-[360px] object-cover'
|
||||
: 'h-28 w-28 object-cover'
|
||||
}
|
||||
/>
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user