fix: remove test settings from production schema

Remove 5 test setting IDs that were incorrectly added to the production
apiSchema.ts. Test settings now use `as TestSettingId` casts in test
files instead of polluting the production Settings type.

Changes:
- Remove TestSetting, TestHiddenSetting, TestDeprecatedSetting,
  TestVisibleSetting, Comfy.TestSetting from apiSchema.ts
- Add TestSettingId type helper to extensionAPI.spec.ts and
  useSettingSearch.spec.ts
- Use specific `as TestSettingId` casts with explanatory comments

This keeps production types clean while allowing tests to register
arbitrary setting IDs (which is valid extension behavior).

Amp-Thread-ID: https://ampcode.com/threads/T-019c1833-2352-728b-a523-a8f440fd3ba1
Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
Alexander Brown
2026-02-01 00:30:27 -08:00
parent c411bfca75
commit 4b95f22737
3 changed files with 29 additions and 11 deletions

View File

@@ -1,8 +1,17 @@
import { expect } from '@playwright/test'
import type { Settings } from '../../src/schemas/apiSchema'
import type { SettingParams } from '../../src/platform/settings/types'
import { comfyPageFixture as test } from '../fixtures/ComfyPage'
/**
* Type helper for test settings with arbitrary IDs.
* Extensions can register settings with any ID, but SettingParams.id
* is typed as keyof Settings for autocomplete. This helper allows
* arbitrary IDs in tests while keeping type safety for other fields.
*/
type TestSettingId = keyof Settings
test.describe('Topbar commands', () => {
test.beforeEach(async ({ comfyPage }) => {
await comfyPage.settings.setSetting('Comfy.UseNewMenu', 'Top')
@@ -87,7 +96,8 @@ test.describe('Topbar commands', () => {
name: 'TestExtension1',
settings: [
{
id: 'TestSetting',
// Extensions can register arbitrary setting IDs
id: 'TestSetting' as TestSettingId,
name: 'Test Setting',
type: 'text',
defaultValue: 'Hello, world!',
@@ -117,7 +127,8 @@ test.describe('Topbar commands', () => {
name: 'TestExtension1',
settings: [
{
id: 'Comfy.TestSetting',
// Extensions can register arbitrary setting IDs
id: 'Comfy.TestSetting' as TestSettingId,
name: 'Test Setting',
type: 'boolean',
defaultValue: false,
@@ -202,7 +213,8 @@ test.describe('Topbar commands', () => {
name: 'TestExtension1',
settings: [
{
id: 'Comfy.TestSetting',
// Extensions can register arbitrary setting IDs
id: 'Comfy.TestSetting' as TestSettingId,
name: 'Test',
attrs: { disabled: true },
...config

View File

@@ -1,7 +1,15 @@
import { expect } from '@playwright/test'
import type { Settings } from '../../src/schemas/apiSchema'
import { comfyPageFixture as test } from '../fixtures/ComfyPage'
/**
* Type helper for test settings with arbitrary IDs.
* Extensions can register settings with any ID, but SettingParams.id
* is typed as keyof Settings for autocomplete.
*/
type TestSettingId = keyof Settings
test.beforeEach(async ({ comfyPage }) => {
await comfyPage.settings.setSetting('Comfy.UseNewMenu', 'Disabled')
})
@@ -14,14 +22,16 @@ test.describe('Settings Search functionality', { tag: '@settings' }, () => {
name: 'TestSettingsExtension',
settings: [
{
id: 'TestHiddenSetting',
// Extensions can register arbitrary setting IDs
id: 'TestHiddenSetting' as TestSettingId,
name: 'Test Hidden Setting',
type: 'hidden',
defaultValue: 'hidden_value',
category: ['Test', 'Hidden']
},
{
id: 'TestDeprecatedSetting',
// Extensions can register arbitrary setting IDs
id: 'TestDeprecatedSetting' as TestSettingId,
name: 'Test Deprecated Setting',
type: 'text',
defaultValue: 'deprecated_value',
@@ -29,7 +39,8 @@ test.describe('Settings Search functionality', { tag: '@settings' }, () => {
category: ['Test', 'Deprecated']
},
{
id: 'TestVisibleSetting',
// Extensions can register arbitrary setting IDs
id: 'TestVisibleSetting' as TestSettingId,
name: 'Test Visible Setting',
type: 'text',
defaultValue: 'visible_value',

View File

@@ -427,11 +427,6 @@ const zSettings = z.object({
'test.setting': z.any(),
'main.sub.setting.name': z.any(),
'single.setting': z.any(),
TestSetting: z.any(),
TestHiddenSetting: z.any(),
TestDeprecatedSetting: z.any(),
TestVisibleSetting: z.any(),
'Comfy.TestSetting': z.any(),
'LiteGraph.Node.DefaultPadding': z.boolean(),
'LiteGraph.Pointer.TrackpadGestures': z.boolean(),
'Comfy.VersionCompatibility.DisableWarnings': z.boolean(),