mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-24 14:45:36 +00:00
- Adds functions to SubgraphHelper to perform widget promotion by standard user means - Right Click -> Promote - Properties Panel - Adds new slot fixture code that works with simple `locator.dragTo` operations. - Adds multiple subgraph tests with a focus on historically difficult operations. - Fixes a bug where the litegraph `node.selected` state would not be unset when switching graphs. This made it so 'Selecting a node -> leaving subgraph -> re-enter subgraph -> right click on node' would fail to select the node because it is marked as already selected. ┆Issue is synchronized with this [Notion page](https://app.notion.com/p/PR-11806-Add-helper-functions-for-widget-promotion-3536d73d365081f58dd9cd730c1a91a9) by [Unito](https://www.unito.io) --------- Co-authored-by: Alexander Brown <drjkl@comfy.org>
34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
import type { Locator } from '@playwright/test'
|
|
|
|
/**
|
|
* Drag an element from one index to another within a list of locators.
|
|
* Uses mousedown/mousemove/mouseup to trigger the DraggableList library.
|
|
*
|
|
* DraggableList toggles position when the dragged item's center crosses
|
|
* past an idle item's center. To reliably land at the target position,
|
|
* we overshoot slightly past the target's far edge.
|
|
*/
|
|
export async function dragByIndex(
|
|
items: Locator,
|
|
fromIndex: number,
|
|
toIndex: number
|
|
) {
|
|
const fromBox = await items.nth(fromIndex).boundingBox()
|
|
const toBox = await items.nth(toIndex).boundingBox()
|
|
if (!fromBox || !toBox) throw new Error('Item not visible for drag')
|
|
|
|
const draggingDown = toIndex > fromIndex
|
|
const targetY = draggingDown
|
|
? toBox.y + toBox.height * 0.9
|
|
: toBox.y + toBox.height * 0.1
|
|
|
|
const page = items.page()
|
|
await page.mouse.move(
|
|
fromBox.x + fromBox.width / 2,
|
|
fromBox.y + fromBox.height / 2
|
|
)
|
|
await page.mouse.down()
|
|
await page.mouse.move(toBox.x + toBox.width / 2, targetY, { steps: 10 })
|
|
await page.mouse.up()
|
|
}
|