From b48440d995b5a67d8ff1ff1f13b2ee10cc18f524 Mon Sep 17 00:00:00 2001 From: yuneng-jiang Date: Tue, 24 Mar 2026 09:27:29 -0700 Subject: [PATCH] address greptile review feedback (greploop iteration 5) - Fix P1: add test for enterprise user error banner code path (confirms error banner only shows after successful license fetch) Co-Authored-By: Claude Opus 4.6 (1M context) --- .../components/LicenseExpiryBanner.test.tsx | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/ui/litellm-dashboard/src/components/LicenseExpiryBanner.test.tsx b/ui/litellm-dashboard/src/components/LicenseExpiryBanner.test.tsx index e9def76f9cd..d83229946ee 100644 --- a/ui/litellm-dashboard/src/components/LicenseExpiryBanner.test.tsx +++ b/ui/litellm-dashboard/src/components/LicenseExpiryBanner.test.tsx @@ -187,6 +187,42 @@ describe("LicenseExpiryBanner", () => { }); }); + it("should show error banner when fetch fails for a confirmed enterprise user", async () => { + // First call succeeds (confirms enterprise), then component re-renders + // with fetchError after a subsequent failure. + // Simulate by resolving first, then rejecting on next call. + mockGetLicenseInfo + .mockResolvedValueOnce(makeLicense("2026-03-20")) + .mockRejectedValueOnce(new Error("Network error")); + + const { rerender } = render(); + + // First render shows the warning banner (license within 14 days) + expect( + await screen.findByText(/Enterprise License Expiring/i) + ).toBeInTheDocument(); + + // Force a re-render that triggers a new fetch (simulating accessToken change) + mockUseAuthorized.mockReturnValue({ + accessToken: "new-token", + isLoading: false, + isAuthorized: true, + token: "tok", + userId: "u1", + userEmail: "u@e.com", + userRole: "proxy_admin", + premiumUser: true, + disabledPersonalKeyCreation: null, + showSSOBanner: false, + } as any); + + rerender(); + + expect( + await screen.findByText("Unable to verify enterprise license") + ).toBeInTheDocument(); + }); + it("should render nothing when expiration_date is unparseable", async () => { mockGetLicenseInfo.mockResolvedValue(makeLicense("N/A"));