Files
OmniRoute/tests/unit/auto-combos-enhanced-4235.test.ts
Diego Rodrigues de Sa e Souza 3c9883bb73 Release v3.8.29 (#4126)
OmniRoute v3.8.29 — 115 commits since v3.8.28. Full CHANGELOG + 41 i18n mirrors. All content quality gates green (build, unit 8/8, vitest 188/188, PR test policy, quality gates extended, docs sync, quality ratchet). Remaining red CI checks are pre-existing release flakes (coverage-shard/integration/node-compat teardown), a new transitive undici advisory in electron devDeps, and a workflow-level CodeQL fail (0 open alerts). VPS-validated by the operator.
2026-06-19 06:49:01 -03:00

64 lines
2.3 KiB
TypeScript

/**
* #4235 — Enhanced `auto/*` combos.
*
* Phase A: the README advertises `auto/cheap`, `auto/offline`, `auto/smart`
* (and they already resolve via parseAutoPrefix → createVirtualAutoCombo), but
* they were missing from AUTO_TEMPLATE_VARIANTS, so `/v1/models` and the
* dashboard never listed them — the catalog/UI drifted from the README.
*
* Later phases (suffix parser `auto/<category>:<tier>`, new categories, `:pro`)
* extend the assertions below.
*/
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-4235-"));
process.env.DATA_DIR = TEST_DATA_DIR;
process.env.API_KEY_SECRET = process.env.API_KEY_SECRET || "auto-4235-test-secret";
const core = await import("../../src/lib/db/core.ts");
const builtinCatalog = await import("../../open-sse/services/autoCombo/builtinCatalog.ts");
function resetStorage() {
core.resetDbInstance();
fs.rmSync(TEST_DATA_DIR, { recursive: true, force: true });
fs.mkdirSync(TEST_DATA_DIR, { recursive: true });
}
test.beforeEach(() => {
resetStorage();
});
test.after(() => {
core.resetDbInstance();
fs.rmSync(TEST_DATA_DIR, { recursive: true, force: true });
});
test("#4235 Phase A: README-advertised cheap/offline/smart are in the built-in catalog", () => {
const ids = Object.keys(builtinCatalog.AUTO_TEMPLATE_VARIANTS);
for (const id of ["auto/cheap", "auto/offline", "auto/smart"]) {
assert.ok(
ids.includes(id),
`expected ${id} in AUTO_TEMPLATE_VARIANTS (advertised in /v1/models)`
);
}
});
test("#4235 Phase A: cheap/offline/smart map to their scoring variant", () => {
assert.equal(builtinCatalog.AUTO_TEMPLATE_VARIANTS["auto/cheap"], "cheap");
assert.equal(builtinCatalog.AUTO_TEMPLATE_VARIANTS["auto/offline"], "offline");
assert.equal(builtinCatalog.AUTO_TEMPLATE_VARIANTS["auto/smart"], "smart");
});
test("#4235 Phase A: each new entry materializes into a virtual auto-combo", async () => {
for (const id of ["auto/cheap", "auto/offline", "auto/smart"]) {
const suffix = id.slice("auto/".length);
const combo = await builtinCatalog.createBuiltinAutoCombo(id, suffix);
assert.equal(combo.id, id, `${id} combo id`);
assert.equal(combo.strategy, "auto", `${id} uses the auto strategy`);
}
});