Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 2 additions & 4 deletions browser_tests/fixtures/agentConversationFixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
import type { HostFrame } from '@e2e/fixtures/agentConversationHostDoc'
import { HostDoc } from '@e2e/fixtures/agentConversationHostDoc'
import { AgentFollowerHostSocket } from '@e2e/fixtures/agentFollowerHostSocket'
import { AgentPanel } from '@e2e/fixtures/components/AgentPanel'
import type {
ClientDocFrame,
HumanOpsHost
Expand Down Expand Up @@ -61,7 +62,6 @@ const VUE_NODES_TAG = '@vue-nodes'
const PANEL_MOUNT_TIMEOUT = 30_000
const CANCEL_TIMEOUT = 10_000

const OPEN_AGENT_LABEL = enMessages.agent.entryButton
const SEND_LABEL = enMessages.agent.send
const STOP_LABEL = enMessages.agent.stop
// The composer names itself with the rendered message, escapes resolved; the
Expand Down Expand Up @@ -319,9 +319,7 @@ export class AgentConversationHarness {
`${this.page.url()} serves no node definitions for ${unregistered.join(', ')}; the replay needs a ComfyUI backend behind the dev server (browser_tests/README.md, "Replay coverage for agent bug fixes")`
)

await this.page
.getByRole('button', { name: OPEN_AGENT_LABEL, exact: true })
.click()
await new AgentPanel(this.page).open()
await expect(this.panel).toBeVisible({ timeout: PANEL_MOUNT_TIMEOUT })
await this.selectWorkflowTarget()
}
Expand Down
13 changes: 12 additions & 1 deletion browser_tests/fixtures/components/AgentPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,18 @@ export class AgentPanel {
}

async open(): Promise<void> {
await this.openButton.click()
for (let attempt = 0; attempt < 2; attempt++) {
if (await this.root.isVisible()) return
try {
await this.openButton.click({ timeout: 1_000 })
await expect(this.root).toBeVisible({ timeout: 1_000 })
return
} catch {
// Startup activation can open between the visibility read and click.
// The click can then either close the panel or briefly match both the
// entry and panel controls. Retry from the newly observed state.
}
}
await expect(this.root).toBeVisible()
}

Expand Down
11 changes: 4 additions & 7 deletions browser_tests/fixtures/minimaxAutogrowFixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import type {

import { HostDoc } from '@e2e/fixtures/agentConversationHostDoc'
import { agentTest, bootAgentApp } from '@e2e/fixtures/agentPanelFixture'
import { AgentPanel } from '@e2e/fixtures/components/AgentPanel'
import { isValidDocOpsBatch, parseWireOps } from '@e2e/fixtures/agentWireFrame'
import {
referenceCatalog,
Expand Down Expand Up @@ -145,13 +146,9 @@ export const minimaxAutogrowTest = agentTest.extend<{
return route.fulfill(jsonRoute(response))
})

await page
.getByRole('button', {
name: enMessages.agent.entryButton,
exact: true
})
.click()
const panel = page.locator('#agent-panel-root')
const agentPanel = new AgentPanel(page)
await agentPanel.open()
const panel = agentPanel.root
await expect(panel).toBeVisible()
await panel
.getByRole('button', { name: enMessages.agent.switchWorkflow })
Expand Down
138 changes: 138 additions & 0 deletions browser_tests/tests/agent/agentActivationConsent.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
import { expect } from '@playwright/test'

import enMessages from '@/locales/en/main.json' with { type: 'json' }

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

test.describe(
'Agent activation consent boundary',
{ tag: ['@cloud', '@ui'] },
() => {
test.use({
agentConsentAccepted: false,
initialLocalStorage: {
'Comfy.AgentConsent.AutoShown.test-user-e2e.ws-personal': 'true'
}
})

test('opens before consent and resumes the held first send exactly once', async ({
agentConsentSave,
agentConsentWrites,
agentPanel,
comfyPage,
postedMessages
}) => {
await expect(agentPanel.root).toBeVisible()
await expect(agentPanel.openButton).toHaveAttribute(
'aria-pressed',
'true'
)

await agentPanel.selectWorkflow()
await agentPanel.composer.fill('Build a product photo workflow')
await agentPanel.sendButton.click()

const dialog = comfyPage.page.getByRole('dialog', {
name: enMessages.agent.consent.title
})
await expect(dialog).toBeVisible()
expect(postedMessages).toHaveLength(0)

let releaseConsentSave = () => {}
agentConsentSave.pending = new Promise<void>((resolve) => {
releaseConsentSave = resolve
})
await dialog
.getByRole('button', { name: enMessages.agent.consent.accept })
.click()

await expect.poll(() => agentConsentWrites).toEqual([true])
expect(postedMessages).toHaveLength(0)
releaseConsentSave()

await expect(dialog).toHaveCount(0)
await expect(agentPanel.composer).toHaveText('')
await expect.poll(() => postedMessages).toHaveLength(1)
})

test('keeps a cancelled held draft unsent and lets the user retry', async ({
agentPanel,
comfyPage,
postedMessages
}) => {
const page = comfyPage.page
await agentPanel.selectWorkflow()
await agentPanel.composer.fill('Build a product photo workflow')
await agentPanel.sendButton.click()

const dialog = page.getByRole('dialog', {
name: enMessages.agent.consent.title
})
await expect(dialog).toBeVisible()
await page.keyboard.press('Escape')

await expect(dialog).toHaveCount(0)
expect(postedMessages).toHaveLength(0)
await expect(agentPanel.composer).toHaveText(
'Build a product photo workflow'
)

await agentPanel.sendButton.click()
await expect(dialog).toBeVisible()
await dialog
.getByRole('button', { name: enMessages.agent.consent.accept })
.click()
await expect.poll(() => postedMessages).toHaveLength(1)
})
}
)

test.describe(
'Agent activation with existing consent',
{ tag: ['@cloud', '@ui'] },
() => {
test.use({ agentConsentAccepted: true })

test('opens on activation and sends without another consent prompt', async ({
agentPanel,
comfyPage,
postedMessages
}) => {
await expect(agentPanel.root).toBeVisible()
await agentPanel.selectWorkflow()
await agentPanel.composer.fill('Build a product photo workflow')
await agentPanel.sendButton.click()

await expect(
comfyPage.page.getByRole('dialog', {
name: enMessages.agent.consent.title
})
).toHaveCount(0)
await expect.poll(() => postedMessages).toHaveLength(1)
})
}
)

test.describe(
'Agent activation with a persisted open preference',
{ tag: ['@cloud', '@ui'] },
() => {
test.use({
agentConsentAccepted: false,
agentPanelInitiallyOpen: true,
initialLocalStorage: {
'Comfy.AgentConsent.AutoShown.test-user-e2e.ws-personal': 'true'
}
})

test('keeps the restored panel visible before consent', async ({
agentPanel
}) => {
await expect(agentPanel.root).toBeVisible()
await expect(agentPanel.openButton).toHaveAttribute(
'aria-pressed',
'true'
)
})
}
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { AgentMessage } from '@comfyorg/ingest-types'
import enMessages from '@/locales/en/main.json' with { type: 'json' }

import { promptHistoryTest as test } from '@e2e/fixtures/agentPromptHistoryFixture'
import { AgentPanel } from '@e2e/fixtures/components/AgentPanel'
import {
dropAssets,
expectAssets
Expand Down Expand Up @@ -167,12 +168,7 @@ for (const scenario of [
return route.fulfill(jsonRoute(messages))
})

await page
.getByRole('button', {
name: enMessages.agent.entryButton,
exact: true
})
.click()
await new AgentPanel(page).open()
await page
.getByRole('button', {
name: enMessages.sideToolbar.newBlankWorkflow,
Expand Down
2 changes: 1 addition & 1 deletion browser_tests/tests/agent/agentAttachmentUpload.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ test.describe('Agent attachment cancellation', { tag: '@cloud' }, () => {
name: enMessages.agent.entryButton,
exact: true
})
await openButton.click()
await agentPanel.open()
await agentPanel.selectWorkflow()
const panel = page.locator('#agent-panel-root')
const composer = panel.getByRole('textbox', { name: /^Describe ideas/ })
Expand Down
18 changes: 5 additions & 13 deletions browser_tests/tests/agent/agentAutogrowTabSwitchReconcile.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
} from '@e2e/fixtures/agentPanelFixture'
import { HostDoc } from '@e2e/fixtures/agentConversationHostDoc'
import { Topbar } from '@e2e/fixtures/components/Topbar'
import { AgentPanel } from '@e2e/fixtures/components/AgentPanel'
import { VueNodeHelpers } from '@e2e/fixtures/VueNodeHelpers'
import { TestIds } from '@e2e/fixtures/selectors'
import { jsonRoute } from '@e2e/fixtures/utils/jsonRoute'
Expand Down Expand Up @@ -381,15 +382,11 @@ test.describe(
'[aria-invalid="true"]'
)

const panel = page.locator('#agent-panel-root')
const agentPanel = new AgentPanel(page)
const panel = agentPanel.root

await test.step('open the agent panel and target the workflow', async () => {
await page
.getByRole('button', {
name: enMessages.agent.entryButton,
exact: true
})
.click()
await agentPanel.open()
await expect(panel).toBeVisible()
await panel
.getByRole('button', { name: enMessages.agent.switchWorkflow })
Expand Down Expand Up @@ -498,12 +495,7 @@ test.describe(
// the CRDT follower and its mint ports. Reopen it before exercising a
// local edit, and prove the replacement follower has rebound this doc.
subscribedTo = null
await page
.getByRole('button', {
name: enMessages.agent.entryButton,
exact: true
})
.click()
await agentPanel.open()
await expect(panel).toBeVisible()
await expect
.poll(() => subscribedTo, { timeout: 20_000 })
Expand Down
5 changes: 2 additions & 3 deletions browser_tests/tests/agent/agentBatchOutputAttachment.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import enMessages from '@/locales/en/main.json' with { type: 'json' }
import { MIME_ASSET_INFO } from '@/platform/assets/schemas/mediaAssetSchema'

import { promptHistoryTest as test } from '@e2e/fixtures/agentPromptHistoryFixture'
import { AgentPanel } from '@e2e/fixtures/components/AgentPanel'
import { assetPath } from '@e2e/fixtures/utils/paths'

test.use({ connectWebSocketToServer: false })
Expand Down Expand Up @@ -38,9 +39,7 @@ test(
(route) => route.fulfill({ path: assetPath('image64x64.webp') })
)

await page
.getByRole('button', { name: enMessages.agent.entryButton })
.click()
await new AgentPanel(page).open()
await page
.getByRole('button', {
name: enMessages.sideToolbar.newBlankWorkflow,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
} from '@e2e/fixtures/agentPanelFixture'
import { HostDoc } from '@e2e/fixtures/agentConversationHostDoc'
import type { HostFrame } from '@e2e/fixtures/agentConversationHostDoc'
import { AgentPanel } from '@e2e/fixtures/components/AgentPanel'
import { VueNodeHelpers } from '@e2e/fixtures/VueNodeHelpers'
import { jsonRoute } from '@e2e/fixtures/utils/jsonRoute'

Expand Down Expand Up @@ -91,7 +92,6 @@ const CATALOG: WidgetCatalog = {
}
const SEED: WorkflowJSON = { nodes: [], links: [] }

const OPEN_AGENT_LABEL = enMessages.agent.entryButton
const SEND_LABEL = enMessages.agent.send
const COMPOSER_LABEL = createI18n({
legacy: false,
Expand Down Expand Up @@ -200,9 +200,7 @@ async function driveThroughToolCallDone(
})

const panel = page.locator('#agent-panel-root')
await page
.getByRole('button', { name: OPEN_AGENT_LABEL, exact: true })
.click()
await new AgentPanel(page).open()
await expect(panel).toBeVisible({ timeout: 30_000 })

let savedName: string | undefined
Expand Down
Loading
Loading