mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-02 21:32:10 +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
101 lines
4.8 KiB
TypeScript
101 lines
4.8 KiB
TypeScript
// Characterization of the providers.ts catalog split (god-file decomposition): the host became a
|
|
// barrel that re-exports 10 data catalogs now living under constants/providers/*, and APIKEY is
|
|
// merged from 6 semantic family files (apikey/<family>.ts). Locks: the public surface (every catalog
|
|
// + helpers still exported), the spread-merge integrity (195 APIKEY entries, no loss/dup), and that
|
|
// load-time Zod validation still runs. Pure-data move → behavior must be identical.
|
|
// Count was 171 before obsolete provider removals (PR #6675: glhf/kluster/cablyai/inclusionai etc.,
|
|
// 171->167) plus #6126 (ClinePass dual-auth): the API-key-only APIKEY_PROVIDERS_GATEWAYS entry was
|
|
// removed as a duplicate now that clinepass is OAuth-primary (OAUTH_PROVIDERS.clinepass) with its
|
|
// BYOK path admitted through the DUAL_AUTH_APIKEY_PROVIDER_IDS gate instead (167->166), then the
|
|
// OpenVecta inference-gateway addition brought it back to 167, then #7246 (Chenzk API gateway)
|
|
// brought it to 168, then more additions brought it to 172, then #6650 (g4f.space no-key gateway:
|
|
// 5 new sub-path entries — g4f-groq/g4f-gemini/g4f-pollinations/g4f-ollama/g4f-nvidia) brought it
|
|
// to 177, then 2 more provider additions in the v3.8.49 cycle brought it to 179, the free-catalog
|
|
// expansion (#7840, navy) to 180, the Alibaba/Qwen Cloud regional additions (#7882) to 182, and
|
|
// #7887 (5 free-tier providers: ainative/aion/sealion/routeway/nara) to 187, then #8077 (clova-studio/
|
|
// internlm/ant-ling, all regional) to 190, then #8161 (sarvam/writer/plamo — writer in frontier-labs,
|
|
// sarvam+plamo in regional) to 193, then #8170 (inception/typhoon — inception in frontier-labs,
|
|
// typhoon in regional) to 195.
|
|
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
const P = await import("../../src/shared/constants/providers.ts");
|
|
|
|
test("barrel still exports every catalog + key helpers", () => {
|
|
for (const name of [
|
|
"NOAUTH_PROVIDERS",
|
|
"OAUTH_PROVIDERS",
|
|
"WEB_COOKIE_PROVIDERS",
|
|
"APIKEY_PROVIDERS",
|
|
"LOCAL_PROVIDERS",
|
|
"SEARCH_PROVIDERS",
|
|
"AUDIO_ONLY_PROVIDERS",
|
|
"UPSTREAM_PROXY_PROVIDERS",
|
|
"CLOUD_AGENT_PROVIDERS",
|
|
"SYSTEM_PROVIDERS",
|
|
"AI_PROVIDERS",
|
|
"ALIAS_TO_ID",
|
|
"ID_TO_ALIAS",
|
|
"getProviderById",
|
|
"getProviderByAlias",
|
|
"resolveProviderId",
|
|
]) {
|
|
assert.ok(name in P, `missing export: ${name}`);
|
|
}
|
|
});
|
|
|
|
test("APIKEY_PROVIDERS merges the 6 family files into 195 entries (no loss / no dup)", async () => {
|
|
const keys = Object.keys((P as Record<string, object>).APIKEY_PROVIDERS);
|
|
assert.equal(keys.length, 195);
|
|
assert.equal(new Set(keys).size, 195, "duplicate keys after spread-merge");
|
|
// the merged object's entry-count equals the sum of the 6 semantic family files; families are a
|
|
// strict partition (every provider in exactly one), so the sum must be exactly 195.
|
|
const families: [string, string][] = [
|
|
["gateways", "APIKEY_PROVIDERS_GATEWAYS"],
|
|
["frontier-labs", "APIKEY_PROVIDERS_FRONTIER"],
|
|
["inference-hosts", "APIKEY_PROVIDERS_INFERENCE"],
|
|
["enterprise-cloud", "APIKEY_PROVIDERS_ENTERPRISE"],
|
|
["regional", "APIKEY_PROVIDERS_REGIONAL"],
|
|
["specialty-media", "APIKEY_PROVIDERS_SPECIALTY"],
|
|
];
|
|
let famTotal = 0;
|
|
const seen = new Set<string>();
|
|
for (const [file, exportName] of families) {
|
|
const mod = await import(`../../src/shared/constants/providers/apikey/${file}.ts`);
|
|
const famKeys = Object.keys(mod[exportName]);
|
|
famTotal += famKeys.length;
|
|
for (const k of famKeys) {
|
|
assert.ok(!seen.has(k), `provider ${k} appears in more than one family`);
|
|
seen.add(k);
|
|
}
|
|
}
|
|
assert.equal(famTotal, 195, "families must partition all 195 providers");
|
|
});
|
|
|
|
test("AI_PROVIDERS Proxy aggregates all sections; lookups resolve", () => {
|
|
const ai = (P as Record<string, Record<string, unknown>>).AI_PROVIDERS;
|
|
assert.ok(Object.keys(ai).length > 200);
|
|
assert.ok((P as Record<string, (id: string) => unknown>).getProviderById("openai"));
|
|
assert.ok((P as Record<string, (id: string) => unknown>).getProviderById("claude"));
|
|
// a moved catalog is reachable through the barrel re-export
|
|
assert.ok((P as Record<string, Record<string, unknown>>).APIKEY_PROVIDERS["openai"]);
|
|
});
|
|
|
|
test("each extracted data module is importable on its own", async () => {
|
|
const mods = [
|
|
["noauth", "NOAUTH_PROVIDERS"],
|
|
["oauth", "OAUTH_PROVIDERS"],
|
|
["web-cookie", "WEB_COOKIE_PROVIDERS"],
|
|
["local", "LOCAL_PROVIDERS"],
|
|
["search", "SEARCH_PROVIDERS"],
|
|
["audio", "AUDIO_ONLY_PROVIDERS"],
|
|
["upstream-proxy", "UPSTREAM_PROXY_PROVIDERS"],
|
|
["cloud-agent", "CLOUD_AGENT_PROVIDERS"],
|
|
["system", "SYSTEM_PROVIDERS"],
|
|
];
|
|
for (const [file, name] of mods) {
|
|
const m = await import(`../../src/shared/constants/providers/${file}.ts`);
|
|
assert.ok(m[name] && typeof m[name] === "object", `${file}.ts must export ${name}`);
|
|
}
|
|
});
|