From 4b95f22737d6d4dc7f4b70a907cf6c74764d2fef Mon Sep 17 00:00:00 2001 From: Alexander Brown <448862+DrJKL@users.noreply.github.com> Date: Sun, 1 Feb 2026 00:30:27 -0800 Subject: [PATCH] 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 --- browser_tests/tests/extensionAPI.spec.ts | 18 +++++++++++++++--- browser_tests/tests/useSettingSearch.spec.ts | 17 ++++++++++++++--- src/schemas/apiSchema.ts | 5 ----- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/browser_tests/tests/extensionAPI.spec.ts b/browser_tests/tests/extensionAPI.spec.ts index 2487815c0..97d4424c9 100644 --- a/browser_tests/tests/extensionAPI.spec.ts +++ b/browser_tests/tests/extensionAPI.spec.ts @@ -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 diff --git a/browser_tests/tests/useSettingSearch.spec.ts b/browser_tests/tests/useSettingSearch.spec.ts index bd8373fc1..5c3ebb866 100644 --- a/browser_tests/tests/useSettingSearch.spec.ts +++ b/browser_tests/tests/useSettingSearch.spec.ts @@ -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', diff --git a/src/schemas/apiSchema.ts b/src/schemas/apiSchema.ts index 2c0d9dbf5..b75942a55 100644 --- a/src/schemas/apiSchema.ts +++ b/src/schemas/apiSchema.ts @@ -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(),