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>
54 lines
1.7 KiB
TypeScript
54 lines
1.7 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: { plan: "free", status: "active", auto_renew: true },
|
|
isLoading: false,
|
|
isError: false,
|
|
refetch: vi.fn(),
|
|
}),
|
|
useMutation: () => ({
|
|
mutate: vi.fn(),
|
|
mutateAsync: vi.fn(),
|
|
isLoading: false,
|
|
}),
|
|
}))
|
|
|
|
vi.mock("@/components/ui", () => ({
|
|
Button: ({ children, onClick }: any) => <button onClick={onClick}>{children}</button>,
|
|
Modal: ({ open, children }: any) => (open ? <div role="dialog">{children}</div> : null),
|
|
}))
|
|
|
|
vi.mock("antd", () => ({
|
|
message: { success: vi.fn(), error: vi.fn(), warning: vi.fn() },
|
|
}))
|
|
|
|
vi.mock("@/api/subscription", () => ({
|
|
getCurrentSubscription: vi.fn().mockResolvedValue({ plan: "free", status: "active" }),
|
|
changePlan: vi.fn().mockResolvedValue({ success: true }),
|
|
toggleAutoRenew: vi.fn().mockResolvedValue({ success: true }),
|
|
cancelSubscription: vi.fn().mockResolvedValue({ success: true }),
|
|
}))
|
|
|
|
vi.mock("@/pages/subscription/UpgradeSubscription.css", () => ({}))
|
|
|
|
import UpgradeSubscription from "@/pages/subscription/UpgradeSubscription"
|
|
|
|
describe("UpgradeSubscription Page", () => {
|
|
it("should render without crashing", () => {
|
|
const { container } = render(
|
|
<MemoryRouter>
|
|
<UpgradeSubscription />
|
|
</MemoryRouter>,
|
|
)
|
|
expect(container.querySelector(".xx-upgrade-page")).toBeTruthy()
|
|
})
|
|
})
|