mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-30 11:11:53 +00:00
test: replace hardcoded positions with computed NodeReference positions
- nodeSearchBox.spec.ts: Use NodeReference.getOutput() for CLIP output slot position - rightClickMenu.spec.ts: Use NodeReference.getTitlePosition() for node dragging - Add getTitlePosition() helper to NodeReference for drag operations Amp-Thread-ID: https://ampcode.com/threads/T-019c1367-6a59-7752-9329-17cbf152fc62 Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -312,6 +312,11 @@ export class NodeReference {
|
|||||||
async getFlags(): Promise<{ collapsed?: boolean; pinned?: boolean }> {
|
async getFlags(): Promise<{ collapsed?: boolean; pinned?: boolean }> {
|
||||||
return await this.getProperty('flags')
|
return await this.getProperty('flags')
|
||||||
}
|
}
|
||||||
|
async getTitlePosition(): Promise<Position> {
|
||||||
|
const nodePos = await this.getPosition()
|
||||||
|
const nodeSize = await this.getSize()
|
||||||
|
return { x: nodePos.x + nodeSize.width / 2, y: nodePos.y - 15 }
|
||||||
|
}
|
||||||
async isPinned() {
|
async isPinned() {
|
||||||
return !!(await this.getFlags()).pinned
|
return !!(await this.getFlags()).pinned
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,16 +68,16 @@ test.describe('Node search box', { tag: '@node' }, () => {
|
|||||||
async ({ comfyPage }) => {
|
async ({ comfyPage }) => {
|
||||||
await comfyPage.loadWorkflow('links/batch_move_links')
|
await comfyPage.loadWorkflow('links/batch_move_links')
|
||||||
|
|
||||||
const outputSlot1Pos = {
|
// Get the CLIP output slot (index 1) from the first CheckpointLoaderSimple node (id: 4)
|
||||||
x: 304,
|
const checkpointNode = await comfyPage.nodeOps.getNodeRefById(4)
|
||||||
y: 127
|
const clipOutputSlot = await checkpointNode.getOutput(1)
|
||||||
}
|
const outputSlotPos = await clipOutputSlot.getPosition()
|
||||||
const emptySpacePos = {
|
|
||||||
x: 5,
|
// Use a position in the empty canvas area (top-left corner)
|
||||||
y: 5
|
const emptySpacePos = { x: 5, y: 5 }
|
||||||
}
|
|
||||||
await comfyPage.page.keyboard.down('Shift')
|
await comfyPage.page.keyboard.down('Shift')
|
||||||
await comfyPage.canvasOps.dragAndDrop(outputSlot1Pos, emptySpacePos)
|
await comfyPage.canvasOps.dragAndDrop(outputSlotPos, emptySpacePos)
|
||||||
await comfyPage.page.keyboard.up('Shift')
|
await comfyPage.page.keyboard.up('Shift')
|
||||||
|
|
||||||
// Select the second item as the first item is always reroute
|
// Select the second item as the first item is always reroute
|
||||||
|
|||||||
@@ -103,7 +103,11 @@ test.describe('Node Right Click Menu', { tag: ['@screenshot', '@ui'] }, () => {
|
|||||||
await expect(comfyPage.canvas).toHaveScreenshot('right-click-node.png')
|
await expect(comfyPage.canvas).toHaveScreenshot('right-click-node.png')
|
||||||
await comfyPage.page.click('.litemenu-entry:has-text("Pin")')
|
await comfyPage.page.click('.litemenu-entry:has-text("Pin")')
|
||||||
await comfyPage.nextFrame()
|
await comfyPage.nextFrame()
|
||||||
await comfyPage.canvasOps.dragAndDrop({ x: 621, y: 617 }, { x: 16, y: 16 })
|
|
||||||
|
// Get EmptyLatentImage node title position dynamically (for dragging)
|
||||||
|
const emptyLatentNode = await comfyPage.nodeOps.getNodeRefById(5)
|
||||||
|
const titlePos = await emptyLatentNode.getTitlePosition()
|
||||||
|
await comfyPage.canvasOps.dragAndDrop(titlePos, { x: 16, y: 16 })
|
||||||
await expect(comfyPage.canvas).toHaveScreenshot('node-pinned.png')
|
await expect(comfyPage.canvas).toHaveScreenshot('node-pinned.png')
|
||||||
await comfyPage.rightClickEmptyLatentNode()
|
await comfyPage.rightClickEmptyLatentNode()
|
||||||
await expect(comfyPage.canvas).toHaveScreenshot(
|
await expect(comfyPage.canvas).toHaveScreenshot(
|
||||||
@@ -124,10 +128,11 @@ test.describe('Node Right Click Menu', { tag: ['@screenshot', '@ui'] }, () => {
|
|||||||
await comfyPage.rightClickEmptyLatentNode()
|
await comfyPage.rightClickEmptyLatentNode()
|
||||||
await comfyPage.page.click('.litemenu-entry:has-text("Unpin")')
|
await comfyPage.page.click('.litemenu-entry:has-text("Unpin")')
|
||||||
await comfyPage.nextFrame()
|
await comfyPage.nextFrame()
|
||||||
await comfyPage.canvasOps.dragAndDrop(
|
|
||||||
{ x: 496, y: 618 },
|
// Get EmptyLatentImage node title position dynamically (for dragging)
|
||||||
{ x: 200, y: 590 }
|
const emptyLatentNode = await comfyPage.nodeOps.getNodeRefById(5)
|
||||||
)
|
const titlePos = await emptyLatentNode.getTitlePosition()
|
||||||
|
await comfyPage.canvasOps.dragAndDrop(titlePos, { x: 200, y: 590 })
|
||||||
await expect(comfyPage.canvas).toHaveScreenshot(
|
await expect(comfyPage.canvas).toHaveScreenshot(
|
||||||
'right-click-unpinned-node-moved.png'
|
'right-click-unpinned-node-moved.png'
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user