mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-21 23:34:31 +00:00
New settings API (#1292)
* Add settings API * Add playwright test * Update README
This commit is contained in:
@@ -528,7 +528,7 @@ export class ComfyPage {
|
||||
async setSetting(settingId: string, settingValue: any) {
|
||||
return await this.page.evaluate(
|
||||
async ({ id, value }) => {
|
||||
await window['app'].ui.settings.setSettingValueAsync(id, value)
|
||||
await window['app'].extensionManager.setting.set(id, value)
|
||||
},
|
||||
{ id: settingId, value: settingValue }
|
||||
)
|
||||
@@ -536,7 +536,7 @@ export class ComfyPage {
|
||||
|
||||
async getSetting(settingId: string) {
|
||||
return await this.page.evaluate(async (id) => {
|
||||
return await window['app'].ui.settings.getSettingValue(id)
|
||||
return await window['app'].extensionManager.setting.get(id)
|
||||
}, settingId)
|
||||
}
|
||||
|
||||
|
||||
@@ -83,4 +83,23 @@ test.describe('Topbar commands', () => {
|
||||
true
|
||||
)
|
||||
})
|
||||
|
||||
test('Should allow adding settings', async ({ comfyPage }) => {
|
||||
await comfyPage.page.evaluate(() => {
|
||||
window['app'].registerExtension({
|
||||
name: 'TestExtension1',
|
||||
settings: [
|
||||
{
|
||||
id: 'TestSetting',
|
||||
name: 'Test Setting',
|
||||
type: 'text',
|
||||
defaultValue: 'Hello, world!'
|
||||
}
|
||||
]
|
||||
})
|
||||
})
|
||||
expect(await comfyPage.getSetting('TestSetting')).toBe('Hello, world!')
|
||||
await comfyPage.setSetting('TestSetting', 'Hello, universe!')
|
||||
expect(await comfyPage.getSetting('TestSetting')).toBe('Hello, universe!')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user