import React from "react"
import { describe, expect, it, vi } from "vitest"
import { render } from "@testing-library/react"
import { MemoryRouter } from "react-router-dom"
vi.mock("@/components/layout/PageHead", () => ({
default: ({ title }: { title: string }) =>
{title}
,
}))
vi.mock("@tanstack/react-query", () => ({
useQuery: () => ({ data: [], isLoading: false, isError: false, refetch: vi.fn() }),
useMutation: () => ({ mutate: vi.fn(), mutateAsync: vi.fn(), isLoading: false }),
useQueryClient: () => ({ invalidateQueries: vi.fn(), setQueryData: vi.fn() }),
useInfiniteQuery: () => ({
data: { pages: [] },
isLoading: false,
fetchNextPage: vi.fn(),
hasNextPage: false,
}),
}))
vi.mock("@/components/ui", () => ({
Button: ({ children, onClick }: any) => ,
Input: ({ placeholder }: any) => ,
Select: ({ options }: any) => (
),
Modal: ({ open, children }: any) => (open ? {children}
: null),
Empty: () => Empty
,
Card: ({ children }: any) => {children}
,
Tag: ({ children }: any) => {children},
Tooltip: ({ children }: any) => {children},
Upload: ({ children }: any) => {children}
,
Progress: () => ,
}))
vi.mock("antd", () => ({
Table: () => ,
Pagination: () => ,
Tabs: () => ,
Modal: ({ open, children }: any) => (open ? {children}
: null),
message: { success: vi.fn(), error: vi.fn(), warning: vi.fn(), info: vi.fn() },
Popconfirm: ({ children }: any) => {children},
Form: ({ children }: any) => ,
Input: ({ placeholder }: any) => ,
InputNumber: () => ,
Select: () => ,
Empty: () => Empty
,
Space: ({ children }: any) => {children}
,
Tag: ({ children }: any) => {children},
Badge: ({ children }: any) => {children},
Tooltip: ({ children }: any) => {children},
Upload: ({ children }: any) => {children}
,
Progress: () => ,
Switch: () => ,
Radio: ({ children }: any) => {children},
RadioGroup: ({ children }: any) => {children}
,
Checkbox: ({ children }: any) => (
),
DatePicker: () => ,
Col: ({ children }: any) => {children}
,
Row: ({ children }: any) => {children}
,
Card: ({ children }: any) => {children}
,
List: () => ,
Grid: { useBreakpoint: () => ({ xs: true, sm: true, md: true, lg: true }) },
Descriptions: ({ children }: any) => {children}
,
Divider: () =>
,
Avatar: () => ,
Dropdown: ({ children }: any) => {children},
Menu: ({ children }: any) => ,
Drawer: ({ open, children }: any) => (open ? {children}
: null),
Typography: {
Title: ({ children }: any) => {children}
,
Text: ({ children }: any) => {children},
Paragraph: ({ children }: any) => {children}
,
},
Spin: ({ spinning }: any) => (spinning ? Loading...
: <>>),
Slider: () => ,
Rate: () => ,
Collapse: ({ children }: any) => {children}
,
Steps: ({ children }: any) => {children}
,
Button: ({ children }: any) => ,
}))
vi.mock("@ant-design/icons", () => ({
AudioOutlined: () => ,
CloseCircleOutlined: () => ,
DeleteOutlined: () => ,
HeartOutlined: () => ,
PauseCircleOutlined: () => ,
PlayCircleOutlined: () => ,
PlusOutlined: () => ,
ReloadOutlined: () => ,
RobotOutlined: () => ,
SearchOutlined: () => ,
SoundOutlined: () => ,
UploadOutlined: () => ,
UserOutlined: () => ,
}))
vi.mock("@/store/authStore", () => ({
useAuthStore: (sel: any) => sel({ user: { id: "1" }, isAuthenticated: true }),
}))
vi.mock("@/api/voice-clone", () => ({
createVoiceClone: vi.fn().mockResolvedValue({ success: true }),
deleteVoiceClone: vi.fn().mockResolvedValue({ success: true }),
retryVoiceClone: vi.fn().mockResolvedValue({ success: true }),
}))
vi.mock("@/api/voices", () => ({
fetchVoices: vi.fn().mockResolvedValue({ items: [], total: 0, success: true }),
fetchPresetVoices: vi.fn().mockResolvedValue({ items: [], total: 0, success: true }),
getVoices: vi.fn().mockResolvedValue({ items: [], total: 0, success: true }),
createVoice: vi.fn().mockResolvedValue({ items: [], total: 0, success: true }),
updateVoice: vi.fn().mockResolvedValue({ items: [], total: 0, success: true }),
deleteVoice: vi.fn().mockResolvedValue({ items: [], total: 0, success: true }),
generateAIVoice: vi.fn().mockResolvedValue({ items: [], total: 0, success: true }),
}))
vi.mock("@/pages/voices/VoiceLibrary.css", () => ({}))
import VoiceLibrary from "@/pages/voices/VoiceLibrary"
describe("VoiceLibrary Page", () => {
it("should render without crashing", () => {
const { container } = render(
,
)
expect(container.firstChild).toBeTruthy()
})
})