From 99014cb1ccd1cef5eae6356a07cc22310619b820 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Thu, 16 Apr 2026 18:33:37 +0200 Subject: [PATCH] test: add enum rejection tests and fix dynamic import in CLI test - Add 2 edge-case tests for invalid protocol/version enum values (protocol: 'ws' and version: '2.0' are now correctly rejected) - Replace unnecessary dynamic import with static import in lifecycle.test.ts for consistency with other test files --- ui/cli/tests/lifecycle.test.ts | 2 +- ui/common/tests/config.test.ts | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/ui/cli/tests/lifecycle.test.ts b/ui/cli/tests/lifecycle.test.ts index 3f12b313..c6d54a60 100644 --- a/ui/cli/tests/lifecycle.test.ts +++ b/ui/cli/tests/lifecycle.test.ts @@ -2,6 +2,7 @@ import assert from 'node:assert' import { describe, it } from 'node:test' +import { Protocol, ProtocolVersion } from 'ui-common' import { ConnectionError } from '../src/client/errors.js' import { executeCommand } from '../src/client/lifecycle.js' @@ -36,7 +37,6 @@ await describe('lifecycle', async () => { }) await it('should reject executeCommand with NaN timeout', async () => { - const { Protocol, ProtocolVersion } = await import('ui-common') await assert.rejects( executeCommand({ config: { diff --git a/ui/common/tests/config.test.ts b/ui/common/tests/config.test.ts index 9946aab3..ab1c4e48 100644 --- a/ui/common/tests/config.test.ts +++ b/ui/common/tests/config.test.ts @@ -24,6 +24,26 @@ await describe('config schema validation', async () => { assert.strictEqual(result.success, false) }) + await it('should reject config with protocol not in Protocol enum', () => { + const result = uiServerConfigSchema.safeParse({ + host: 'localhost', + port: 8080, + protocol: 'ws', + version: '0.0.1', + }) + assert.strictEqual(result.success, false) + }) + + await it('should reject config with version not in ProtocolVersion enum', () => { + const result = uiServerConfigSchema.safeParse({ + host: 'localhost', + port: 8080, + protocol: 'ui', + version: '2.0', + }) + assert.strictEqual(result.success, false) + }) + await it('should reject missing required host field', () => { const result = uiServerConfigSchema.safeParse({ port: 8080, -- 2.53.0