Files
xiaoxia-saas/apps/web/src/test/pages/HomePage.test.tsx
T
xiaoxia 5610ef9f1a
CI/CD Pipeline / Check if frontend-only change (push) Has been skipped
CI Build & Deploy Pipeline / Build Production API Image (push) Has been skipped
CI Build & Deploy Pipeline / Build Production Worker Image (push) Has been skipped
CI Build & Deploy Pipeline / Build Production Web 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/CD Pipeline / Frontend Unit Tests (push) Successful in 1m8s
CI Build & Deploy Pipeline / Build Staging Web Image (push) Successful in 1m31s
CI/CD Pipeline / Frontend Lint (push) Successful in 2m26s
CI/CD Pipeline / Validate Code Quality And Tests (push) Successful in 3m46s
CI/CD Pipeline / Unit Tests (push) Successful in 3m49s
CI/CD Pipeline / Integration Tests (push) Successful in 1m52s
CI Build & Deploy Pipeline / Build Staging API Image (push) Successful in 6m29s
CI Build & Deploy Pipeline / Build Staging Worker Image (push) Successful in 8m32s
CI Build & Deploy Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Successful in 50s
CI Build & Deploy Pipeline / Staging E2E Tests (push) Failing after 1m21s
CI Build & Deploy Pipeline / Staging API Integration Tests (push) Successful in 3m11s
test: 前端单测覆盖率Phase1,行覆盖率0.84%→22.35% (#560)
Co-authored-by: xiaoxia <dev@xiaoxiajianji.com>
Co-committed-by: xiaoxia <dev@xiaoxiajianji.com>
2026-07-19 11:16:36 +08:00

63 lines
1.5 KiB
TypeScript

import { describe, expect, it, vi } from "vitest"
import { render } from "@testing-library/react"
import { MemoryRouter } from "react-router-dom"
import HomePage from "@/pages/home/HomePage"
vi.mock("react-router-dom", async () => {
const actual = await vi.importActual("react-router-dom")
return {
...actual,
useNavigate: () => vi.fn(),
}
})
vi.mock("@/store/authStore", () => ({
useAuthStore: (selector: any) => {
const store = {
isAuthenticated: false,
user: null,
setAuth: vi.fn(),
clearAuth: vi.fn(),
}
return selector ? selector(store) : store
},
}))
describe("HomePage", () => {
it("should render without crashing", () => {
const { container } = render(
<MemoryRouter>
<HomePage />
</MemoryRouter>,
)
expect(container).toBeTruthy()
})
it("should render hero section", () => {
const { container } = render(
<MemoryRouter>
<HomePage />
</MemoryRouter>,
)
expect(container.querySelector(".hp-hero")).toBeTruthy()
})
it("should render feature section", () => {
const { container } = render(
<MemoryRouter>
<HomePage />
</MemoryRouter>,
)
expect(container.querySelector(".hp-features")).toBeTruthy()
})
it("should render pricing section", () => {
const { container } = render(
<MemoryRouter>
<HomePage />
</MemoryRouter>,
)
expect(container.querySelector(".hp-pricing")).toBeTruthy()
})
})