From 3089f2acc66d0a61f96ee296830ad5812007755c Mon Sep 17 00:00:00 2001 From: jesus Date: Wed, 16 Sep 2026 19:52:32 +0000 Subject: [PATCH] test(ui): update team metadata schema tests for fixed labels Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- .../src/components/Teams.test.tsx | 32 +++++++------------ .../src/components/team/TeamInfo.test.tsx | 18 ++++++----- 2 files changed, 22 insertions(+), 28 deletions(-) diff --git a/ui/litellm-dashboard/src/components/Teams.test.tsx b/ui/litellm-dashboard/src/components/Teams.test.tsx index 851c9e6d487..303587f4e70 100644 --- a/ui/litellm-dashboard/src/components/Teams.test.tsx +++ b/ui/litellm-dashboard/src/components/Teams.test.tsx @@ -902,16 +902,16 @@ describe("Teams - schema-declared metadata fields in team create", () => { }); }; - it("should prepopulate the declared key as an ordinary pair row and submit its value", async () => { + it("should show the declared key as a fixed label and submit its value under the declared key", async () => { await openCreateModal(); fireEvent.change(screen.getByLabelText(/team name/i), { target: { value: "Test Team" } }); fireEvent.change(screen.getByTestId("create-team-models-select"), { target: { value: "gpt-4" } }); - await waitFor(() => { - expect((screen.getByPlaceholderText("Key") as HTMLInputElement).value).toBe("cost_center"); - }); - fireEvent.change(screen.getByPlaceholderText("Value"), { target: { value: "CC-1001" } }); + expect(await screen.findByTestId("metadata-schema-label")).toHaveTextContent("Cost Center"); + expect(screen.queryByPlaceholderText("Key")).not.toBeInTheDocument(); + expect(screen.queryByLabelText("Remove key-value pair")).not.toBeInTheDocument(); + fireEvent.change(screen.getByLabelText("Cost Center"), { target: { value: "CC-1001" } }); const createTeamSubmitButtons = screen.getAllByRole("button", { name: /create team/i }); fireEvent.click(createTeamSubmitButtons[createTeamSubmitButtons.length - 1]); @@ -932,10 +932,7 @@ describe("Teams - schema-declared metadata fields in team create", () => { fireEvent.change(screen.getByLabelText(/team name/i), { target: { value: "Test Team" } }); fireEvent.change(screen.getByTestId("create-team-models-select"), { target: { value: "gpt-4" } }); - await waitFor(() => { - expect((screen.getByPlaceholderText("Key") as HTMLInputElement).value).toBe("cost_center"); - }); - fireEvent.change(screen.getByPlaceholderText("Value"), { target: { value: "CC-9999" } }); + fireEvent.change(await screen.findByLabelText("Cost Center"), { target: { value: "CC-9999" } }); const createTeamSubmitButtons = screen.getAllByRole("button", { name: /create team/i }); fireEvent.click(createTeamSubmitButtons[createTeamSubmitButtons.length - 1]); @@ -955,16 +952,12 @@ describe("Teams - schema-declared metadata fields in team create", () => { expect(screen.queryByRole("button", { name: /add key-value pair/i })).not.toBeInTheDocument(); }); - it("should re-seed declared keys when the create modal is closed and reopened", async () => { + it("should re-seed the declared key and drop free-form rows when the create modal is closed and reopened", async () => { await openCreateModal(); - await waitFor(() => { - expect((screen.getByPlaceholderText("Key") as HTMLInputElement).value).toBe("cost_center"); - }); - fireEvent.click(screen.getByLabelText("Remove key-value pair")); - await waitFor(() => { - expect(screen.queryByPlaceholderText("Key")).not.toBeInTheDocument(); - }); + fireEvent.change(await screen.findByLabelText("Cost Center"), { target: { value: "CC-1001" } }); + fireEvent.click(screen.getByRole("button", { name: /add key-value pair/i })); + fireEvent.change(await screen.findByPlaceholderText("Key"), { target: { value: "region" } }); fireEvent.click(screen.getByRole("button", { name: /^close$/i })); await waitFor(() => { @@ -976,9 +969,8 @@ describe("Teams - schema-declared metadata fields in team create", () => { fireEvent.click(createButton); }); - await waitFor(() => { - expect((screen.getByPlaceholderText("Key") as HTMLInputElement).value).toBe("cost_center"); - }); + expect(await screen.findByLabelText("Cost Center")).toHaveValue(""); + expect(screen.queryByPlaceholderText("Key")).not.toBeInTheDocument(); }); }); diff --git a/ui/litellm-dashboard/src/components/team/TeamInfo.test.tsx b/ui/litellm-dashboard/src/components/team/TeamInfo.test.tsx index eb912ffa3cc..e9671acfaef 100644 --- a/ui/litellm-dashboard/src/components/team/TeamInfo.test.tsx +++ b/ui/litellm-dashboard/src/components/team/TeamInfo.test.tsx @@ -1380,7 +1380,7 @@ describe("TeamInfoView", () => { expect(screen.getByLabelText("Estimated Output Tokens Per Model")).toBeEnabled(); }); - it("should keep declared keys as ordinary prefilled rows and submit the edited value", async () => { + it("should show declared keys as fixed labels and submit the edited value", async () => { const user = userEvent.setup({ delay: null }); vi.mocked(useTeamMetadataSchema).mockReturnValue({ data: [ @@ -1401,16 +1401,18 @@ describe("TeamInfoView", () => { await openSettingsEditor(user); await waitFor(() => { - expect(screen.getAllByPlaceholderText("Key").map((input) => (input as HTMLInputElement).value)).toEqual([ - "cost_center", - "department", - "app_name", + expect(screen.getAllByTestId("metadata-schema-label").map((label) => label.textContent)).toEqual([ + "Cost Center", + "Application Name", ]); }); - expect(screen.getAllByPlaceholderText("Value")[0]).toHaveValue("CC-OLD"); + expect(screen.getAllByPlaceholderText("Key").map((input) => (input as HTMLInputElement).value)).toEqual([ + "department", + ]); + expect(screen.getByLabelText("Cost Center")).toHaveValue("CC-OLD"); - await user.clear(screen.getAllByPlaceholderText("Value")[0]); - fireEvent.change(screen.getAllByPlaceholderText("Value")[0], { target: { value: "CC-NEW" } }); + await user.clear(screen.getByLabelText("Cost Center")); + fireEvent.change(screen.getByLabelText("Cost Center"), { target: { value: "CC-NEW" } }); await user.click(screen.getByRole("button", { name: /save changes/i })); await waitFor(() => {