mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-09 03:18:44 +00:00
Key Already Exist Error Notification (#15993)
This commit is contained in:
parent
a3d64fb843
commit
43af45ab88
2 changed files with 43 additions and 1 deletions
|
|
@ -0,0 +1,41 @@
|
|||
import { describe, it, expect, beforeEach, vi } from "vitest";
|
||||
import { notification } from "antd";
|
||||
import NotificationManager from "./notifications_manager";
|
||||
|
||||
// Mock the antd notification module
|
||||
vi.mock("antd", () => ({
|
||||
notification: {
|
||||
error: vi.fn(),
|
||||
warning: vi.fn(),
|
||||
info: vi.fn(),
|
||||
success: vi.fn(),
|
||||
destroy: vi.fn(),
|
||||
},
|
||||
}));
|
||||
|
||||
describe("NotificationManager", () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
describe("Already Exists case", () => {
|
||||
it("should show error notification for 'already exists' message", () => {
|
||||
const error = {
|
||||
message: "Key with alias 'test10' already exists.",
|
||||
type: "bad_request_error",
|
||||
code: "400",
|
||||
};
|
||||
|
||||
NotificationManager.fromBackend(error);
|
||||
|
||||
expect(notification.error).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
message: "Already Exists",
|
||||
description: "Key with alias 'test10' already exists.",
|
||||
duration: 6,
|
||||
placement: "topRight",
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -317,7 +317,8 @@ const NotificationManager = {
|
|||
title === "Authentication Error" ||
|
||||
title === "Access Denied" ||
|
||||
title === "Not Found" ||
|
||||
title === "Error"
|
||||
title === "Error" ||
|
||||
title === "Already Exists"
|
||||
) {
|
||||
notification.error({ ...payload, duration: extra?.duration ?? 6 });
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue