mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-02 13:22:11 +03:00
* test: realign catalog snapshot tests to current deliberate catalog state Six catalog/snapshot tests drifted behind deliberate catalog changes that were already validated by newer sibling tests. No production code touched; every change aligns a stale snapshot to behavior already validated by newer sibling tests. Root causes (all confirmed against the current code before editing): - tests/unit/providers-constants-split.test.ts: APIKEY_PROVIDERS grew from 187 to 195 entries via #8077 (clova-studio/internlm/ant-ling, regional), #8161 (sarvam/plamo → regional, writer → frontier-labs) and #8170 (typhoon → regional, inception → frontier-labs). Family counts verified to sum to 195 (gateways 60, frontier-labs 24, inference-hosts 28, enterprise-cloud 17, regional 40, specialty-media 26) with no duplicates. Updated the two assertions and extended the changelog comment. - tests/unit/qianfan-provider.test.ts: the expected Baidu Qianfan website URL was the pre-#8128 wenxinworkshop path. #8128/#6271 moved it to https://cloud.baidu.com/product-s/qianfan_home, already locked by the sibling regression test tests/unit/baidu-qianfan-website-urls-6271.test.ts. - tests/unit/t31-t33-t34-t38-model-specs.test.ts and tests/unit/auto-combo-credentialed-model-pool.test.ts: the Antigravity catalog refactor (#8013) retired gemini-3-pro-preview/claude-sonnet-5 and renamed the Gemini 3.5 Flash tiers (low/medium/high -> extra-low/low/gemini-3-flash-agent), confirmed against ANTIGRAVITY_PUBLIC_MODELS and tests/unit/antigravity-retired-public-models.test.ts. Swapped the retired IDs for currently-registered ones (gemini-3.6-flash-high, claude-sonnet-4-6, gemini-3-flash-agent, gemini-3.5-flash-low/extra-low) and moved the wildcard-exclusion prefix test from the now-2-tier "gemini-3.5-*" group to "gemini-3.6-*", which has 3 real tiers today (same >=3 semantics, just pointed at a prefix that still has 3 members). - tests/unit/model-alias-seed.test.ts: getModelInfo("gemini-3.1-pro") now canonicalizes through ALIAS_TO_PROVIDER_ID["agy"] = "antigravity" (#8050), the same pattern already applied to opencode -> opencode-zen. Updated the expected provider id. - tests/unit/video-dashscope.test.ts (deleted, 216 lines): #8266 reorganized the Alibaba video catalog so the flat wan2.7-t2v id no longer exists under the plain "alibaba" provider (only the dated wan2.7-t2v-2026-06-12 does); the flat id now lives only under "qwen-cloud". All 6 tests in the file failed because they built requests against alibaba/wan2.7-t2v, which the new allowlist now rejects with 400 ("unsupported alibaba video model") - verified directly against VIDEO_PROVIDERS in open-sse/config/videoRegistry.ts. Coverage already exists and was confirmed passing pre-deletion in tests/unit/alibaba-video-media.test.ts (including an explicit "Alibaba rejects video models outside its own allowlist" case for this exact id) and tests/unit/qwen-cloud-video-media.test.ts (covers the same id under qwen-cloud). Note: the deleted file's DashScope upstream error-path assertions (401 missing credentials, 502 missing task_id, 502 FAILED status, 504 poll timeout) don't have a byte-for-byte equivalent in the two replacement files, though the shared dashscopeHandler.ts code path they exercise remains covered by several sibling *-media.test.ts files for the happy path and local validation. - tests/unit/authz/spawn-capable-prefixes-client-safe.test.ts: #7892 added /api/vnc-session to the SPAWN_CAPABLE_PREFIXES deny-list (Hard Rules #15/#17 hardening). Bumped the expected length 10 -> 11 and added the entry to the test's named list for documentation. Refs #8013, #8050, #8266, #7892, #8128 * chore(quality): allowlist the video-dashscope.test.ts deletion with its replacements check:test-masking (pr-test-policy CI gate) requires a _deletedWithReplacement entry for any deleted test file, even when the deletion is a verified-legitimate supersession. Documents the same #8266 rationale from the prior commit in the machine-checked allowlist so the deletion is not flagged as unexplained masking. Refs #8266
134 lines
5.2 KiB
TypeScript
134 lines
5.2 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import fs from "node:fs";
|
|
import os from "node:os";
|
|
import path from "node:path";
|
|
|
|
const TEST_DATA_DIR = fs.mkdtempSync(path.join(os.tmpdir(), "omniroute-alias-seed-"));
|
|
process.env.DATA_DIR = TEST_DATA_DIR;
|
|
|
|
const core = await import("../../src/lib/db/core.ts");
|
|
const modelsDb = await import("../../src/lib/db/models.ts");
|
|
const sseModelService = await import("../../src/sse/services/model.ts");
|
|
const { DEFAULT_MODEL_ALIAS_SEED, seedDefaultModelAliases } =
|
|
await import("../../src/lib/modelAliasSeed.ts");
|
|
|
|
async function resetStorage() {
|
|
core.resetDbInstance();
|
|
fs.rmSync(TEST_DATA_DIR, { recursive: true, force: true });
|
|
fs.mkdirSync(TEST_DATA_DIR, { recursive: true });
|
|
}
|
|
|
|
test.beforeEach(async () => {
|
|
await resetStorage();
|
|
});
|
|
|
|
test.after(async () => {
|
|
core.resetDbInstance();
|
|
fs.rmSync(TEST_DATA_DIR, { recursive: true, force: true });
|
|
});
|
|
|
|
test("default model alias seed writes missing aliases and is idempotent", async () => {
|
|
const first = await seedDefaultModelAliases();
|
|
const aliases = await modelsDb.getModelAliases();
|
|
|
|
assert.deepEqual(first.failed, []);
|
|
assert.equal(first.applied.length, Object.keys(DEFAULT_MODEL_ALIAS_SEED).length);
|
|
assert.equal(aliases["gemini-3.1-pro"], "agy/gemini-pro-agent");
|
|
assert.equal(aliases["gemini-3-pro-high"], undefined);
|
|
assert.equal(aliases["gemini-3-pro-low"], undefined);
|
|
assert.equal(aliases["gemini-3-pro-preview"], undefined);
|
|
assert.equal(aliases["gemini-3.1-pro-preview"], undefined);
|
|
assert.equal(aliases["gemini-3-flash-preview"], undefined);
|
|
|
|
const routed = await sseModelService.getModelInfo("gemini-3.1-pro");
|
|
assert.deepEqual(routed, {
|
|
provider: "antigravity",
|
|
model: "gemini-pro-agent",
|
|
extendedContext: false,
|
|
});
|
|
|
|
const second = await seedDefaultModelAliases();
|
|
assert.equal(second.applied.length, 0);
|
|
assert.equal(second.failed.length, 0);
|
|
assert.equal(second.skipped.length, Object.keys(DEFAULT_MODEL_ALIAS_SEED).length);
|
|
});
|
|
|
|
test("default model alias seed preserves existing aliases and skips invalid entries", async () => {
|
|
await modelsDb.setModelAlias("gemini-3.1-pro", "custom/canonical-model");
|
|
await modelsDb.setModelAlias("gemini-3-pro-low", "custom/legacy-model");
|
|
|
|
const warnings = [];
|
|
const result = await seedDefaultModelAliases({
|
|
logger: {
|
|
warn: (message) => warnings.push(String(message)),
|
|
},
|
|
seedMap: {
|
|
...DEFAULT_MODEL_ALIAS_SEED,
|
|
"broken-entry": null,
|
|
},
|
|
});
|
|
const aliases = await modelsDb.getModelAliases();
|
|
|
|
assert.equal(aliases["gemini-3.1-pro"], "custom/canonical-model");
|
|
assert.equal(aliases["gemini-3-pro-low"], "custom/legacy-model");
|
|
assert.ok(result.skipped.includes("gemini-3.1-pro"));
|
|
assert.equal(result.removed.includes("gemini-3-pro-low"), false);
|
|
assert.ok(result.failed.includes("broken-entry"));
|
|
assert.ok(warnings.some((message) => message.includes("broken-entry")));
|
|
});
|
|
|
|
test("default model alias seed replaces superseded Gemini Pro aliases with 3.1 Pro", async () => {
|
|
await modelsDb.setModelAlias("gemini-3-pro-high", "agy/gemini-3.1-pro-high");
|
|
await modelsDb.setModelAlias("gemini-3-pro-low", "agy/gemini-3.1-pro-low");
|
|
await modelsDb.setModelAlias("gemini-3-pro-preview", "agy/gemini-pro-agent");
|
|
await modelsDb.setModelAlias("gemini-3.1-pro-preview", "agy/gemini-pro-agent");
|
|
|
|
const result = await seedDefaultModelAliases();
|
|
const aliases = await modelsDb.getModelAliases();
|
|
|
|
assert.deepEqual(result.removed.sort(), [
|
|
"gemini-3-pro-high",
|
|
"gemini-3-pro-low",
|
|
"gemini-3-pro-preview",
|
|
"gemini-3.1-pro-preview",
|
|
]);
|
|
assert.ok(result.applied.includes("gemini-3.1-pro"));
|
|
assert.equal(aliases["gemini-3.1-pro"], "agy/gemini-pro-agent");
|
|
assert.equal(aliases["gemini-3-pro-high"], undefined);
|
|
assert.equal(aliases["gemini-3-pro-low"], undefined);
|
|
assert.equal(aliases["gemini-3-pro-preview"], undefined);
|
|
assert.equal(aliases["gemini-3.1-pro-preview"], undefined);
|
|
});
|
|
|
|
test("default model alias seed removes the short-lived Pro High alias", async () => {
|
|
await modelsDb.setModelAlias("gemini-3-pro-high", "agy/gemini-pro-agent");
|
|
|
|
const result = await seedDefaultModelAliases();
|
|
const aliases = await modelsDb.getModelAliases();
|
|
|
|
assert.ok(result.removed.includes("gemini-3-pro-high"));
|
|
assert.equal(aliases["gemini-3-pro-high"], undefined);
|
|
assert.equal(aliases["gemini-3.1-pro"], "agy/gemini-pro-agent");
|
|
});
|
|
|
|
test("default model alias seed removes the retired Gemini Flash default alias", async () => {
|
|
await modelsDb.setModelAlias("gemini-3-flash-preview", "agy/gemini-3.5-flash-medium");
|
|
|
|
const result = await seedDefaultModelAliases();
|
|
const aliases = await modelsDb.getModelAliases();
|
|
|
|
assert.deepEqual(result.removed, ["gemini-3-flash-preview"]);
|
|
assert.equal(aliases["gemini-3-flash-preview"], undefined);
|
|
});
|
|
|
|
test("default model alias seed preserves a customized retired alias", async () => {
|
|
await modelsDb.setModelAlias("gemini-3-flash-preview", "custom/provider-model");
|
|
|
|
const result = await seedDefaultModelAliases();
|
|
const aliases = await modelsDb.getModelAliases();
|
|
|
|
assert.deepEqual(result.removed, []);
|
|
assert.equal(aliases["gemini-3-flash-preview"], "custom/provider-model");
|
|
});
|