Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

test(ui): cover a negative policy attachment priority typed keystroke by keystroke

yucheng8164189237bb
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/policies/_components/add_attachment_form.test.tsx b/ui/litellm-dashboard/src/app/(dashboard)/policies/_components/add_attachment_form.test.tsx
index d635872ad81..dfc023d428e 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/policies/_components/add_attachment_form.test.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/policies/_components/add_attachment_form.test.tsx
@@ -210,6 +210,23 @@ describe("AddAttachmentForm", () => {
});
});
+ it("sends a negative priority typed one keystroke at a time", async () => {
+ const user = userEvent.setup();
+ const createAttachment = vi.fn().mockResolvedValue({});
+ renderWithProviders(<AddAttachmentForm {...defaultProps} createAttachment={createAttachment} />);
+ await selectPolicy(user, "policy-alpha");
+ const priority = screen.getByLabelText("Priority");
+ await user.type(priority, "-5");
+ expect(priority).toHaveValue(-5);
+ await submit(user);
+ await waitFor(() => expect(createAttachment).toHaveBeenCalledTimes(1));
+ expect(createAttachment).toHaveBeenCalledWith("test-token", {
+ policy_name: "policy-alpha",
+ scope: "*",
+ priority: -5,
+ });
+ });
+
it("omits priority from the attachment when the field is left blank", async () => {
const user = userEvent.setup();
const createAttachment = vi.fn().mockResolvedValue({});