This commit is contained in:
SeongWoon Cho 2026-10-03 08:12:39 -04:00 • committed by GitHub
commit f7a7aa4215
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 34 additions and 3 deletions

View file

@ -0,0 +1,29 @@
import { describe, expect, it } from "vitest";
import { BUDGET_WINDOW_OPTIONS } from "./BudgetWindowsEditor";
const hintFor = (value: string): string => {
const option = BUDGET_WINDOW_OPTIONS.find((o) => o.value === value);
if (!option) throw new Error(`no budget window option for ${value}`);
return option.resetHint;
};
describe("BUDGET_WINDOW_OPTIONS reset hints", () => {
it("describes the weekly window as resetting on Monday, matching the backend", () => {
expect(hintFor("7d")).toContain("Monday");
expect(hintFor("7d")).not.toContain("Sunday");
});
it("does not claim a fixed UTC reset, since the backend honors the configured timezone", () => {
for (const option of BUDGET_WINDOW_OPTIONS) {
expect(option.resetHint).not.toContain("midnight UTC");
}
});
it("points at litellm_settings.timezone and its UTC default for every window that resets at a time of day", () => {
for (const value of ["24h", "7d", "30d"]) {
expect(hintFor(value)).toContain("litellm_settings.timezone");
expect(hintFor(value)).toContain("defaults to UTC");
}
});
});

View file

@ -8,11 +8,13 @@ export interface BudgetWindowEntry {
max_budget: number | null;
}
const RESET_TIMEZONE_NOTE = "in the proxy timezone (litellm_settings.timezone, defaults to UTC)";
export const BUDGET_WINDOW_OPTIONS = [
{ value: "1h", label: "Hourly", resetHint: "Resets every hour" },
{ value: "24h", label: "Daily", resetHint: "Resets daily at midnight UTC" },
{ value: "7d", label: "Weekly", resetHint: "Resets every Sunday at midnight UTC" },
{ value: "30d", label: "Monthly", resetHint: "Resets on the 1st of every month at midnight UTC" },
{ value: "24h", label: "Daily", resetHint: `Resets daily at midnight ${RESET_TIMEZONE_NOTE}` },
{ value: "7d", label: "Weekly", resetHint: `Resets every Monday at midnight ${RESET_TIMEZONE_NOTE}` },
{ value: "30d", label: "Monthly", resetHint: `Resets on the 1st of each month at midnight ${RESET_TIMEZONE_NOTE}` },
];
interface BudgetWindowsEditorProps {