mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-27 09:45:13 +00:00
[Electron] Show server launch args in server config panel (#1669)
* Move revertChanges * Show launch args * Explicit ServerConfigValue type * nit * nit * Add tests
This commit is contained in:
@@ -170,21 +170,80 @@ describe('useServerConfigStore', () => {
|
||||
const configs: ServerConfig<any>[] = [
|
||||
{ ...dummyFormItem, id: 'test.config1', defaultValue: 'default1' },
|
||||
{ ...dummyFormItem, id: 'test.config2', defaultValue: 'default2' },
|
||||
{ ...dummyFormItem, id: 'test.config3', defaultValue: 'default3' }
|
||||
{ ...dummyFormItem, id: 'test.config3', defaultValue: 'default3' },
|
||||
{ ...dummyFormItem, id: 'test.config4', defaultValue: null }
|
||||
]
|
||||
|
||||
store.loadServerConfig(configs, {
|
||||
'test.config1': undefined,
|
||||
'test.config2': null,
|
||||
'test.config3': ''
|
||||
'test.config3': '',
|
||||
'test.config4': 0
|
||||
})
|
||||
|
||||
expect(Object.keys(store.launchArgs)).toHaveLength(0)
|
||||
expect(Object.keys(store.serverConfigValues)).toEqual([
|
||||
'test.config1',
|
||||
'test.config2',
|
||||
'test.config3'
|
||||
expect(Object.keys(store.launchArgs)).toEqual([
|
||||
'test.config3',
|
||||
'test.config4'
|
||||
])
|
||||
expect(Object.values(store.launchArgs)).toEqual(['', '0'])
|
||||
expect(store.serverConfigById['test.config3'].value).toBe('')
|
||||
expect(store.serverConfigById['test.config4'].value).toBe(0)
|
||||
expect(Object.values(store.serverConfigValues)).toEqual([
|
||||
undefined,
|
||||
undefined,
|
||||
'',
|
||||
0
|
||||
])
|
||||
})
|
||||
|
||||
it('should convert true to empty string in launch arguments', () => {
|
||||
store.loadServerConfig(
|
||||
[
|
||||
{
|
||||
...dummyFormItem,
|
||||
id: 'test.config1',
|
||||
defaultValue: 0
|
||||
}
|
||||
],
|
||||
{
|
||||
'test.config1': true
|
||||
}
|
||||
)
|
||||
expect(store.launchArgs['test.config1']).toBe('')
|
||||
expect(store.commandLineArgs).toBe('--test.config1')
|
||||
})
|
||||
|
||||
it('should convert number to string in launch arguments', () => {
|
||||
store.loadServerConfig(
|
||||
[
|
||||
{
|
||||
...dummyFormItem,
|
||||
id: 'test.config1',
|
||||
defaultValue: 1
|
||||
}
|
||||
],
|
||||
{
|
||||
'test.config1': 123
|
||||
}
|
||||
)
|
||||
expect(store.launchArgs['test.config1']).toBe('123')
|
||||
expect(store.commandLineArgs).toBe('--test.config1 123')
|
||||
})
|
||||
|
||||
it('should drop nullish values in launch arguments', () => {
|
||||
store.loadServerConfig(
|
||||
[
|
||||
{
|
||||
...dummyFormItem,
|
||||
id: 'test.config1',
|
||||
defaultValue: 1
|
||||
}
|
||||
],
|
||||
{
|
||||
'test.config1': null
|
||||
}
|
||||
)
|
||||
expect(Object.keys(store.launchArgs)).toHaveLength(0)
|
||||
})
|
||||
|
||||
it('should track modified configs', () => {
|
||||
|
||||
Reference in New Issue
Block a user