mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-09 22:31:41 +00:00
tests
This commit is contained in:
parent
f16fb63434
commit
546fba9849
4 changed files with 97 additions and 0 deletions
|
|
@ -0,0 +1,26 @@
|
|||
import { render, screen } from "@testing-library/react";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import AddSSOSettingsModal from "./AddSSOSettingsModal";
|
||||
|
||||
// Mock networking functions
|
||||
vi.mock("@/components/networking", () => ({
|
||||
updateSSOSettings: vi.fn(),
|
||||
}));
|
||||
|
||||
// Mock error utils
|
||||
vi.mock("@/components/shared/errorUtils", () => ({
|
||||
parseErrorMessage: vi.fn((error) => error?.message || "Unknown error"),
|
||||
}));
|
||||
|
||||
describe("AddSSOSettingsModal", () => {
|
||||
it("should render", () => {
|
||||
const onCancel = vi.fn();
|
||||
const onSuccess = vi.fn();
|
||||
|
||||
render(<AddSSOSettingsModal isVisible={true} onCancel={onCancel} onSuccess={onSuccess} accessToken="test-token" />);
|
||||
|
||||
expect(screen.getByText("SSO Provider")).toBeInTheDocument();
|
||||
expect(screen.getByText("Cancel")).toBeInTheDocument();
|
||||
expect(screen.getAllByText("Add SSO")).toHaveLength(2); // Title and button
|
||||
});
|
||||
});
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
import { render, screen } from "@testing-library/react";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import DeleteSSOSettingsModal from "./DeleteSSOSettingsModal";
|
||||
|
||||
describe("DeleteSSOSettingsModal", () => {
|
||||
it("should render", () => {
|
||||
const onCancel = vi.fn();
|
||||
const onSuccess = vi.fn();
|
||||
|
||||
render(
|
||||
<DeleteSSOSettingsModal isVisible={true} onCancel={onCancel} onSuccess={onSuccess} accessToken="test-token" />,
|
||||
);
|
||||
|
||||
expect(screen.getByText("Confirm Clear SSO Settings")).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByText("Are you sure you want to clear all SSO settings? This action cannot be undone."),
|
||||
).toBeInTheDocument();
|
||||
expect(screen.getByText("Users will no longer be able to login using SSO after this change.")).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import SSOSettings from "./SSOSettings";
|
||||
|
||||
// Mock the useSSOSettings hook
|
||||
vi.mock("@/app/(dashboard)/hooks/sso/useSSOSettings", () => ({
|
||||
useSSOSettings: () => ({
|
||||
data: null,
|
||||
refetch: vi.fn(),
|
||||
}),
|
||||
}));
|
||||
|
||||
const createQueryClient = () =>
|
||||
new QueryClient({
|
||||
defaultOptions: {
|
||||
queries: {
|
||||
retry: false,
|
||||
gcTime: 0,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
describe("SSOSettings", () => {
|
||||
it("should render", () => {
|
||||
const queryClient = createQueryClient();
|
||||
|
||||
render(
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<SSOSettings />
|
||||
</QueryClientProvider>,
|
||||
);
|
||||
|
||||
expect(screen.getByText("SSO Configuration")).toBeInTheDocument();
|
||||
expect(screen.getByText("Manage Single Sign-On authentication settings")).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
import { render, screen } from "@testing-library/react";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import SSOSettingsEmptyPlaceholder from "./SSOSettingsEmptyPlaceholder";
|
||||
|
||||
describe("SSOSettingsEmptyPlaceholder", () => {
|
||||
it("should render", () => {
|
||||
const onAdd = vi.fn();
|
||||
|
||||
render(<SSOSettingsEmptyPlaceholder onAdd={onAdd} />);
|
||||
|
||||
expect(screen.getByText("No SSO Configuration Found")).toBeInTheDocument();
|
||||
expect(screen.getByText("Configure SSO")).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Reference in a new issue