From 30141f86f824cdc53e425a4b27fe07e34cc61c64 Mon Sep 17 00:00:00 2001 From: ryan-crabbe-berri Date: Tue, 30 Jun 2026 11:40:09 -0700 Subject: [PATCH] test(ui): make router settings save tests resilient to async timing Address Greptile P2: the routing_groups test read setCallbacksCall.mock.calls[0][1] immediately after the now-async save handler, so any latency in the mock would throw an opaque TypeError instead of a clean assertion failure. Assert through toHaveBeenCalledWith inside waitFor with expect.not.objectContaining, dropping the index access and the cast. Also drop the ticket id from the test names. --- .../src/components/router_settings/index.test.tsx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 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 0df1cd81d6b..94cbb94d164 100644 --- a/ui/litellm-dashboard/src/components/router_settings/index.test.tsx +++ b/ui/litellm-dashboard/src/components/router_settings/index.test.tsx @@ -147,7 +147,7 @@ describe("RouterSettings", () => { expect(NotificationsManager.success).toHaveBeenCalledWith("router settings updated successfully"); }); - it("should not render or save routing_groups (owned by the Routing Groups tab) (LIT-4057)", async () => { + it("should not render or save routing_groups (owned by the Routing Groups tab)", async () => { const user = userEvent.setup(); vi.mocked(getCallbacksCall).mockResolvedValue({ router_settings: { @@ -165,13 +165,14 @@ describe("RouterSettings", () => { await user.click(screen.getByRole("button", { name: /save changes/i })); - const payload = vi.mocked(setCallbacksCall).mock.calls[0][1] as { - router_settings: Record; - }; - expect(payload.router_settings).not.toHaveProperty("routing_groups"); + await waitFor(() => + expect(setCallbacksCall).toHaveBeenCalledWith("test-token", { + router_settings: expect.not.objectContaining({ routing_groups: expect.anything() }), + }), + ); }); - it("should surface an error and not claim success when saving fails (LIT-4057)", async () => { + it("should surface an error and not claim success when saving fails", async () => { const user = userEvent.setup(); vi.mocked(setCallbacksCall).mockRejectedValue(new Error("422 Unprocessable Entity")); renderWithProviders();