mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-19 22:09:37 +00:00
## Summary Adds a test for setting various types of widgets in app mode, then validating the /prompt API is called with the expected values ## Changes - **What**: - extract duplicated enableLinearMode - add AppModeWidgetHelper for setting values ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-10746-test-App-mode-setting-widget-value-test-3336d73d365081739598fb5280d0127e) by [Unito](https://www.unito.io)
95 lines
2.3 KiB
TypeScript
95 lines
2.3 KiB
TypeScript
import {
|
|
comfyPageFixture as test,
|
|
comfyExpect as expect
|
|
} from '../fixtures/ComfyPage'
|
|
|
|
/** One representative of each widget type from the default workflow. */
|
|
type WidgetType = 'textarea' | 'number' | 'select' | 'text'
|
|
|
|
const WIDGET_TEST_DATA: {
|
|
nodeId: string
|
|
widgetName: string
|
|
type: WidgetType
|
|
fill: string
|
|
expected: unknown
|
|
}[] = [
|
|
{
|
|
nodeId: '6',
|
|
widgetName: 'text',
|
|
type: 'textarea',
|
|
fill: 'test prompt',
|
|
expected: 'test prompt'
|
|
},
|
|
{
|
|
nodeId: '5',
|
|
widgetName: 'width',
|
|
type: 'number',
|
|
fill: '768',
|
|
expected: 768
|
|
},
|
|
{
|
|
nodeId: '3',
|
|
widgetName: 'cfg',
|
|
type: 'number',
|
|
fill: '3.5',
|
|
expected: 3.5
|
|
},
|
|
{
|
|
nodeId: '3',
|
|
widgetName: 'sampler_name',
|
|
type: 'select',
|
|
fill: 'uni_pc',
|
|
expected: 'uni_pc'
|
|
},
|
|
{
|
|
nodeId: '9',
|
|
widgetName: 'filename_prefix',
|
|
type: 'text',
|
|
fill: 'test_prefix',
|
|
expected: 'test_prefix'
|
|
}
|
|
]
|
|
|
|
test.describe('App mode widget values in prompt', { tag: '@ui' }, () => {
|
|
test.beforeEach(async ({ comfyPage }) => {
|
|
await comfyPage.appMode.enableLinearMode()
|
|
})
|
|
|
|
test('Widget values are sent correctly in prompt POST', async ({
|
|
comfyPage
|
|
}) => {
|
|
const { appMode } = comfyPage
|
|
const inputs: [string, string][] = WIDGET_TEST_DATA.map(
|
|
({ nodeId, widgetName }) => [nodeId, widgetName]
|
|
)
|
|
await appMode.enterAppModeWithInputs(inputs)
|
|
await expect(appMode.linearWidgets).toBeVisible({ timeout: 5000 })
|
|
|
|
for (const { nodeId, widgetName, type, fill } of WIDGET_TEST_DATA) {
|
|
const key = `${nodeId}:${widgetName}`
|
|
switch (type) {
|
|
case 'textarea':
|
|
await appMode.widgets.fillTextarea(key, fill)
|
|
break
|
|
case 'number':
|
|
await appMode.widgets.fillNumber(key, fill)
|
|
break
|
|
case 'select':
|
|
await appMode.widgets.selectOption(key, fill)
|
|
break
|
|
case 'text':
|
|
await appMode.widgets.fillText(key, fill)
|
|
break
|
|
default:
|
|
throw new Error(`Unknown widget type: ${type satisfies never}`)
|
|
}
|
|
}
|
|
|
|
const prompt = await appMode.widgets.runAndCapturePrompt()
|
|
|
|
for (const { nodeId, widgetName, expected } of WIDGET_TEST_DATA) {
|
|
expect(prompt[nodeId].inputs[widgetName]).toBe(expected)
|
|
}
|
|
})
|
|
})
|