Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

test(ui): pin the clock in the per-user export filename test

yuneng49126d44344e
diff --git a/ui/litellm-dashboard/src/components/EntityUsageExport/utils.test.ts b/ui/litellm-dashboard/src/components/EntityUsageExport/utils.test.ts
index b8f36d57c85..3f9cf58ec20 100644
--- a/ui/litellm-dashboard/src/components/EntityUsageExport/utils.test.ts
+++ b/ui/litellm-dashboard/src/components/EntityUsageExport/utils.test.ts
@@ -2234,12 +2234,13 @@ describe("EntityUsageExport utils", () => {
it("should generate the daily_with_users filename and include User ID in the rows", () => {
const anchorElement = document.createElement("a");
vi.spyOn(document, "createElement").mockReturnValue(anchorElement);
-
- const today = new Date().toISOString().split("T")[0];
+ vi.useFakeTimers();
+ vi.setSystemTime(new Date("2025-03-01T12:00:00Z"));
handleExportCSV(usersFixture, "daily_with_users", "Team", "team", mockTeamAliasMap);
+ vi.useRealTimers();
- expect(anchorElement.download).toBe(`team_usage_daily_with_users_${today}.csv`);
+ expect(anchorElement.download).toBe("team_usage_daily_with_users_2025-03-01.csv");
const unparsedRows = vi.mocked(Papa.unparse).mock.calls[0][0] as Record<string, unknown>[];
expect(unparsedRows[0]).toHaveProperty("User ID");