mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-31 20:32:20 +03:00
- tests/unit/custom-cli-config.test.ts: fix ERR_MODULE_NOT_FOUND — stale import path cli-tools → cli-code (regression from F8 git mv, missed by F10 audit because it only ran curated test subset).
- tests/unit/ui/CliAgentsPage.test.tsx: update vi.mock path to current cli-code location (was no-op mock pointing to deleted path).
- tests/unit/ui/CliToolCard.test.tsx: update URL strings /dashboard/cli-tools/claude → /dashboard/cli-code/claude (cosmetic alignment with new routes).
- src/app/(dashboard)/dashboard/cli-code/components/ToolDetailClient.tsx: remove dead case "cliproxyapi" + unused import (no entry in CLI_TOOLS catalog).
- src/app/(dashboard)/dashboard/cli-agents/CliAgentsPageClient.tsx: replace inline div skeleton with shared <CardSkeleton /> for visual consistency with CliCodePageClient.
- src/app/api/cli-tools/{forge,jcode,deepseek-tui,smelt,pi}-settings/route.ts: replace catch (err: any) with catch (err) + (err as NodeJS.ErrnoException).code narrowing (8 instances, eliminates 8 of 11 implicit-any introductions).
Validated: custom-cli-config.test.ts now 3/3 PASS (was 0/1 FAIL with ERR_MODULE_NOT_FOUND); F1/F3 tests 147/147 PASS; UI tests 25/25 PASS; typecheck:core + noimplicit clean.
66 lines
2.2 KiB
TypeScript
66 lines
2.2 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
import {
|
|
buildAliasEnvVar,
|
|
buildCustomCliEnvScript,
|
|
buildCustomCliJsonConfig,
|
|
normalizeOpenAiBaseUrl,
|
|
} from "../../src/app/(dashboard)/dashboard/cli-code/components/customCliConfig.ts";
|
|
|
|
test("normalizeOpenAiBaseUrl appends /v1 only when needed", () => {
|
|
assert.equal(normalizeOpenAiBaseUrl("http://localhost:20128"), "http://localhost:20128/v1");
|
|
assert.equal(
|
|
normalizeOpenAiBaseUrl("https://example.com/proxy/v1"),
|
|
"https://example.com/proxy/v1"
|
|
);
|
|
});
|
|
|
|
test("buildAliasEnvVar sanitizes aliases for env variable export", () => {
|
|
assert.equal(buildAliasEnvVar("review"), "OMNIROUTE_MODEL_REVIEW");
|
|
assert.equal(buildAliasEnvVar("plan mode"), "OMNIROUTE_MODEL_PLAN_MODE");
|
|
assert.equal(buildAliasEnvVar(""), null);
|
|
});
|
|
|
|
test("custom CLI generators include default model and alias mappings", () => {
|
|
const envScript = buildCustomCliEnvScript({
|
|
cliName: "My Team CLI",
|
|
baseUrl: "http://localhost:20128",
|
|
apiKey: "sk_test_123",
|
|
defaultModel: "omniroute/fast",
|
|
aliasMappings: [
|
|
{ alias: "review", model: "cc/claude-sonnet-4-5-20250929" },
|
|
{ alias: "vision", model: "gemini/gemini-3-flash" },
|
|
],
|
|
});
|
|
|
|
assert.match(envScript, /export OPENAI_BASE_URL="http:\/\/localhost:20128\/v1"/);
|
|
assert.match(envScript, /export OPENAI_MODEL="omniroute\/fast"/);
|
|
assert.match(envScript, /export OMNIROUTE_MODEL_REVIEW="cc\/claude-sonnet-4-5-20250929"/);
|
|
assert.match(envScript, /# http:\/\/localhost:20128\/v1\/chat\/completions/);
|
|
assert.match(envScript, /my-team-cli --base-url "\$OPENAI_BASE_URL"/);
|
|
|
|
const jsonConfig = JSON.parse(
|
|
buildCustomCliJsonConfig({
|
|
cliName: "My Team CLI",
|
|
baseUrl: "http://localhost:20128",
|
|
apiKey: "sk_test_123",
|
|
defaultModel: "omniroute/fast",
|
|
aliasMappings: [{ alias: "review", model: "cc/claude-sonnet-4-5-20250929" }],
|
|
})
|
|
);
|
|
|
|
assert.deepEqual(jsonConfig, {
|
|
name: "My Team CLI",
|
|
provider: {
|
|
type: "openai",
|
|
baseURL: "http://localhost:20128/v1",
|
|
apiKey: "sk_test_123",
|
|
model: "omniroute/fast",
|
|
},
|
|
modelAliases: {
|
|
review: "cc/claude-sonnet-4-5-20250929",
|
|
},
|
|
});
|
|
});
|