Skip to content

Commit

Permalink
Drop to center
Browse files Browse the repository at this point in the history
  • Loading branch information
huchenlei committed Sep 24, 2024
1 parent 475f944 commit 2a9718c
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion browser_tests/menu.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,21 @@ test.describe('Menu', () => {
const count = await comfyPage.getGraphNodesCount()
// Drag the node onto the canvas
const canvasSelector = '#graph-canvas'
await comfyPage.page.dragAndDrop(nodeSelector, canvasSelector)

// Get the bounding box of the canvas element
const canvasBoundingBox = (await comfyPage.page
.locator(canvasSelector)
.boundingBox())!

// Calculate the center position of the canvas
const targetPosition = {
x: canvasBoundingBox.x + canvasBoundingBox.width / 2,
y: canvasBoundingBox.y + canvasBoundingBox.height / 2
}

await comfyPage.page.dragAndDrop(nodeSelector, canvasSelector, {
targetPosition
})

// Verify the node is added to the canvas
expect(await comfyPage.getGraphNodesCount()).toBe(count + 1)
Expand Down

0 comments on commit 2a9718c

Please sign in to comment.