mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-24 16:12:23 +03:00
Validated on the combined 12-PR batch board: focused node:test suites green (incl. provider-rate-limit-overrides-schema + ratelimit-admission-control-6593 isolated 11/11 + the new EditConnectionModal vitest 3/3), typecheck:core clean, all static gates within baseline. Pushed one follow-up commit to your branch with the real Vietnamese translations for the two new keys (repo convention: vi never ships __MISSING__ placeholders). Per-connection maxWaitMs override lands, folding the zai-web exception into the general mechanism. Thank you @maxmad64bis!
35 lines
1.4 KiB
TypeScript
35 lines
1.4 KiB
TypeScript
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import {
|
|
sanitizeRateLimitOverrides,
|
|
sanitizeQuotaWindowThresholds,
|
|
} from "@/lib/db/providers/columns";
|
|
|
|
test("sanitizeRateLimitOverrides surfaces rejected keys (blocking, not silent)", () => {
|
|
const r = sanitizeRateLimitOverrides({ rpm: 10, foo: 1, tpm: -1 });
|
|
assert.deepEqual(r.sanitized, { rpm: 10 });
|
|
assert.deepEqual(r.rejected.sort(), ["foo", "tpm"]);
|
|
});
|
|
|
|
test("sanitizeQuotaWindowThresholds surfaces key-too-long and out-of-range", () => {
|
|
const r = sanitizeQuotaWindowThresholds({ ["a".repeat(65)]: 50, win: 101 });
|
|
assert.ok(r.rejected.length >= 1);
|
|
assert.ok(r.rejected.includes("win"));
|
|
});
|
|
|
|
test("valid input yields no rejected keys", () => {
|
|
const r = sanitizeRateLimitOverrides({ rpm: 10, tpm: 20 });
|
|
assert.deepEqual(r.rejected, []);
|
|
assert.deepEqual(r.sanitized, { rpm: 10, tpm: 20 });
|
|
});
|
|
|
|
// #11251 added `maxWaitMs` to the Zod validation schema and the
|
|
// EditConnectionModal UI, but not to this separate allowlist — saving the
|
|
// field from the dashboard threw "Refusing to persist rateLimitOverrides
|
|
// with rejected keys: maxWaitMs" (500) on every attempt.
|
|
test("sanitizeRateLimitOverrides accepts maxWaitMs (#11251 follow-up)", () => {
|
|
const r = sanitizeRateLimitOverrides({ minTime: 500, maxWaitMs: 30000 });
|
|
assert.deepEqual(r.rejected, []);
|
|
assert.deepEqual(r.sanitized, { minTime: 500, maxWaitMs: 30000 });
|
|
});
|