OmniRoute/tests/unit/provider-cost-data.test.ts
Dizzle 1b98484d20
fix(routing): trace estimated pricing and latency fallbacks (#15224)
Validated in a combined board on the current release tip: focused node:test + vitest suites, typecheck:core, open-sse typecheck, gate-manifest, mutation-test-coverage, file-size, changelog-integrity, complexity, env-doc-sync, test-discovery, vitest-exclusions, error-helper, cli-i18n and the i18n new-keys/ui-coverage gates green. Thank you for the contribution.
2026-10-06 12:20:54 -03:00

51 lines
1.5 KiB
TypeScript

import assert from "node:assert/strict";
import test from "node:test";
import { getModelPricing, KNOWN_MODEL_PRICING } from "../../open-sse/services/providerCostData.ts";
test("provider-specific pricing wins over a generic model fallback", () => {
const genericKey = "provider-price-test-model";
const providerKey = `devin-cli/${genericKey}`;
const previousGeneric = KNOWN_MODEL_PRICING[genericKey];
const previousProvider = KNOWN_MODEL_PRICING[providerKey];
KNOWN_MODEL_PRICING[genericKey] = {
inputCostPer1M: 9,
outputCostPer1M: 90,
isFree: false,
};
KNOWN_MODEL_PRICING[providerKey] = {
inputCostPer1M: 1,
outputCostPer1M: 10,
isFree: false,
};
try {
assert.deepEqual(getModelPricing("devin-cli", genericKey), {
inputCostPer1M: 1,
outputCostPer1M: 10,
isFree: false,
isEstimated: false,
});
} finally {
if (previousGeneric) KNOWN_MODEL_PRICING[genericKey] = previousGeneric;
else delete KNOWN_MODEL_PRICING[genericKey];
if (previousProvider) KNOWN_MODEL_PRICING[providerKey] = previousProvider;
else delete KNOWN_MODEL_PRICING[providerKey];
}
});
test("tier pricing reads the exact Devin provider/model rate", () => {
assert.deepEqual(getModelPricing("devin-cli", "gpt-5-6-luna-max"), {
inputCostPer1M: 0.2,
outputCostPer1M: 1.2,
isFree: false,
isEstimated: false,
});
assert.deepEqual(getModelPricing("devin-cli", "gpt-5-6-luna-max-priority"), {
inputCostPer1M: 0.4,
outputCostPer1M: 2.4,
isFree: false,
isEstimated: false,
});
});