mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-22 21:38:52 +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>
82 lines
2.5 KiB
TypeScript
82 lines
2.5 KiB
TypeScript
import type { Locator } from '@playwright/test'
|
|
|
|
import { comfyExpect as expect } from '@e2e/fixtures/ComfyPage'
|
|
import type { ComfyPage } from '@e2e/fixtures/ComfyPage'
|
|
import { TestIds } from '@e2e/fixtures/selectors'
|
|
import { dragByIndex } from '@e2e/fixtures/utils/dragAndDrop'
|
|
import { VueNodeFixture } from '@e2e/fixtures/utils/vueNodeFixtures'
|
|
|
|
export class SubgraphEditor {
|
|
public readonly root: Locator
|
|
public readonly promotionItems: Locator
|
|
|
|
constructor(protected readonly comfyPage: ComfyPage) {
|
|
this.root = this.comfyPage.menu.propertiesPanel.root
|
|
this.promotionItems = this.root.getByTestId(
|
|
TestIds.subgraphEditor.widgetItem
|
|
)
|
|
}
|
|
|
|
async open(subgraphNode: Locator) {
|
|
await new VueNodeFixture(subgraphNode).select()
|
|
const menu = await this.comfyPage.contextMenu.openFor(subgraphNode)
|
|
await menu.clickMenuItemExact('Edit Subgraph Widgets')
|
|
await expect(this.root, 'Open Properties Panel').toBeVisible()
|
|
}
|
|
|
|
resolveItem(options: {
|
|
nodeName?: string
|
|
nodeId?: string
|
|
widgetName: string
|
|
}): Locator {
|
|
const nodeItems =
|
|
options.nodeId !== undefined
|
|
? this.comfyPage.page.locator(`[data-nodeid="${options.nodeId}"]`)
|
|
: options.nodeName !== undefined
|
|
? this.promotionItems.filter({
|
|
has: this.comfyPage.page
|
|
.getByTestId(TestIds.subgraphEditor.nodeName)
|
|
.filter({ hasText: options.nodeName })
|
|
})
|
|
: this.promotionItems
|
|
|
|
return nodeItems.filter({
|
|
has: this.comfyPage.page
|
|
.getByTestId(TestIds.subgraphEditor.widgetLabel)
|
|
.filter({ hasText: options.widgetName })
|
|
})
|
|
}
|
|
|
|
getToggleButton(item: Locator) {
|
|
return item.getByTestId(TestIds.subgraphEditor.widgetToggle)
|
|
}
|
|
|
|
async togglePromotionOnItem(item: Locator, toState?: boolean) {
|
|
const toggleIcon = item.getByTestId(TestIds.subgraphEditor.iconEye)
|
|
if (toState !== undefined) {
|
|
const expectedIcon = `icon-[lucide--eye${toState ? '-off' : ''}]`
|
|
await expect(toggleIcon).toContainClass(expectedIcon)
|
|
}
|
|
await toggleIcon.click()
|
|
}
|
|
|
|
async togglePromotion(
|
|
subgraphNode: Locator,
|
|
options: {
|
|
nodeName?: string
|
|
nodeId?: string
|
|
widgetName: string
|
|
toState?: boolean
|
|
}
|
|
) {
|
|
await this.open(subgraphNode)
|
|
|
|
const item = this.resolveItem(options)
|
|
await this.togglePromotionOnItem(item, options.toState)
|
|
}
|
|
async dragItem(fromIndex: number, toIndex: number) {
|
|
await dragByIndex(this.promotionItems, fromIndex, toIndex)
|
|
await this.comfyPage.nextFrame()
|
|
}
|
|
}
|