mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-09 03:18:44 +00:00
Merge 8905ca8a8d into e768ad55ce
This commit is contained in:
commit
f7a7aa4215
2 changed files with 34 additions and 3 deletions
|
|
@ -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");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue