Files
OmniRoute/tests/unit/pricing-constants-split.test.ts
Diego Rodrigues de Sa e Souza 78f09c8d9f Release v3.8.41 (#5327)
Release v3.8.41 — 52 commits since v3.8.40 (19 CHANGELOG bullets, 11 contributors).

All gating CI green: Unit×8, Coverage×8, Vitest, Package Artifact, Quality Ratchet, CodeQL, Lint, Docs Sync (Strict), Node 24/26 compat, E2E×9, Integration, Electron smoke.

Advisory checks overridden (main unprotected): PR Test Policy = test-masking heuristic on the cumulative 52-commit assert delta (legitimate dead-code-sweep removals + consolidations, reviewed per-PR); SonarCloud/SonarQube = new-code maintainability/coverage quality gate (CodeQL/Semgrep/Security/npm-audit/Dependabot all clean — not a security finding).
2026-06-29 16:51:03 -03:00

52 lines
2.2 KiB
TypeScript

// Characterization of the pricing.ts split (god-file decomposition): the host became a barrel that
// re-exports DEFAULT_PRICING (now merged from 4 semantic family files that import shared tier consts)
// and keeps the helper functions. Pure-data move → behavior identical. Locks: public surface, the
// spread-merge integrity, and that lookups/cost math resolve unchanged.
import { test } from "node:test";
import assert from "node:assert/strict";
const P = await import("../../src/shared/constants/pricing.ts");
test("barrel still exports DEFAULT_PRICING + supported helpers", () => {
for (const name of ["DEFAULT_PRICING", "getPricingForModel", "getDefaultPricing"]) {
assert.ok(name in P, `missing export: ${name}`);
}
assert.equal(Object.hasOwn(P, "calculateCostFromTokens"), false);
});
test("DEFAULT_PRICING merges the 4 family files; families partition all entries", async () => {
const merged = Object.keys((P as Record<string, object>).DEFAULT_PRICING).length;
const families: [string, string][] = [
["oauth-subscriptions", "DEFAULT_PRICING_OAUTH"],
["frontier-labs", "DEFAULT_PRICING_FRONTIER"],
["inference-hosts", "DEFAULT_PRICING_INFERENCE"],
["regional", "DEFAULT_PRICING_REGIONAL"],
];
let famTotal = 0;
const seen = new Set<string>();
for (const [file, exportName] of families) {
const mod = await import(`../../src/shared/constants/pricing/${file}.ts`);
for (const k of Object.keys(mod[exportName])) {
assert.ok(!seen.has(k), `pricing key ${k} appears in more than one family`);
seen.add(k);
famTotal++;
}
}
assert.equal(merged, famTotal, "spread-merge lost/duplicated a top-level key");
assert.ok(merged > 25);
});
test("shared tier consts feed the parts (a known model resolves to a shared rate)", () => {
const pricing = (P as Record<string, (p: string, m: string) => unknown>).getPricingForModel(
"openai",
"gpt-4o"
);
assert.ok(pricing && typeof pricing === "object");
assert.equal(typeof (pricing as { input?: number }).input, "number");
});
test("formatCost remains re-exported from the pricing barrel", () => {
const fn = (P as Record<string, (value: number) => string>).formatCost;
assert.equal(fn(0.0123), "$0.0123");
});