New settings API (#1292)

* Add settings API

* Add playwright test

* Update README
This commit is contained in:
Chenlei Hu
2024-10-24 16:26:01 +02:00
committed by GitHub
parent 3553c8e0d4
commit 957a767ed0
9 changed files with 109 additions and 4 deletions

View File

@@ -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)
}

View File

@@ -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!')
})
})