mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-08 03:08:45 +00:00
fix(ui): disable retries on readiness/details + cover token forwarding
Two small follow-ups on the readiness/details migration: - Set `retry: false` on the query. The payload feeds a passive navbar tag and a debug banner; a 401 from an expired token shouldn't fan out into three retries against the proxy. - Add navbar specs that assert the `accessToken` prop is forwarded into the hook (matches the DebugWarningBanner spec). Without this, the navbar could silently regress to passing `undefined` and the existing tests wouldn't catch it.
This commit is contained in:
parent
ab0267d9fd
commit
51ed234e36
2 changed files with 25 additions and 1 deletions
|
|
@ -54,5 +54,8 @@ export const useHealthReadinessDetails = (
|
|||
queryFn: () => fetchHealthReadinessDetails(accessToken!),
|
||||
enabled: Boolean(accessToken),
|
||||
staleTime: 5 * 60 * 1000,
|
||||
// The response feeds a passive navbar tag and a debug banner — a failed
|
||||
// call (e.g. expired token → 401) shouldn't fan out into three retries.
|
||||
retry: false,
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -99,12 +99,17 @@ let mockUseAuthorizedImpl = () => ({
|
|||
premiumUser: false,
|
||||
});
|
||||
|
||||
const useHealthReadinessDetailsSpy = vi.hoisted(() => vi.fn());
|
||||
|
||||
vi.mock("@/contexts/ThemeContext", () => ({
|
||||
useTheme: () => mockUseThemeImpl(),
|
||||
}));
|
||||
|
||||
vi.mock("@/app/(dashboard)/hooks/healthReadiness/useHealthReadinessDetails", () => ({
|
||||
useHealthReadinessDetails: () => mockUseHealthReadinessDetailsImpl(),
|
||||
useHealthReadinessDetails: (accessToken: string | null | undefined) => {
|
||||
useHealthReadinessDetailsSpy(accessToken);
|
||||
return mockUseHealthReadinessDetailsImpl();
|
||||
},
|
||||
}));
|
||||
|
||||
vi.mock("@/app/(dashboard)/hooks/useAuthorized", () => ({
|
||||
|
|
@ -214,6 +219,22 @@ describe("Navbar", () => {
|
|||
mockUseHealthReadinessDetailsImpl = () => ({ data: null });
|
||||
});
|
||||
|
||||
it("should forward accessToken to the readiness hook", () => {
|
||||
useHealthReadinessDetailsSpy.mockClear();
|
||||
|
||||
renderWithProviders(<Navbar {...defaultProps} accessToken="my-token" />);
|
||||
|
||||
expect(useHealthReadinessDetailsSpy).toHaveBeenCalledWith("my-token");
|
||||
});
|
||||
|
||||
it("should forward a null accessToken to the readiness hook (disables the hook)", () => {
|
||||
useHealthReadinessDetailsSpy.mockClear();
|
||||
|
||||
renderWithProviders(<Navbar {...defaultProps} accessToken={null} />);
|
||||
|
||||
expect(useHealthReadinessDetailsSpy).toHaveBeenCalledWith(null);
|
||||
});
|
||||
|
||||
it("should use custom logo from theme context", () => {
|
||||
mockUseThemeImpl = () => ({ logoUrl: "https://example.com/custom-logo.png" });
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue