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
Binary file added browser_tests/assets/silence.wav
Binary file not shown.
9 changes: 9 additions & 0 deletions browser_tests/fixtures/VueNodeHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,15 @@ export class VueNodeHelpers {
await this.deleteSelected()
}

/** Rename a node through the canvas title editor. */
async renameNode(nodeId: string, newTitle: string): Promise<void> {
const title = this.getNodeLocator(nodeId).getByTestId('node-title')
await title.dblclick({ delay: 5 })
const input = title.getByTestId('node-title-input')
await input.fill(newTitle)
await input.press('Enter')
}

/**
* Delete selected Vue nodes using Backspace key
*/
Expand Down
22 changes: 22 additions & 0 deletions browser_tests/fixtures/agentPanelFixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type {

import type { RemoteConfig } from '@/platform/remoteConfig/types'
import type { UserDataFullInfo } from '@/platform/remote/comfyui/types'
import type { ComfyWorkflowJSON } from '@/platform/workflow/validation/schemas/workflowSchema'
import { AGENT_CONSENT_SETTING_ID } from '@/platform/settings/constants/agent'
import type { ComfyNodeDef } from '@/schemas/nodeDefSchema'
import type { AgentTurnAccepted } from '@/workbench/extensions/agent/schemas/agentApiSchema'
Expand All @@ -18,6 +19,8 @@ import { cloudAppFixture, waitForCloudApp } from '@e2e/fixtures/cloudAppFixture'
import { mockBilling } from '@e2e/fixtures/utils/cloudBillingMocks'
import { bootCloud, mockCloudBoot } from '@e2e/fixtures/utils/cloudBootMocks'
import { jsonRoute } from '@e2e/fixtures/utils/jsonRoute'
import { nextFrame } from '@e2e/fixtures/utils/timing'
import type { WorkspaceStore } from '@e2e/types/globals'

const APP_URL = process.env.PLAYWRIGHT_TEST_URL || 'http://localhost:8188'

Expand Down Expand Up @@ -198,3 +201,22 @@ export async function bootAgentApp(
await page.goto(APP_URL)
await waitForCloudApp(page)
}

/** Replace the boot tab's graph while retaining its active workflow identity. */
export async function loadIntoBootWorkflow(
page: Page,
json: ComfyWorkflowJSON
): Promise<void> {
await page.waitForFunction(() => {
const workspace = window.app?.extensionManager as WorkspaceStore | undefined
return workspace?.workflow.activeWorkflow != null
})
await page.evaluate(async (json) => {
const activeWorkflow = (window.app!.extensionManager as WorkspaceStore)
.workflow.activeWorkflow!
await window.app!.loadGraphData(json, true, true, activeWorkflow)
if (json.nodes.length > 0)
await window.app!.extensionManager.command.execute('Comfy.Canvas.FitView')
}, json)
await nextFrame(page)
}
62 changes: 60 additions & 2 deletions browser_tests/fixtures/components/AgentPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export class AgentPanel {
public readonly workflowPicker: Locator
public readonly fileInput: Locator
public readonly composerAssetSection: Locator
public readonly scrollAssetsRight: Locator
public readonly attachmentChips: Locator
public readonly composer: Locator
public readonly composerPromptArea: Locator
Expand Down Expand Up @@ -55,6 +56,9 @@ export class AgentPanel {
})
this.fileInput = this.root.getByTestId('agent-file-input')
this.composerAssetSection = this.root.getByTestId('composer-asset-section')
this.scrollAssetsRight = this.root.getByRole('button', {
name: enMessages.g.scrollRight
})
this.attachmentChips = this.root.getByTestId('agent-attachment-chip')
this.composer = this.root.getByRole('textbox', { name: /^Describe ideas/ })
this.composerPromptArea = this.root.getByTestId('composer-inline-input')
Expand All @@ -63,9 +67,63 @@ export class AgentPanel {
})
}

async scrollAssetsToEnd(): Promise<void> {
const count = await this.attachmentChips.count()
for (
let step = 0;
step < count && (await this.scrollAssetsRight.isEnabled());
step++
) {
const target = await this.composerAssetSection.evaluate((element) =>
Math.min(
element.scrollWidth - element.clientWidth,
element.scrollLeft + element.clientWidth
)
)
await this.scrollAssetsRight.click()
await expect
.poll(() =>
this.composerAssetSection.evaluate((element) => element.scrollLeft)
)
.toBeCloseTo(target, 0)
}
await expect(this.scrollAssetsRight).toBeDisabled()
}

assetPreview(name: string): Locator {
return this.page.getByRole('dialog', { name, exact: true })
}

previewAssetButton(name: string): Locator {
return this.attachmentChip(name).getByRole('button', {
name: enMessages.agent.previewAsset.replace('{name}', name),
exact: true
})
}

async expectAttachmentFullyVisible(name: string): Promise<void> {
const tray = this.root.getByRole('region', {
name: enMessages.assetBrowser.assets,
exact: true
})
await expect
.poll(async () => {
const [card, viewport] = await Promise.all([
this.attachmentChip(name).boundingBox(),
tray.boundingBox()
])
return (
!!card &&
!!viewport &&
card.y >= viewport.y &&
card.y + card.height <= viewport.y + viewport.height
)
})
.toBe(true)
}

/**
* The composer attachment carrying `name`. Matches on the chip's own
* attribute rather than its text, which truncates at `max-w-32`.
* The composer attachment carrying `name`.
*
* `name` is a filename and may legitimately contain a quote or backslash, so
* it is escaped for the double-quoted CSS string rather than interpolated
Expand Down
11 changes: 11 additions & 0 deletions browser_tests/fixtures/data/assetFixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,17 @@ export const AGENT_VIDEO_ASSET: Asset = createOutputAsset({
last_access_time: '2026-09-18T00:00:00.000Z'
})

export const AGENT_AUDIO_ASSET: Asset = createOutputAsset({
id: '33333333-3333-4333-a333-333333333333',
hash: 'blake3:3333333333333333333333333333333333333333333333333333333333333333',
name: 'agent_generated_audio.wav',
mime_type: 'audio/wav',
size: 24_044,
created_at: '2026-09-18T00:00:00.000Z',
updated_at: '2026-09-18T00:00:00.000Z',
last_access_time: '2026-09-18T00:00:00.000Z'
})

export const STALE_TEMP_FILENAME = 'ComfyUI_temp_thsmm_00001_.png'
export const STALE_TEMP_CARD_TEXT = STALE_TEMP_FILENAME.replace(/\.[^.]+$/, '')
export const STALE_TEMP_ASSET: Asset = createOutputAsset({
Expand Down
26 changes: 24 additions & 2 deletions browser_tests/fixtures/helpers/DragDropHelper.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { readFileSync } from 'fs'
import { readFileSync, statSync } from 'fs'
import { basename } from 'path'

import type { Page } from '@playwright/test'
import type { Locator, Page } from '@playwright/test'

import type { Position } from '@e2e/fixtures/types'
import { getMimeType } from '@e2e/fixtures/utils/mimeTypeUtil'
Expand All @@ -11,6 +11,28 @@ import { nextFrame } from '@e2e/fixtures/utils/timing'
export class DragDropHelper {
constructor(private readonly page: Page) {}

async dropFilesOn(target: Locator, filePaths: string[]): Promise<void> {
const files = filePaths.map((filePath) => ({
bytes: Array.from(readFileSync(filePath)),
name: basename(filePath),
type: getMimeType(basename(filePath)),
lastModified: statSync(filePath).mtimeMs
}))
const transfer = await this.page.evaluateHandle((files) => {
const transfer = new DataTransfer()
for (const { bytes, name, type, lastModified } of files)
transfer.items.add(
new File([new Uint8Array(bytes)], name, { type, lastModified })
)
return transfer
}, files)
try {
await target.dispatchEvent('drop', { dataTransfer: transfer })
} finally {
await transfer.dispose()
}
}

async dragAndDropExternalResource(
options: {
fileName?: string
Expand Down
107 changes: 107 additions & 0 deletions browser_tests/tests/agent/agentAssetPreviewPlayback.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import assert from 'node:assert/strict'

import { expect } from '@playwright/test'

import {
agentTest as test,
bootAgentApp
} from '@e2e/fixtures/agentPanelFixture'
import { AgentPanel } from '@e2e/fixtures/components/AgentPanel'
import { AssetsSidebarTab } from '@e2e/fixtures/components/SidebarTab'
import {
AGENT_AUDIO_ASSET,
AGENT_VIDEO_ASSET
} from '@e2e/fixtures/data/assetFixtures'
import { assetPath } from '@e2e/fixtures/utils/paths'

test.describe('Asset preview playback', { tag: '@cloud' }, () => {
for (const { kind, asset, file, contentType } of [
{
kind: 'video',
asset: AGENT_VIDEO_ASSET,
file: 'plain_video.mp4',
contentType: 'video/mp4'
},
{
kind: 'audio',
asset: AGENT_AUDIO_ASSET,
file: 'silence.wav',
contentType: 'audio/wav'
}
] as const) {
test(`stops ${kind} at close and reopens paused during the exit animation`, async ({
page,
agentFlagEnabled
}) => {
await page.route(`**/api/assets/${asset.id}/content**`, (route) =>
route.fulfill({ path: assetPath(file), contentType })
)
await bootAgentApp(page, agentFlagEnabled, {
assets: { assets: [asset], total: 1, has_more: false }
})
const panel = new AgentPanel(page)
await panel.open()
const assets = new AssetsSidebarTab(page)
await assets.open()
await assets.assetCards.first().dragTo(panel.root)
await panel.composer.fill('Keep this draft')
const trigger = panel.previewAssetButton(asset.name)
await trigger.press('Enter')
const player = panel.assetPreview(asset.name).locator(kind)
await expect(player).toBeFocused()
await expect
.poll(() =>
player.evaluate((media: HTMLMediaElement) => media.readyState)
)
.toBeGreaterThanOrEqual(2)
await player.press('Space')
await expect
.poll(() => player.evaluate((media: HTMLMediaElement) => media.paused))
.toBe(false)
const playingElement = await player.elementHandle()
assert(playingElement)
try {
await page.keyboard.press('Escape')
expect(
await playingElement.evaluate(
(media) => media instanceof HTMLMediaElement && media.paused
)
).toBe(true)
await page.keyboard.press('Enter')
await expect(trigger).toHaveAttribute('aria-expanded', 'true')
await expect(player).toBeFocused()
await expect
.poll(() =>
player.evaluate(
(media: HTMLMediaElement) =>
media.paused && media.currentTime === 0
)
)
.toBe(true)
await player.press('Space')
await expect
.poll(() =>
player.evaluate((media: HTMLMediaElement) => media.paused)
)
.toBe(false)
const reopenedElement = await player.elementHandle()
assert(reopenedElement)
try {
await panel.composer.click()
expect(
await reopenedElement.evaluate(
(media) => media instanceof HTMLMediaElement && media.paused
)
).toBe(true)
} finally {
await reopenedElement.dispose()
}
await expect(trigger).toHaveAttribute('aria-expanded', 'false')
await expect(panel.composer).toBeFocused()
await expect(panel.composer).toContainText('Keep this draft')
} finally {
await playingElement.dispose()
}
})
}
})
Loading
Loading