diff --git a/ui/litellm-dashboard/src/components/Navbar/BlogDropdown/__tests__/BlogDropdown.test.tsx b/ui/litellm-dashboard/src/components/Navbar/BlogDropdown/BlogDropdown.test.tsx similarity index 92% rename from ui/litellm-dashboard/src/components/Navbar/BlogDropdown/__tests__/BlogDropdown.test.tsx rename to ui/litellm-dashboard/src/components/Navbar/BlogDropdown/BlogDropdown.test.tsx index 6f448e5b60b..fa1baa311d4 100644 --- a/ui/litellm-dashboard/src/components/Navbar/BlogDropdown/__tests__/BlogDropdown.test.tsx +++ b/ui/litellm-dashboard/src/components/Navbar/BlogDropdown/BlogDropdown.test.tsx @@ -2,7 +2,7 @@ import React from "react"; import { render, screen, fireEvent, waitFor } from "@testing-library/react"; import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; import { describe, it, expect, vi, beforeEach } from "vitest"; -import { BlogDropdown } from "../BlogDropdown"; +import { BlogDropdown } from "./BlogDropdown"; import { useDisableShowBlog } from "@/app/(dashboard)/hooks/useDisableShowBlog"; // Mock hooks @@ -33,7 +33,7 @@ const SAMPLE_POSTS = { function createWrapper() { const queryClient = new QueryClient({ - defaultOptions: { queries: { retry: false } }, + defaultOptions: { queries: { retry: false, retryDelay: 0 } }, }); return ({ children }: { children: React.ReactNode }) => ( {children} @@ -96,7 +96,10 @@ describe("BlogDropdown", () => { }); it("shows error message and Retry button on fetch failure", async () => { - global.fetch = vi.fn().mockRejectedValueOnce(new Error("Network error")); + global.fetch = vi + .fn() + .mockRejectedValueOnce(new Error("Network error")) + .mockRejectedValueOnce(new Error("Network error")); render(, { wrapper: createWrapper() }); fireEvent.click(screen.getByText("Blog")); @@ -111,6 +114,7 @@ describe("BlogDropdown", () => { global.fetch = vi .fn() .mockRejectedValueOnce(new Error("Network error")) + .mockRejectedValueOnce(new Error("Network error")) .mockResolvedValueOnce({ ok: true, json: async () => SAMPLE_POSTS }); render(, { wrapper: createWrapper() }); diff --git a/ui/litellm-dashboard/src/components/Navbar/BlogDropdown/BlogDropdown.tsx b/ui/litellm-dashboard/src/components/Navbar/BlogDropdown/BlogDropdown.tsx index 022ebb1e68c..20cfe99ae44 100644 --- a/ui/litellm-dashboard/src/components/Navbar/BlogDropdown/BlogDropdown.tsx +++ b/ui/litellm-dashboard/src/components/Navbar/BlogDropdown/BlogDropdown.tsx @@ -47,6 +47,9 @@ export const BlogDropdown: React.FC = () => { queryKey: ["blogPosts"], queryFn: fetchBlogPosts, staleTime: 60 * 60 * 1000, // 1 hour — matches server-side TTL + retry: 1, + retryDelay: 0, + enabled: !disableShowBlog, }); if (disableShowBlog) { @@ -77,9 +80,9 @@ export const BlogDropdown: React.FC = () => { return (
- {data.posts.slice(0, 5).map((post, index) => ( + {data.posts.slice(0, 5).map((post) => (