mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-03 02:22:24 +00:00
test(ui): update team metadata schema tests for fixed labels
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
74bc75001b
commit
3089f2acc6
2 changed files with 22 additions and 28 deletions
|
|
@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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(() => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue