mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-23 15:42:12 +03:00
Validated on the combined batch board over tip 8a42aeeb: static gates clean (changelog, file-size 159 frozen, complexity 2621<=2774, cognitive 1181<=1223, dead-code 408<=416), typecheck:core clean, 107 focused tests green.
This drains the remaining #9985 tail — the v2 dual-write assertions (guide-settings/t40), the zai→z-ai stale id, the hackclub leftovers, and the #11162 cli-combo models (#11203). Note: guide-settings also trips this devbox's container guard (/.dockerenv present), an environment artifact unrelated to CI. Base is green again. Thank you @jonlwheat2-gif!
This commit is contained in:
@@ -37,7 +37,11 @@ async function withComboEnv(fn: (dataDir: string) => Promise<void>) {
|
||||
test("combo create inserts a new combo via db module", async () => {
|
||||
await withComboEnv(async () => {
|
||||
const { runComboCreateCommand } = await import("../../bin/cli/commands/combo.mjs");
|
||||
const result = await runComboCreateCommand("my-combo", "priority", {});
|
||||
// #11162: combo create refuses combos without any model — pass a model
|
||||
// like the sibling tests updated in that commit.
|
||||
const result = await runComboCreateCommand("my-combo", "priority", {
|
||||
models: ["openai/gpt-4o-mini"],
|
||||
});
|
||||
assert.equal(result, 0);
|
||||
|
||||
// Verify via the same db module
|
||||
@@ -53,10 +57,12 @@ test("combo create fails if combo already exists", async () => {
|
||||
await withComboEnv(async () => {
|
||||
const { runComboCreateCommand } = await import("../../bin/cli/commands/combo.mjs");
|
||||
|
||||
await runComboCreateCommand("dup-combo", "auto", {});
|
||||
await runComboCreateCommand("dup-combo", "auto", { models: ["openai/gpt-4o-mini"] });
|
||||
const originalError = console.error;
|
||||
console.error = () => {};
|
||||
const result = await runComboCreateCommand("dup-combo", "auto", {});
|
||||
const result = await runComboCreateCommand("dup-combo", "auto", {
|
||||
models: ["openai/gpt-4o-mini"],
|
||||
});
|
||||
console.error = originalError;
|
||||
|
||||
assert.equal(result, 1);
|
||||
@@ -68,7 +74,7 @@ test("combo delete removes the combo", async () => {
|
||||
const { runComboCreateCommand, runComboDeleteCommand } =
|
||||
await import("../../bin/cli/commands/combo.mjs");
|
||||
|
||||
await runComboCreateCommand("to-delete", "weighted", {});
|
||||
await runComboCreateCommand("to-delete", "weighted", { models: ["openai/gpt-4o-mini"] });
|
||||
const result = await runComboDeleteCommand("to-delete", { yes: true });
|
||||
assert.equal(result, 0);
|
||||
|
||||
@@ -91,7 +97,7 @@ test("combo switch updates active combo when server is offline", async () => {
|
||||
const { runComboCreateCommand, runComboSwitchCommand } =
|
||||
await import("../../bin/cli/commands/combo.mjs");
|
||||
|
||||
await runComboCreateCommand("my-switch", "round-robin", {});
|
||||
await runComboCreateCommand("my-switch", "round-robin", { models: ["openai/gpt-4o-mini"] });
|
||||
const result = await runComboSwitchCommand("my-switch", {});
|
||||
assert.equal(result, 0);
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ test("ClinePass fallback is the official subscription-only catalog", () => {
|
||||
test("Cline fallback owns recommended/free models and excludes the ClinePass namespace", () => {
|
||||
const ids = providerRegistry.cline.models.map((model: { id: string }) => model.id);
|
||||
assert.deepEqual(ids, [
|
||||
"zai/glm-5.2",
|
||||
"z-ai/glm-5.2",
|
||||
"x-ai/grok-4.5",
|
||||
"openai/gpt-5.6-sol",
|
||||
"moonshotai/kimi-k3",
|
||||
|
||||
@@ -127,7 +127,11 @@ test("guide-settings POST writes OpenCode config with current schema and multi-m
|
||||
"cc/claude-sonnet-4-20250514",
|
||||
"gg/gemini-2.5-pro",
|
||||
]);
|
||||
assert.equal(content.providers, undefined);
|
||||
// The v2 provider schema is dual-written alongside the v1 block: the v2
|
||||
// entry lives under `providers.omniroute` with `package`/`settings`.
|
||||
assert.equal(content.providers.omniroute.package, "@opencode-ai/ai/providers/openai-compatible");
|
||||
assert.equal(content.providers.omniroute.settings.baseURL, "http://my-omni/v1");
|
||||
assert.ok(content.providers.omniroute.settings.apiKey.startsWith("sk-"));
|
||||
});
|
||||
|
||||
test("guide-settings POST preserves existing OpenCode config fields while only updating provider.omniroute", async () => {
|
||||
|
||||
@@ -47,21 +47,18 @@ test("primary providers keep the short alias; web variants use their own id", ()
|
||||
assert.equal(PROVIDER_ID_TO_ALIAS["qwen-web"], "qwen-web");
|
||||
assert.equal(PROVIDER_ID_TO_ALIAS.kimi, "kimi");
|
||||
assert.equal(PROVIDER_ID_TO_ALIAS["kimi-web"], "kimi-web");
|
||||
assert.equal(PROVIDER_ID_TO_ALIAS.hackclub, "hc");
|
||||
assert.equal(PROVIDER_ID_TO_ALIAS.huggingchat, "huggingchat");
|
||||
});
|
||||
|
||||
test("src/shared providers map resolves the same aliases unambiguously", () => {
|
||||
// alias → id
|
||||
assert.equal(resolveProviderId("kimi"), "kimi");
|
||||
assert.equal(resolveProviderId("hc"), "hackclub");
|
||||
// id used as alias for the secondary variants
|
||||
assert.equal(resolveProviderId("qwen-web"), "qwen-web");
|
||||
assert.equal(resolveProviderId("kimi-web"), "kimi-web");
|
||||
assert.equal(resolveProviderId("huggingchat"), "huggingchat");
|
||||
// id → alias
|
||||
assert.equal(getProviderAlias("kimi"), "kimi");
|
||||
assert.equal(getProviderAlias("hackclub"), "hc");
|
||||
});
|
||||
|
||||
// #6673: hailuo-web must not collide with the paid API-key minimax/minimax-cn
|
||||
|
||||
@@ -110,7 +110,11 @@ test("T40: OpenCode config document uses current provider schema", () => {
|
||||
configDocument.provider.omniroute.models["gg/gemini-2.5-pro"].name,
|
||||
"Gemini 2.5 Pro"
|
||||
);
|
||||
assert.equal(configDocument.providers, undefined);
|
||||
// v2 provider schema is dual-written alongside the v1 block.
|
||||
assert.equal(
|
||||
configDocument.providers.omniroute.package,
|
||||
"@opencode-ai/ai/providers/openai-compatible"
|
||||
);
|
||||
});
|
||||
|
||||
test("T40: OpenCode explicit multi-model selection overrides fallback defaults", () => {
|
||||
|
||||
Reference in New Issue
Block a user