mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-14 17:37:46 +00:00
Fix widget/input conversion on text widgets (#1129)
* Support converting dynamically created text widgets to input * Fix array contains * Add test wait * Try to fix test only failing in CI * Fix test: Disable conversion option nesting in contextmenu
This commit is contained in:
@@ -1198,6 +1198,11 @@ export class NodeReference {
|
||||
)
|
||||
return originSlot
|
||||
}
|
||||
async getContextMenuOptionNames() {
|
||||
await this.click('title', { button: 'right' })
|
||||
const ctx = this.comfyPage.page.locator('.litecontextmenu')
|
||||
return await ctx.locator('.litemenu-entry').allInnerTexts()
|
||||
}
|
||||
async clickContextMenuOption(optionText: string) {
|
||||
await this.click('title', { button: 'right' })
|
||||
const ctx = this.comfyPage.page.locator('.litecontextmenu')
|
||||
|
||||
@@ -93,16 +93,54 @@ test.describe('Node Right Click Menu', () => {
|
||||
)
|
||||
})
|
||||
|
||||
test('Can convert widget to input', async ({ comfyPage }) => {
|
||||
await comfyPage.rightClickEmptyLatentNode()
|
||||
await expect(comfyPage.canvas).toHaveScreenshot('right-click-node.png')
|
||||
await comfyPage.page.getByText('Convert Widget to Input').click()
|
||||
await comfyPage.nextFrame()
|
||||
await comfyPage.page.getByText('Convert width to input').click()
|
||||
await comfyPage.nextFrame()
|
||||
await expect(comfyPage.canvas).toHaveScreenshot(
|
||||
'right-click-node-widget-converted.png'
|
||||
)
|
||||
test.describe('Widget conversion', () => {
|
||||
const convertibleWidgetTypes = ['text', 'string', 'number', 'toggle']
|
||||
|
||||
test.afterEach(async ({ comfyPage }) => {
|
||||
// Restore default setting value
|
||||
await comfyPage.setSetting('Comfy.NodeInputConversionSubmenus', true)
|
||||
})
|
||||
|
||||
test('Can convert widget to input', async ({ comfyPage }) => {
|
||||
await comfyPage.rightClickEmptyLatentNode()
|
||||
await expect(comfyPage.canvas).toHaveScreenshot('right-click-node.png')
|
||||
await comfyPage.page.getByText('Convert Widget to Input').click()
|
||||
await comfyPage.nextFrame()
|
||||
await comfyPage.page.getByText('Convert width to input').click()
|
||||
await comfyPage.nextFrame()
|
||||
await expect(comfyPage.canvas).toHaveScreenshot(
|
||||
'right-click-node-widget-converted.png'
|
||||
)
|
||||
})
|
||||
|
||||
convertibleWidgetTypes.forEach((widgetType) => {
|
||||
test(`Can convert ${widgetType} widget to input`, async ({
|
||||
comfyPage
|
||||
}) => {
|
||||
const nodeType = 'KSampler'
|
||||
|
||||
// To avoid needing multiple clicks, disable nesting of conversion options
|
||||
await comfyPage.setSetting('Comfy.NodeInputConversionSubmenus', false)
|
||||
|
||||
// Add the widget using the node's `addWidget` method
|
||||
await comfyPage.page.evaluate(
|
||||
([nodeType, widgetType]) => {
|
||||
const node = window['app'].graph.nodes.find(
|
||||
(n) => n.type === nodeType
|
||||
)
|
||||
node.addWidget(widgetType, widgetType, 'defaultValue', () => {}, {})
|
||||
},
|
||||
[nodeType, widgetType]
|
||||
)
|
||||
|
||||
// Verify the context menu includes the conversion option
|
||||
const node = (await comfyPage.getNodeRefsByType(nodeType))[0]
|
||||
const menuOptions = await node.getContextMenuOptionNames()
|
||||
expect(menuOptions.includes(`Convert ${widgetType} to input`)).toBe(
|
||||
true
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
test('Can pin and unpin', async ({ comfyPage }) => {
|
||||
|
||||
Reference in New Issue
Block a user