mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-13 23:11:40 +00:00
test(ui): update OldTeams test for team-detail route navigation
OldTeams now uses useRouter, so the suite mocks next/navigation, and the click-a-team-ID test asserts navigation to /teams/<id> (via migratedHref, which needs serverRootPath on the networking mock) instead of an inline TeamInfoView render
This commit is contained in:
parent
a9b8b5f2fd
commit
d18afe940e
1 changed files with 10 additions and 6 deletions
|
|
@ -7,6 +7,11 @@ import { fetchMCPAccessGroups, getGuardrailsList, teamCreateCall } from "./netwo
|
|||
import OldTeams from "./OldTeams";
|
||||
import { teamListCall } from "@/app/(dashboard)/hooks/teams/useTeams";
|
||||
|
||||
const { mockRouterPush } = vi.hoisted(() => ({ mockRouterPush: vi.fn() }));
|
||||
vi.mock("next/navigation", () => ({
|
||||
useRouter: () => ({ push: mockRouterPush }),
|
||||
}));
|
||||
|
||||
const mockTeamInfoView = vi.fn();
|
||||
const mockUseOrganizations = vi.fn();
|
||||
|
||||
|
|
@ -17,6 +22,7 @@ vi.mock("./networking", () => ({
|
|||
v2TeamListCall: vi.fn(),
|
||||
getGuardrailsList: vi.fn().mockResolvedValue({ guardrails: [] }),
|
||||
getPoliciesList: vi.fn().mockResolvedValue({ policies: [] }),
|
||||
serverRootPath: "",
|
||||
}));
|
||||
|
||||
vi.mock("@/app/(dashboard)/hooks/teams/useTeams", () => ({
|
||||
|
|
@ -575,16 +581,16 @@ describe("OldTeams - helper functions", () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe("OldTeams - premium props", () => {
|
||||
describe("OldTeams - team id navigation", () => {
|
||||
beforeEach(() => {
|
||||
mockTeamInfoView.mockClear();
|
||||
vi.clearAllMocks();
|
||||
vi.mocked(fetchAvailableModelsForTeamOrKey).mockResolvedValue([]);
|
||||
vi.mocked(fetchMCPAccessGroups).mockResolvedValue([]);
|
||||
vi.mocked(getGuardrailsList).mockResolvedValue({ guardrails: [] });
|
||||
mockUseOrganizations.mockReturnValue({ data: [] });
|
||||
});
|
||||
|
||||
it("passes premiumUser flag to TeamInfoView", async () => {
|
||||
it("navigates to the team detail route when clicking the team ID", async () => {
|
||||
vi.mocked(teamListCall).mockResolvedValue({
|
||||
teams: [
|
||||
{
|
||||
|
|
@ -614,9 +620,7 @@ describe("OldTeams - premium props", () => {
|
|||
fireEvent.click(teamIdElement);
|
||||
});
|
||||
|
||||
await waitFor(() => expect(mockTeamInfoView).toHaveBeenCalled());
|
||||
|
||||
expect(mockTeamInfoView).toHaveBeenLastCalledWith(expect.objectContaining({ premiumUser: true }));
|
||||
expect(mockRouterPush).toHaveBeenCalledWith(expect.stringContaining("teams/team-123456789"));
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue