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
5 changes: 2 additions & 3 deletions browser_tests/fixtures/agentCrdtIdCollisionFixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import { HostDoc } from '@e2e/fixtures/agentConversationHostDoc'
import { AgentFollowerHostSocket } from '@e2e/fixtures/agentFollowerHostSocket'
import type { WireOpEnvelope } from '@e2e/fixtures/agentWireFrame'
import { ContextMenu } from '@e2e/fixtures/components/ContextMenu'
import { AgentPanel } from '@e2e/fixtures/components/AgentPanel'
import { Topbar } from '@e2e/fixtures/components/Topbar'
import { VueNodeHelpers } from '@e2e/fixtures/VueNodeHelpers'
import { jsonRoute } from '@e2e/fixtures/utils/jsonRoute'
Expand Down Expand Up @@ -219,9 +220,7 @@ export class IdCollisionHarness {
},
objectInfo: 'server'
})
await this.page
.getByRole('button', { name: enMessages.agent.entryButton })
.click()
await new AgentPanel(this.page).open()
await expect(this.panel).toBeVisible({ timeout: 30_000 })
await this.selectWorkflowTarget()
// `useAgentSession` only binds the CRDT workflow id (which is what makes
Expand Down
12 changes: 11 additions & 1 deletion browser_tests/fixtures/components/AgentPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,17 @@ export class AgentPanel {
}

async open(): Promise<void> {
await this.openButton.click()
for (let attempt = 0; attempt < 2; attempt++) {
if (await this.root.isVisible()) return
await this.openButton.click()
try {
await expect(this.root).toBeVisible({ timeout: 1_000 })
return
} catch {
// Startup activation can open between the visibility read and click,
// making that click close the panel. Retry from the observed state.
}
}
await expect(this.root).toBeVisible()
}

Expand Down
9 changes: 2 additions & 7 deletions browser_tests/fixtures/load3dAgentFixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { expect } from '@playwright/test'

import type { WidgetCatalog, WorkflowJSON } from '@comfyorg/comfy-multi-player'

import enMessages from '@/locales/en/main.json' with { type: 'json' }
import type { ComfyApiWorkflow } from '@/platform/workflow/validation/schemas/workflowSchema'
import {
zComfyApiWorkflow,
Expand All @@ -15,6 +14,7 @@ import load3dWorkflow from '@e2e/assets/3d/load3d_node.json' with { type: 'json'
import { HostDoc } from '@e2e/fixtures/agentConversationHostDoc'
import { AgentFollowerHostSocket } from '@e2e/fixtures/agentFollowerHostSocket'
import { agentTest, bootAgentApp } from '@e2e/fixtures/agentPanelFixture'
import { AgentPanel } from '@e2e/fixtures/components/AgentPanel'
import type { RecordedGraphOperation } from '@e2e/fixtures/data/agent/agentConversation'
import { TestIds } from '@e2e/fixtures/selectors'
import { jsonRoute } from '@e2e/fixtures/utils/jsonRoute'
Expand Down Expand Up @@ -166,12 +166,7 @@ class Load3dAgentHarness {
// The node materializes from the black-box backend's Load3D definition.
objectInfo: 'server'
})
await this.page
.getByRole('button', {
name: enMessages.agent.entryButton,
exact: true
})
.click()
await new AgentPanel(this.page).open()
await expect(this.page.locator('#agent-panel-root')).toBeVisible({
timeout: PANEL_MOUNT_TIMEOUT
})
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 @@ -6,6 +6,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 { jsonRoute } from '@e2e/fixtures/utils/jsonRoute'
import { assetPath } from '@e2e/fixtures/utils/paths'

Expand Down Expand Up @@ -91,9 +92,7 @@ test(
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
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 @@ -21,6 +21,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'
import { loadSeedIntoActiveTab } from '@e2e/fixtures/utils/seedActiveTab'
Expand Down Expand Up @@ -98,7 +99,6 @@ const SEED: WorkflowJSON = {
links: []
}

const OPEN_AGENT_LABEL = enMessages.agent.entryButton
const SEND_LABEL = enMessages.agent.send
const COMPOSER_LABEL = createI18n({
legacy: false,
Expand Down Expand Up @@ -240,7 +240,7 @@ async function driveThroughDocReset(
await loadSeedIntoActiveTab(page, SEED)

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

let savedName: string | undefined
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
8 changes: 2 additions & 6 deletions browser_tests/tests/agent/agentChatRefreshPersistence.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { expect } from '@playwright/test'

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 { TestIds } from '@e2e/fixtures/selectors'

// PM-679: the transcript must survive a browser refresh with its content and
Expand All @@ -21,12 +22,7 @@ test(
await expect(
page.getByTestId('integrated-tab-bar-actions')
).toHaveAttribute('data-agent-gate-settled', 'true', { timeout: 8_000 })
await page
.getByRole('button', {
name: enMessages.agent.entryButton,
exact: true
})
.click()
await new AgentPanel(page).open()
const panel = page.locator('#agent-panel-root')
await expect(panel).toBeVisible()
await page
Expand Down
5 changes: 1 addition & 4 deletions browser_tests/tests/agent/agentComposerPaste.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { expect } from '@playwright/test'

import enMessages from '@/locales/en/main.json' with { type: 'json' }
import type { ComfyWorkflowJSON } from '@/platform/workflow/validation/schemas/workflowSchema'
import type { ComfyNodeDef } from '@/schemas/nodeDefSchema'

Expand Down Expand Up @@ -78,10 +77,8 @@ test(
await canvas.click()
await canvas.press('Control+c')

await page
.getByRole('button', { name: enMessages.agent.entryButton })
.click()
const agentPanel = new AgentPanel(page)
await agentPanel.open()
await expect(agentPanel.root).toBeVisible()

const composer = agentPanel.composer
Expand Down
Loading
Loading