mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-25 16:42:16 +03:00
Drain the unit-shard reds the 2026-08-23 merge wave left on release/v3.8.50, each discriminated as stale-test (contract moved intentionally, test aligned) vs real bug (fixed in code/messages): 1. check-deps 6A.8 allowlist — #11224 added @testing-library/dom and @testing-library/user-event to package.json without the gate allowlist. Both are legitimate: @testing-library/dom is a required peer of @testing-library/react v16, and user-event is the official companion for UI tests. Fix: allowlist entries with a justification note referencing #11224/#9985. 2. search-route 400-vs-fallback — #11097 intentionally changed the zero-credential /v1/search contract: instead of returning 400 it promotes the fallback-only duckduckgo-free provider so out-of-the-box search works. The test pinned the OLD 400 contract. Fix (contract alignment): the test now pins the new fallback contract — 200, provider duckduckgo-free, DuckDuckGo lite endpoint called, results parsed from lite HTML. 3. codex catalog token limits (4 named reds + 2 sibling sweeps) — #11179 raised GPT_5_6_CODEX_CAPABILITIES from the 272K pricing tier to the real usable 872K window (live evidence: 390K served past 272K with HTTP 200) and updated codex-gpt56-catalog.test.ts but missed the sibling pins. Stale tests aligned: models-catalog-combo- metadata (max_input_tokens now clamps to min(872000, 500000 override) = 500000), vscode-token-routes x3 (872000), and two more found in the sibling sweep: vscode-token-routes-gpt56 and provider-models-route- codex (conservative merge semantics unchanged: pinned 872000 < live 999999 still wins). 4. CLI catalog counts (3 reds) — #11166 added prime-agent (agent category) without the cardinality pins: EXPECTED_AGENT_COUNT 8->9, total 34->35, D15 agent list + prime-agent, cli-tools-schema id list. Also added the missing English/Vietnamese cliTools descriptions for prime-agent (cli-catalog-display-contract) and corrected the stale CLI-TOOLS.md agent count (8->9). 5. setup-qwen container guard — since #10057 the container guard exits 2 on ephemeral runtimes; the two tests exercising the merge/write path were environment-sensitive (red on container devboxes). Fix: pass allowContainerWrite so the tests are hermetic everywhere; the guard keeps its own dedicated coverage. 6. i18n health verdict namespace (real bug, fixed in messages) — #11224 added the verdict/diagnostics strings to the `sidebar` namespace but health/page.tsx reads them via useTranslations("health"), so the page rendered raw keys in every locale and the "direct translation calls have English messages" gate went red. Fix: keys moved sidebar->health in en.json + vi.json (the only locales that had them), plus health.healthSubtitle added. The sidebar never referenced them (verified: no usage), and sidebar.healthSubtitle (its real sidebar key) is untouched. 7. i18n pt-BR drift (22 keys) — the 08-23 wave (#11224/#11228/#11215/ #11204/#11195) added English keys never translated: common.batch*, endpoint.*, cliCommon.concept.acp.warning, resilienceConnections.*, plus the moved health.* keys and the prime-agent cliTools description. Fix: pt-BR translations added — 0 missing keys vs en; vi strict parity re-verified (0 missing, 0 extra). Validation: every touched test file RED->GREEN individually (node --import tsx/esm --test), typecheck:core clean, docs-counts-sync soft-pass, cli-i18n gate PASS, 8/8 unit shards re-run on the branch. Refs #9985
91 lines
3.1 KiB
TypeScript
91 lines
3.1 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import fs from "node:fs/promises";
|
|
import os from "node:os";
|
|
import path from "node:path";
|
|
|
|
import { resolveQwenTarget, runSetupQwenCommand } from "../../../bin/cli/commands/setup-qwen.mjs";
|
|
|
|
test("resolveQwenTarget normalizes a remote endpoint to the OpenAI /v1 base", () => {
|
|
assert.deepEqual(resolveQwenTarget({ remote: "https://omni.example/", apiKey: "sk-explicit" }), {
|
|
baseUrl: "https://omni.example/v1",
|
|
apiKey: "sk-explicit",
|
|
});
|
|
});
|
|
|
|
test("setup-qwen writes current V4 settings and only its dedicated env key", async () => {
|
|
const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), "omniroute-setup-qwen-"));
|
|
const settingsPath = path.join(tempDir, "settings.json");
|
|
const envPath = path.join(tempDir, ".env");
|
|
await fs.writeFile(
|
|
settingsPath,
|
|
JSON.stringify({
|
|
ui: { theme: "dark" },
|
|
modelProviders: {
|
|
openai: [
|
|
{
|
|
id: "personal",
|
|
envKey: "OPENAI_API_KEY",
|
|
baseUrl: "https://api.openai.com/v1",
|
|
},
|
|
],
|
|
},
|
|
})
|
|
);
|
|
await fs.writeFile(envPath, "OPENAI_API_KEY=keep-me\n");
|
|
|
|
try {
|
|
const code = await runSetupQwenCommand({
|
|
remote: "http://router:20128",
|
|
apiKey: "sk-qwen-dedicated",
|
|
model: "qwen/qwen3.8-max-preview",
|
|
configPath: settingsPath,
|
|
envPath,
|
|
yes: true,
|
|
// These tests exercise the merge/write logic, not the container guard
|
|
// (#10057) — keep them hermetic on container devboxes/CI.
|
|
allowContainerWrite: true,
|
|
});
|
|
assert.equal(code, 0);
|
|
|
|
const settings = JSON.parse(await fs.readFile(settingsPath, "utf8"));
|
|
assert.equal(settings.ui.theme, "dark");
|
|
assert.equal(Array.isArray(settings.modelProviders.openai), true);
|
|
assert.equal(settings.modelProviders.openai.length, 2);
|
|
assert.deepEqual(settings.modelProviders.openai[1], {
|
|
id: "qwen/qwen3.8-max-preview",
|
|
name: "qwen/qwen3.8-max-preview (OmniRoute)",
|
|
envKey: "OMNIROUTE_API_KEY",
|
|
baseUrl: "http://router:20128/v1",
|
|
});
|
|
assert.equal(JSON.stringify(settings).includes("sk-qwen-dedicated"), false);
|
|
|
|
const env = await fs.readFile(envPath, "utf8");
|
|
assert.match(env, /^OPENAI_API_KEY=keep-me$/m);
|
|
assert.match(env, /^OMNIROUTE_API_KEY="sk-qwen-dedicated"$/m);
|
|
} finally {
|
|
await fs.rm(tempDir, { recursive: true, force: true });
|
|
}
|
|
});
|
|
|
|
test("setup-qwen does not overwrite an invalid settings file", async () => {
|
|
const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), "omniroute-setup-qwen-bad-"));
|
|
const settingsPath = path.join(tempDir, "settings.json");
|
|
await fs.writeFile(settingsPath, "{ invalid JSON");
|
|
|
|
try {
|
|
const code = await runSetupQwenCommand({
|
|
remote: "http://router:20128",
|
|
model: "model-id",
|
|
configPath: settingsPath,
|
|
yes: true,
|
|
// See above — hermetic regardless of container detection (#10057).
|
|
allowContainerWrite: true,
|
|
});
|
|
assert.equal(code, 1);
|
|
assert.equal(await fs.readFile(settingsPath, "utf8"), "{ invalid JSON");
|
|
} finally {
|
|
await fs.rm(tempDir, { recursive: true, force: true });
|
|
}
|
|
});
|