Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 45 additions & 13 deletions browser_tests/tests/agent/agentComposerManyAttachments.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
import { expect } from '@playwright/test'

import { agentTest as test } from '@e2e/tests/agent/agentPanelMocks'
import { jsonRoute } from '@e2e/fixtures/utils/jsonRoute'
import { agentTest as test } from '@e2e/tests/agent/agentPanelMocks'

// Regression for https://linear.app/comfyorg/issue/PM-1954
//
// `composer-asset-section` grew without bound inside a panel that is a
// fixed-height `overflow-hidden` column, so attaching dozens of images drove
// the composer taller than the panel and left the action row — and the Send
// button on it — clipped below the panel's bottom edge with nothing scrollable
// to reach it. Enter was then the only way to send, so both halves of the
// report ("can't find Send" and "Enter won't send") are asserted together.
const ATTACHMENT_COUNT = 36

function pngAttachments(count: number) {
return Array.from({ length: count }, (_, index) => ({
name: `attachment-${String(index + 1).padStart(2, '0')}.png`,
mimeType: 'image/png',
buffer: Buffer.from('image')
}))
}

test.describe(
'Agent composer with many attachments',
{ tag: ['@cloud', '@agent', '@ui'] },
Expand All @@ -26,23 +43,38 @@ test.describe(
await agentPanel.selectWorkflow()
await agentPanel.composer.fill('Use these images')

await agentPanel.fileInput.setInputFiles(
Array.from({ length: 36 }, (_, index) => ({
name: `attachment-${String(index + 1).padStart(2, '0')}.png`,
mimeType: 'image/png',
buffer: Buffer.from('image')
}))
)
await expect(agentPanel.attachmentChips).toHaveCount(36)
await expect(agentPanel.sendButton).toBeInViewport({ ratio: 1 })
await agentPanel.fileInput.setInputFiles(pngAttachments(ATTACHMENT_COUNT))
await expect(agentPanel.attachmentChips).toHaveCount(ATTACHMENT_COUNT)

// Enabled proves the uploads settled; in viewport proves the action row
// survived the chips rather than being clipped past the panel.
await expect(agentPanel.sendButton).toBeEnabled()
await expect(agentPanel.sendButton).toBeInViewport({ ratio: 1 })

// Capping the chips' height only helps if the user can still reach the
// ones it pushes out of sight, which a wheel over the section proves and
// an `overflow-hidden` cap would not.
await agentPanel.composerAssetSection.hover()
await page.mouse.wheel(0, 400)
await expect
.poll(() =>
agentPanel.composerAssetSection.evaluate(
(element) => element.scrollTop
)
)
.toBeGreaterThan(0)

await agentPanel.composer.press('Enter')

await expect.poll(() => postedMessages).toHaveLength(1)
expect(JSON.parse(postedMessages[0])).toMatchObject({
content: 'Use these images'
})
const { content, attachments } = JSON.parse(postedMessages[0])
expect(content).toContain('Use these images')
// The backend consumes `attachments`, so capping the chips' height must
// not drop the off-screen ones from either the text or that list.
expect([
...content.matchAll(/@\[Image: (attachment-\d+\.png)\]/g)
]).toHaveLength(ATTACHMENT_COUNT)
expect(attachments).toHaveLength(ATTACHMENT_COUNT)
})
}
)
Loading