mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 14:30:41 +00:00
fix: restore page.evaluate fallbacks for legacy menu mode
isInSubgraph, exitViaBreadcrumb, getNodeCount, and delete now use DOM-first with page.evaluate fallback when UseNewMenu is Disabled. Amp-Thread-ID: https://ampcode.com/threads/T-019d368d-bb9c-74f6-8b34-71cef5e40054 Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -317,13 +317,29 @@ export class SubgraphHelper {
|
||||
|
||||
async isInSubgraph(): Promise<boolean> {
|
||||
const breadcrumb = this.page.getByTestId(TestIds.breadcrumb.subgraph)
|
||||
return breadcrumb.isVisible()
|
||||
if (await breadcrumb.isVisible().catch(() => false)) return true
|
||||
|
||||
return this.page.evaluate(() => {
|
||||
const graph = window.app!.canvas.graph
|
||||
return !!graph && 'inputNode' in graph
|
||||
})
|
||||
}
|
||||
|
||||
async exitViaBreadcrumb(): Promise<void> {
|
||||
const breadcrumb = this.page.getByTestId(TestIds.breadcrumb.subgraph)
|
||||
const parentLink = breadcrumb.getByRole('link').first()
|
||||
await parentLink.click()
|
||||
const rootItem = breadcrumb.getByTestId(TestIds.breadcrumb.root)
|
||||
|
||||
if (await rootItem.isVisible().catch(() => false)) {
|
||||
await rootItem.click()
|
||||
} else {
|
||||
await this.page.evaluate(() => {
|
||||
const canvas = window.app!.canvas
|
||||
const graph = canvas.graph
|
||||
if (!graph) return
|
||||
canvas.setGraph(graph.rootGraph)
|
||||
})
|
||||
}
|
||||
|
||||
await this.comfyPage.nextFrame()
|
||||
await expect.poll(async () => this.isInSubgraph()).toBe(false)
|
||||
}
|
||||
@@ -386,7 +402,12 @@ export class SubgraphHelper {
|
||||
}
|
||||
|
||||
async getNodeCount(): Promise<number> {
|
||||
return this.page.locator('[data-node-id]').count()
|
||||
const domCount = await this.page.locator('[data-node-id]').count()
|
||||
if (domCount > 0) return domCount
|
||||
|
||||
return this.page.evaluate(() => {
|
||||
return window.app!.canvas.graph!.nodes?.length || 0
|
||||
})
|
||||
}
|
||||
|
||||
async getSlotCount(type: 'input' | 'output'): Promise<number> {
|
||||
|
||||
@@ -380,7 +380,16 @@ export class NodeReference {
|
||||
await this.comfyPage.nextFrame()
|
||||
}
|
||||
async delete(): Promise<void> {
|
||||
await this.click('title')
|
||||
const header = this.comfyPage.page
|
||||
.locator(`[data-node-id="${this.id}"] [data-testid^="node-header-"]`)
|
||||
.first()
|
||||
|
||||
if ((await header.count()) > 0) {
|
||||
await header.click({ force: true })
|
||||
} else {
|
||||
await this.click('title')
|
||||
}
|
||||
|
||||
await this.comfyPage.page.keyboard.press('Delete')
|
||||
await this.comfyPage.nextFrame()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user