280db0b862
CI/CD Pipeline / Check if frontend-only change (push) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (push) Successful in 3m19s
CI/CD Pipeline / Frontend Lint (push) Successful in 4m24s
CI/CD Pipeline / Validate Code Quality And Tests (push) Successful in 4m48s
CI/CD Pipeline / Unit Tests (push) Successful in 5m28s
CI/CD Pipeline / Integration Tests (push) Successful in 1m34s
CI Build & Deploy Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Successful in 53s
CI Build & Deploy Pipeline / Build Staging API Image (push) Successful in 6m43s
CI Build & Deploy Pipeline / Build Staging Web Image (push) Successful in 1m48s
CI Build & Deploy Pipeline / Build Staging Worker Image (push) Successful in 8m36s
CI Build & Deploy Pipeline / Build Production API Image (push) Has been skipped
CI Build & Deploy Pipeline / Build Production Web Image (push) Has been skipped
CI Build & Deploy Pipeline / Build Production Worker Image (push) Has been skipped
CI Build & Deploy Pipeline / Deploy Production (push) Has been skipped
CI Build & Deploy Pipeline / Production Browser E2E (push) Has been skipped
CI Build & Deploy Pipeline / Staging E2E Tests (push) Failing after 1m14s
CI Build & Deploy Pipeline / Staging API Integration Tests (push) Successful in 3m3s
Co-authored-by: xiaoxia <dev@xiaoxiajianji.com> Co-committed-by: xiaoxia <dev@xiaoxiajianji.com>
64 lines
1.8 KiB
TypeScript
64 lines
1.8 KiB
TypeScript
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 }) => <div data-testid="page-head">{title}</div>,
|
|
}))
|
|
|
|
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(),
|
|
}),
|
|
}))
|
|
|
|
vi.mock("@/components/ui", () => ({
|
|
Button: ({ children, onClick }: any) => <button onClick={onClick}>{children}</button>,
|
|
}))
|
|
|
|
vi.mock("antd", () => ({
|
|
Table: () => <div data-testid="mock-table" />,
|
|
Pagination: () => <div data-testid="mock-pagination" />,
|
|
Select: () => <select />,
|
|
Tabs: () => <div data-testid="mock-tabs" />,
|
|
Empty: () => <div>Empty</div>,
|
|
Space: ({ children }: any) => <div>{children}</div>,
|
|
message: { success: vi.fn(), error: vi.fn() },
|
|
Popconfirm: ({ children }: any) => <span>{children}</span>,
|
|
Tag: ({ children }: any) => <span>{children}</span>,
|
|
Badge: ({ children }: any) => <span>{children}</span>,
|
|
Tooltip: ({ children }: any) => <span>{children}</span>,
|
|
}))
|
|
|
|
vi.mock("@/api/tasks", () => ({
|
|
getUserTasks: vi.fn().mockResolvedValue([]),
|
|
retryTask: vi.fn().mockResolvedValue({ success: true }),
|
|
}))
|
|
|
|
vi.mock("@/pages/history/history.css", () => ({}))
|
|
|
|
import TaskHistory from "@/pages/history/TaskHistory"
|
|
|
|
describe("TaskHistory Page", () => {
|
|
it("should render without crashing", () => {
|
|
const { container } = render(
|
|
<MemoryRouter>
|
|
<TaskHistory />
|
|
</MemoryRouter>,
|
|
)
|
|
expect(container.firstChild).toBeTruthy()
|
|
})
|
|
})
|