mirror of
https://github.com/tiennm99/litellm.git
synced 2026-08-09 16:24:38 +00:00
test(ui): update tests to match new team_id / access-group signatures
- useKeyAliases, PaginatedKeyAliasSelect: add trailing `undefined` to spy matchers for the new `team_id` param on `useInfiniteKeyAliases` and `keyAliasesCall`. - EntityUsage: mock new `TeamMultiSelect` child so QueryClientProvider is not required for team-entity tests. - ModelsCell: replace the overflow-accordion test with one that verifies the new collapse-on-`all-proxy-models` behavior (no accordion, single badge).
This commit is contained in:
@@ -65,7 +65,7 @@ describe("useInfiniteKeyAliases", () => {
|
||||
expect(result.current.isSuccess).toBe(true);
|
||||
});
|
||||
|
||||
expect(mockKeyAliasesCall).toHaveBeenCalledWith("test-token", 1, 50, undefined);
|
||||
expect(mockKeyAliasesCall).toHaveBeenCalledWith("test-token", 1, 50, undefined, undefined);
|
||||
expect(result.current.data?.pages[0]).toEqual(mockPage1);
|
||||
});
|
||||
|
||||
@@ -74,7 +74,7 @@ describe("useInfiniteKeyAliases", () => {
|
||||
renderHook(() => useInfiniteKeyAliases(25), { wrapper });
|
||||
|
||||
await waitFor(() => {
|
||||
expect(mockKeyAliasesCall).toHaveBeenCalledWith("test-token", 1, 25, undefined);
|
||||
expect(mockKeyAliasesCall).toHaveBeenCalledWith("test-token", 1, 25, undefined, undefined);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -83,7 +83,7 @@ describe("useInfiniteKeyAliases", () => {
|
||||
renderHook(() => useInfiniteKeyAliases(50, "my-alias"), { wrapper });
|
||||
|
||||
await waitFor(() => {
|
||||
expect(mockKeyAliasesCall).toHaveBeenCalledWith("test-token", 1, 50, "my-alias");
|
||||
expect(mockKeyAliasesCall).toHaveBeenCalledWith("test-token", 1, 50, "my-alias", undefined);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -145,7 +145,7 @@ describe("useInfiniteKeyAliases", () => {
|
||||
expect(result.current.data?.pages).toHaveLength(2);
|
||||
});
|
||||
|
||||
expect(mockKeyAliasesCall).toHaveBeenCalledWith("test-token", 2, 2, undefined);
|
||||
expect(mockKeyAliasesCall).toHaveBeenCalledWith("test-token", 2, 2, undefined, undefined);
|
||||
expect(result.current.data?.pages[1]).toEqual(mockPage2);
|
||||
});
|
||||
|
||||
@@ -171,7 +171,7 @@ describe("useInfiniteKeyAliases", () => {
|
||||
rerender({ search: "search-result" });
|
||||
|
||||
await waitFor(() => {
|
||||
expect(mockKeyAliasesCall).toHaveBeenCalledWith("test-token", 1, 50, "search-result");
|
||||
expect(mockKeyAliasesCall).toHaveBeenCalledWith("test-token", 1, 50, "search-result", undefined);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
+6
-6
@@ -125,14 +125,14 @@ describe("ModelsCell", () => {
|
||||
expect(screen.getByText("+2 more models")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("should render 'all-proxy-models' entries in the overflow section as 'All Proxy Models' badges", () => {
|
||||
it("should collapse to a single 'All Proxy Models' badge when the models list includes 'all-proxy-models'", () => {
|
||||
renderModelsCell(makeTeam(["m1", "m2", "m3", "all-proxy-models"]));
|
||||
|
||||
act(() => {
|
||||
screen.getByRole("button", { name: /accordion/i }).click();
|
||||
});
|
||||
|
||||
// There should now be an "All Proxy Models" badge in the expanded section
|
||||
// When all-proxy-models is present, all individual models are hidden and no accordion is shown
|
||||
expect(screen.getByText("All Proxy Models")).toBeInTheDocument();
|
||||
expect(screen.queryByText("m1")).not.toBeInTheDocument();
|
||||
expect(screen.queryByText("m2")).not.toBeInTheDocument();
|
||||
expect(screen.queryByText("m3")).not.toBeInTheDocument();
|
||||
expect(screen.queryByRole("button", { name: /accordion/i })).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
+2
-2
@@ -112,7 +112,7 @@ describe("PaginatedKeyAliasSelect", () => {
|
||||
it("should pass pageSize to useInfiniteKeyAliases", () => {
|
||||
renderWithProviders(<PaginatedKeyAliasSelect onChange={mockOnChange} pageSize={25} />);
|
||||
|
||||
expect(mockUseInfiniteKeyAliases).toHaveBeenCalledWith(25, undefined);
|
||||
expect(mockUseInfiniteKeyAliases).toHaveBeenCalledWith(25, undefined, undefined);
|
||||
});
|
||||
|
||||
it("should pass search to useInfiniteKeyAliases when user types", async () => {
|
||||
@@ -124,7 +124,7 @@ describe("PaginatedKeyAliasSelect", () => {
|
||||
await user.keyboard("my-alias");
|
||||
|
||||
await waitFor(() => {
|
||||
expect(mockUseInfiniteKeyAliases).toHaveBeenCalledWith(50, "my-alias");
|
||||
expect(mockUseInfiniteKeyAliases).toHaveBeenCalledWith(50, "my-alias", undefined);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
+4
@@ -45,6 +45,10 @@ vi.mock("../../../EntityUsageExport", () => ({
|
||||
UsageExportHeader: () => <div>Usage Export Header</div>,
|
||||
}));
|
||||
|
||||
vi.mock("../../../common_components/team_multi_select", () => ({
|
||||
default: () => <div>Team Multi Select</div>,
|
||||
}));
|
||||
|
||||
// Mock useTeams hook
|
||||
vi.mock("@/app/(dashboard)/hooks/useTeams", () => ({
|
||||
default: vi.fn(() => ({
|
||||
|
||||
Reference in New Issue
Block a user