mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-10 03:28:53 +00:00
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.
This commit is contained in:
parent
9968499aab
commit
30141f86f8
1 changed files with 7 additions and 6 deletions
|
|
@ -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<string, unknown>;
|
||||
};
|
||||
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(<RouterSettings {...defaultProps} />);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue