mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-07 07:58:09 +00:00
test(ui): characterize shared migration surfaces
This commit is contained in:
parent
0e9da56f89
commit
c6b559f414
2 changed files with 83 additions and 0 deletions
|
|
@ -0,0 +1,34 @@
|
|||
import userEvent from "@testing-library/user-event";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { renderWithProviders, screen } from "../../../tests/test-utils";
|
||||
import { fetchSearchTools } from "../networking";
|
||||
import SearchToolSelector from "./SearchToolSelector";
|
||||
|
||||
vi.mock("../networking", () => ({
|
||||
fetchSearchTools: vi.fn(),
|
||||
}));
|
||||
|
||||
describe("SearchToolSelector", () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
vi.mocked(fetchSearchTools).mockResolvedValue({
|
||||
search_tools: [{ search_tool_name: "search-one" }, { search_tool_name: "search-two" }],
|
||||
});
|
||||
});
|
||||
|
||||
it("should render", () => {
|
||||
renderWithProviders(<SearchToolSelector accessToken="" onChange={vi.fn()} />);
|
||||
|
||||
expect(screen.getByRole("combobox")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("should load and display available search tools", async () => {
|
||||
const user = userEvent.setup();
|
||||
renderWithProviders(<SearchToolSelector accessToken="token" onChange={vi.fn()} />);
|
||||
|
||||
await user.click(screen.getByRole("combobox"));
|
||||
|
||||
expect(await screen.findByRole("option", { name: "search-one" })).toBeInTheDocument();
|
||||
expect(screen.getByRole("option", { name: "search-two" })).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
49
ui/litellm-dashboard/src/components/team/MyUserTab.test.tsx
Normal file
49
ui/litellm-dashboard/src/components/team/MyUserTab.test.tsx
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { renderWithProviders, screen } from "../../../tests/test-utils";
|
||||
import MyUserTab from "./MyUserTab";
|
||||
import { useMyTeamMember } from "./useMyTeamMember";
|
||||
|
||||
vi.mock("./useMyTeamMember", () => ({
|
||||
useMyTeamMember: vi.fn(),
|
||||
}));
|
||||
|
||||
describe("MyUserTab", () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it("should render", () => {
|
||||
vi.mocked(useMyTeamMember).mockReturnValue({ isLoading: true } as ReturnType<typeof useMyTeamMember>);
|
||||
|
||||
renderWithProviders(<MyUserTab teamId="team-1" />);
|
||||
|
||||
expect(screen.getByText("Loading your membership info…")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("should display the current member budget and model scope", () => {
|
||||
vi.mocked(useMyTeamMember).mockReturnValue({
|
||||
data: {
|
||||
user_id: "user-1",
|
||||
user_email: "member@example.com",
|
||||
team_id: "team-1",
|
||||
role: "admin",
|
||||
spend: 12.5,
|
||||
total_spend: 30,
|
||||
litellm_budget_table: {
|
||||
max_budget: 100,
|
||||
tpm_limit: 1000,
|
||||
rpm_limit: 10,
|
||||
allowed_models: ["model-one"],
|
||||
},
|
||||
},
|
||||
isLoading: false,
|
||||
error: null,
|
||||
} as ReturnType<typeof useMyTeamMember>);
|
||||
|
||||
renderWithProviders(<MyUserTab teamId="team-1" />);
|
||||
|
||||
expect(screen.getByText("member@example.com")).toBeInTheDocument();
|
||||
expect(screen.getByText("model-one")).toBeInTheDocument();
|
||||
expect(screen.getByText("TPM: 1,000")).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Reference in a new issue