From 26e5482abb352b16dd57444705a6e44ef206d3d8 Mon Sep 17 00:00:00 2001 From: yuneng-jiang Date: Tue, 24 Feb 2026 15:52:15 -0800 Subject: [PATCH] address greptile review feedback (greploop iteration 2) - Wait for strategy select (API data loaded) before clicking Save - Assert specific payload content in setCallbacksCall - Move NotificationsManager import to top of file --- .../components/router_settings/index.test.tsx | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/ui/litellm-dashboard/src/components/router_settings/index.test.tsx b/ui/litellm-dashboard/src/components/router_settings/index.test.tsx index 1920268207d..8edb0ac6e07 100644 --- a/ui/litellm-dashboard/src/components/router_settings/index.test.tsx +++ b/ui/litellm-dashboard/src/components/router_settings/index.test.tsx @@ -48,6 +48,7 @@ import { getRouterSettingsCall, setCallbacksCall, } from "@/components/networking"; +import NotificationsManager from "@/components/molecules/notifications_manager"; const mockCallbacksResponse = { router_settings: { @@ -141,29 +142,34 @@ describe("RouterSettings", () => { const user = userEvent.setup(); renderWithProviders(); + // Wait for the strategy select to appear — it only renders after getRouterSettingsCall resolves await waitFor(() => { - expect(screen.getByRole("button", { name: /save changes/i })).toBeInTheDocument(); + expect(screen.getByTestId("strategy-select")).toBeInTheDocument(); }); await user.click(screen.getByRole("button", { name: /save changes/i })); expect(setCallbacksCall).toHaveBeenCalledWith( "test-token", - expect.objectContaining({ router_settings: expect.any(Object) }) + expect.objectContaining({ + router_settings: expect.objectContaining({ + routing_strategy: "simple-shuffle", + }), + }) ); }); it("should show a success notification after saving", async () => { - const NotificationsManager = await import("@/components/molecules/notifications_manager"); const user = userEvent.setup(); renderWithProviders(); - await waitFor(() => - expect(screen.getByRole("button", { name: /save changes/i })).toBeInTheDocument() - ); + // Wait for data to load before interacting + await waitFor(() => { + expect(screen.getByTestId("strategy-select")).toBeInTheDocument(); + }); await user.click(screen.getByRole("button", { name: /save changes/i })); - expect(NotificationsManager.default.success).toHaveBeenCalledWith( + expect(NotificationsManager.success).toHaveBeenCalledWith( "router settings updated successfully" ); });