Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix playwright tests
  • Loading branch information
huchenlei committed Aug 8, 2025
commit c5d630167192de1663c06eceff2e3df715c36085
92 changes: 64 additions & 28 deletions browser_tests/fixtures/ComfyPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1035,12 +1035,40 @@ export class ComfyPage {
}

const input = inputsToTry[0]
if (!input.pos) {
throw new Error('Input slot position not found')
if (!input.boundingRect) {
throw new Error('Input slot bounding rect not found')
}

const testX = input.pos[0]
const testY = input.pos[1]
// Use center of bounding rect for reliable clicking
const rect = input.boundingRect
const testX = rect[0] + rect[2] / 2 // x + width/2
const testY = rect[1] + rect[3] / 2 // y + height/2

// Simulate double-click directly through pointer events
const leftClickEvent = {
canvasX: testX,
canvasY: testY,
button: 0, // Left mouse button
preventDefault: () => {},
stopPropagation: () => {}
}

// Trigger the input node's pointer down handler
if (inputNode.onPointerDown) {
inputNode.onPointerDown(
leftClickEvent,
app.canvas.pointer,
app.canvas.linkConnector
)

// Trigger double-click if pointer has the handler
if (app.canvas.pointer.onDoubleClick) {
app.canvas.pointer.onDoubleClick(leftClickEvent)
}
}

// Wait briefly for dialog to appear
await new Promise((resolve) => setTimeout(resolve, 200))

return { success: true, inputName: input.name, x: testX, y: testY }
}, inputName)
Expand All @@ -1053,17 +1081,7 @@ export class ComfyPage {
)
}

// Perform the actual double-click at the slot position
await this.canvas.dblclick({
position: { x: foundSlot.x, y: foundSlot.y }
})
await this.nextFrame()

// Wait for the rename dialog to appear
await this.page.waitForSelector('.graphdialog input', {
state: 'visible',
timeout: 5000
})
}

/**
Expand Down Expand Up @@ -1112,12 +1130,40 @@ export class ComfyPage {
}

const output = outputsToTry[0]
if (!output.pos) {
throw new Error('Output slot position not found')
if (!output.boundingRect) {
throw new Error('Output slot bounding rect not found')
}

const testX = output.pos[0]
const testY = output.pos[1]
// Use center of bounding rect for reliable clicking
const rect = output.boundingRect
const testX = rect[0] + rect[2] / 2 // x + width/2
const testY = rect[1] + rect[3] / 2 // y + height/2

// Simulate double-click directly through pointer events
const leftClickEvent = {
canvasX: testX,
canvasY: testY,
button: 0, // Left mouse button
preventDefault: () => {},
stopPropagation: () => {}
}

// Trigger the output node's pointer down handler
if (outputNode.onPointerDown) {
outputNode.onPointerDown(
leftClickEvent,
app.canvas.pointer,
app.canvas.linkConnector
)

// Trigger double-click if pointer has the handler
if (app.canvas.pointer.onDoubleClick) {
app.canvas.pointer.onDoubleClick(leftClickEvent)
}
}

// Wait briefly for dialog to appear
await new Promise((resolve) => setTimeout(resolve, 200))

return { success: true, outputName: output.name, x: testX, y: testY }
}, outputName)
Expand All @@ -1130,17 +1176,7 @@ export class ComfyPage {
)
}

// Perform the actual double-click at the slot position
await this.canvas.dblclick({
position: { x: foundSlot.x, y: foundSlot.y }
})
await this.nextFrame()

// Wait for the rename dialog to appear
await this.page.waitForSelector('.graphdialog input', {
state: 'visible',
timeout: 5000
})
}

/**
Expand Down
50 changes: 36 additions & 14 deletions browser_tests/tests/subgraph.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,23 +271,45 @@ test.describe('Subgraph Operations', () => {
return graph.inputs?.[0]?.label || null
})

// Get the label position (not the connector position) and double-click there
const labelPosition = await comfyPage.page.evaluate(() => {
const graph = window['app'].canvas.graph
// Use direct pointer event approach to double-click on label
await comfyPage.page.evaluate(() => {
const app = window['app']
const graph = app.canvas.graph
const input = graph.inputs?.[0]
if (!input?.labelPos) return null
// labelPos gives us the text label position, which should be different from pos (connector position)
return { x: input.labelPos[0], y: input.labelPos[1] }
})

if (!labelPosition) {
throw new Error('Could not get label position for testing')
}

// Double-click on the label text specifically
await comfyPage.canvas.dblclick({
position: labelPosition
if (!input?.labelPos) {
throw new Error('Could not get label position for testing')
}

// Use labelPos for more precise clicking on the text
const testX = input.labelPos[0]
const testY = input.labelPos[1]

const leftClickEvent = {
canvasX: testX,
canvasY: testY,
button: 0, // Left mouse button
preventDefault: () => {},
stopPropagation: () => {}
}

const inputNode = graph.inputNode
if (inputNode?.onPointerDown) {
inputNode.onPointerDown(
leftClickEvent,
app.canvas.pointer,
app.canvas.linkConnector
)

// Trigger double-click if pointer has the handler
if (app.canvas.pointer.onDoubleClick) {
app.canvas.pointer.onDoubleClick(leftClickEvent)
}
}
})

// Wait for dialog to appear
await comfyPage.page.waitForTimeout(200)
await comfyPage.nextFrame()

await comfyPage.page.waitForSelector(SELECTORS.promptDialog, {
Expand Down