mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 14:30:41 +00:00
fix: restore graph-model fallbacks and fix slot coordinate conversion
- Add convertOffsetToCanvas() for slot.pos in rightClick branch - Restore page.evaluate fallback in findSubgraphNodeId() - Replace DOM-only lookups with graph-model queries in specs Amp-Thread-ID: https://ampcode.com/threads/T-019d36b1-19c4-75ed-924c-5eaea2f3a90c Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -69,8 +69,12 @@ export class SubgraphHelper {
|
||||
|
||||
if (action === 'rightClick') {
|
||||
if (!slot.pos) continue
|
||||
canvasX = slot.pos[0]
|
||||
canvasY = slot.pos[1]
|
||||
const converted = app.canvas.ds.convertOffsetToCanvas([
|
||||
slot.pos[0],
|
||||
slot.pos[1]
|
||||
])
|
||||
canvasX = converted[0]
|
||||
canvasY = converted[1]
|
||||
} else {
|
||||
if (!slot.boundingRect) {
|
||||
throw new Error(`${slotType} slot bounding rect not found`)
|
||||
@@ -447,10 +451,22 @@ export class SubgraphHelper {
|
||||
const enterButton = this.page
|
||||
.getByTestId(TestIds.widgets.subgraphEnterButton)
|
||||
.first()
|
||||
const nodeEl = enterButton
|
||||
.locator('xpath=ancestor::*[@data-node-id]')
|
||||
.first()
|
||||
const id = await nodeEl.getAttribute('data-node-id')
|
||||
|
||||
if ((await enterButton.count()) > 0) {
|
||||
const nodeEl = enterButton
|
||||
.locator('xpath=ancestor::*[@data-node-id]')
|
||||
.first()
|
||||
const id = await nodeEl.getAttribute('data-node-id')
|
||||
if (id) return id
|
||||
}
|
||||
|
||||
const id = await this.page.evaluate(() => {
|
||||
const graph = window.app!.canvas.graph!
|
||||
const node = graph.nodes.find(
|
||||
(n) => typeof n.isSubgraphNode === 'function' && n.isSubgraphNode()
|
||||
)
|
||||
return node ? String(node.id) : null
|
||||
})
|
||||
if (!id) throw new Error('No subgraph node found in current graph')
|
||||
return id
|
||||
}
|
||||
|
||||
@@ -448,10 +448,10 @@ test.describe('Subgraph Operations', { tag: ['@slow', '@subgraph'] }, () => {
|
||||
|
||||
const initialNodeCount = await comfyPage.subgraph.getNodeCount()
|
||||
|
||||
const firstNodeLocator = comfyPage.page.locator('[data-node-id]').first()
|
||||
await expect(firstNodeLocator).toBeVisible()
|
||||
const firstNodeId = await firstNodeLocator.getAttribute('data-node-id')
|
||||
|
||||
const firstNodeId = await comfyPage.page.evaluate(() => {
|
||||
const nodes = window.app!.canvas.graph!.nodes
|
||||
return nodes?.[0]?.id != null ? String(nodes[0].id) : null
|
||||
})
|
||||
expect(firstNodeId).not.toBeNull()
|
||||
|
||||
const nodeToClone = await comfyPage.nodeOps.getNodeRefById(firstNodeId!)
|
||||
|
||||
@@ -310,9 +310,10 @@ test.describe(
|
||||
})
|
||||
await comfyPage.nextFrame()
|
||||
|
||||
await expect(comfyPage.page.locator('[data-node-id="7"]')).toHaveCount(
|
||||
0
|
||||
)
|
||||
const nodeExists = await comfyPage.page.evaluate(() => {
|
||||
return !!window.app!.graph!.getNodeById('7')
|
||||
})
|
||||
expect(nodeExists).toBe(false)
|
||||
|
||||
const secondNodeAfter = await getPseudoPreviewWidgets(comfyPage, '8')
|
||||
expect(secondNodeAfter).toEqual(secondNodeBefore)
|
||||
|
||||
@@ -559,16 +559,15 @@ test.describe(
|
||||
await comfyPage.page.keyboard.up('Alt')
|
||||
await comfyPage.nextFrame()
|
||||
|
||||
const enterButtons = comfyPage.page.getByTestId(
|
||||
TestIds.widgets.subgraphEnterButton
|
||||
)
|
||||
const allButtons = await enterButtons.all()
|
||||
const subgraphNodeIds: string[] = []
|
||||
for (const btn of allButtons) {
|
||||
const nodeEl = btn.locator('xpath=ancestor::*[@data-node-id]').first()
|
||||
const id = await nodeEl.getAttribute('data-node-id')
|
||||
if (id) subgraphNodeIds.push(id)
|
||||
}
|
||||
const subgraphNodeIds = await comfyPage.page.evaluate(() => {
|
||||
const graph = window.app!.canvas.graph!
|
||||
return graph.nodes
|
||||
.filter(
|
||||
(n) =>
|
||||
typeof n.isSubgraphNode === 'function' && n.isSubgraphNode()
|
||||
)
|
||||
.map((n) => String(n.id))
|
||||
})
|
||||
|
||||
expect(subgraphNodeIds.length).toBeGreaterThan(1)
|
||||
for (const nodeId of subgraphNodeIds) {
|
||||
|
||||
Reference in New Issue
Block a user