From a45fc07dae6daf1844a8e2b809da33c77f1f939c Mon Sep 17 00:00:00 2001 From: Ishaan Jaffer Date: Mon, 26 Jan 2026 17:30:58 -0800 Subject: [PATCH] UI fixes unit tests --- .../vector_store_management/DocumentsTable.test.tsx | 8 ++++---- .../TestVectorStoreTab.test.tsx | 3 ++- .../VectorStoreTable.test.tsx | 12 ++++++------ 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/ui/litellm-dashboard/src/components/vector_store_management/DocumentsTable.test.tsx b/ui/litellm-dashboard/src/components/vector_store_management/DocumentsTable.test.tsx index 053c7efa623..761bc2b7df7 100644 --- a/ui/litellm-dashboard/src/components/vector_store_management/DocumentsTable.test.tsx +++ b/ui/litellm-dashboard/src/components/vector_store_management/DocumentsTable.test.tsx @@ -70,7 +70,7 @@ describe("DocumentsTable", () => { const onRemove = vi.fn(); render(); - const deleteButtons = screen.getAllByLabelText(/remove/i); + const deleteButtons = screen.getAllByLabelText(/delete/i); act(() => { fireEvent.click(deleteButtons[0]); @@ -91,9 +91,9 @@ describe("DocumentsTable", () => { render(); // Each document should have 3 action buttons (view, copy, delete) - const viewButtons = screen.getAllByLabelText(/view details/i); - const copyButtons = screen.getAllByLabelText(/copy id/i); - const deleteButtons = screen.getAllByLabelText(/remove/i); + const viewButtons = screen.getAllByLabelText(/eye/i); + const copyButtons = screen.getAllByLabelText(/copy/i); + const deleteButtons = screen.getAllByLabelText(/delete/i); expect(viewButtons).toHaveLength(3); expect(copyButtons).toHaveLength(3); diff --git a/ui/litellm-dashboard/src/components/vector_store_management/TestVectorStoreTab.test.tsx b/ui/litellm-dashboard/src/components/vector_store_management/TestVectorStoreTab.test.tsx index 541754fe2ad..ad6ef02e87b 100644 --- a/ui/litellm-dashboard/src/components/vector_store_management/TestVectorStoreTab.test.tsx +++ b/ui/litellm-dashboard/src/components/vector_store_management/TestVectorStoreTab.test.tsx @@ -83,7 +83,8 @@ describe("TestVectorStoreTab", () => { const selectElement = screen.getByRole("combobox"); fireEvent.mouseDown(selectElement); - expect(screen.getByText("Test Store 1")).toBeInTheDocument(); + // Use getAllByText since the selected value also shows the name + expect(screen.getAllByText("Test Store 1").length).toBeGreaterThan(0); expect(screen.getByText("Test Store 2")).toBeInTheDocument(); }); }); diff --git a/ui/litellm-dashboard/src/components/vector_store_management/VectorStoreTable.test.tsx b/ui/litellm-dashboard/src/components/vector_store_management/VectorStoreTable.test.tsx index 65d15260c4c..0e2be7f62df 100644 --- a/ui/litellm-dashboard/src/components/vector_store_management/VectorStoreTable.test.tsx +++ b/ui/litellm-dashboard/src/components/vector_store_management/VectorStoreTable.test.tsx @@ -130,9 +130,9 @@ describe("VectorStoreTable", () => { expect(screen.getByText("Provider")).toBeInTheDocument(); expect(screen.getByText("Created At")).toBeInTheDocument(); expect(screen.getByText("Updated At")).toBeInTheDocument(); - // Check that we have the expected number of header cells (6 data + 1 actions) + // Check that we have the expected number of header cells (7 data + 1 actions) const headers = screen.getAllByRole("columnheader"); - expect(headers).toHaveLength(7); + expect(headers).toHaveLength(8); }); it("should render all vector store rows", () => { @@ -183,7 +183,7 @@ describe("VectorStoreTable", () => { it("should render fallback for missing name", () => { renderComponent(); const fallbackElements = screen.getAllByText("-"); - expect(fallbackElements.length).toBe(2); // One for missing name, one for missing description + expect(fallbackElements.length).toBe(3); // One for missing name, one for missing description, one for missing files }); it("should wrap name in tooltip", () => { @@ -203,7 +203,7 @@ describe("VectorStoreTable", () => { it("should render fallback for missing description", () => { renderComponent(); const fallbackElements = screen.getAllByText("-"); - expect(fallbackElements.length).toBe(2); // One for missing name, one for missing description + expect(fallbackElements.length).toBe(3); // One for missing name, one for missing description, one for missing files }); it("should wrap description in tooltip", () => { @@ -386,7 +386,7 @@ describe("VectorStoreTable", () => { it("should span all columns in empty state", () => { renderComponent({ data: [] }); const emptyCell = screen.getByText("No vector stores found").closest("td"); - expect(emptyCell).toHaveAttribute("colSpan", "7"); // 6 data columns + 1 actions column + expect(emptyCell).toHaveAttribute("colSpan", "8"); // 7 data columns + 1 actions column }); }); @@ -403,7 +403,7 @@ describe("VectorStoreTable", () => { renderComponent({ data: minimalData }); expect(screen.getByText("minimal")).toBeInTheDocument(); - expect(screen.getAllByText("-")).toHaveLength(2); // Name and description fallbacks + expect(screen.getAllByText("-")).toHaveLength(3); // Name, description, and files fallbacks }); it("should handle single vector store", () => {