3862996045
CI/CD Pipeline / Check if frontend-only change (push) Waiting to run
CI/CD Pipeline / Validate - Code Quality (push) Waiting to run
CI/CD Pipeline / Validate - Type Check (mypy) (push) Waiting to run
CI/CD Pipeline / Validate - Migration (alembic) (push) Waiting to run
CI/CD Pipeline / Unit Tests (push) Blocked by required conditions
CI/CD Pipeline / Integration Tests (push) Blocked by required conditions
CI/CD Pipeline / Frontend Lint (push) Waiting to run
CI/CD Pipeline / Frontend Unit Tests (push) Blocked by required conditions
CI/CD Pipeline / PR Build API Image (push) Waiting to run
CI/CD Pipeline / PR Build Web Image (push) Waiting to run
CI/CD Pipeline / PR Build Worker Image (push) Waiting to run
CI/CD Pipeline / Build Staging API Image (push) Waiting to run
CI/CD Pipeline / Build Staging Web Image (push) Waiting to run
CI/CD Pipeline / Build Staging Worker Image (push) Waiting to run
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Blocked by required conditions
CI/CD Pipeline / Staging E2E Tests (push) Blocked by required conditions
CI/CD Pipeline / Staging API Integration Tests (push) Blocked by required conditions
CI/CD Pipeline / Build Production API Image (push) Waiting to run
CI/CD Pipeline / Build Production Web Image (push) Waiting to run
CI/CD Pipeline / Build Production Worker Image (push) Waiting to run
CI/CD Pipeline / Deploy Production (push) Blocked by required conditions
CI/CD Pipeline / Production Browser E2E (push) Blocked by required conditions
CI/CD Pipeline / ACR Image Cleanup (push) Blocked by required conditions
425 lines
16 KiB
TypeScript
425 lines
16 KiB
TypeScript
import { describe, expect, it, vi, beforeEach } from "vitest"
|
|
import {
|
|
getEditPlans,
|
|
getEditPlan,
|
|
createEditPlan,
|
|
updateEditPlan,
|
|
deleteEditPlan,
|
|
generateEditPlan,
|
|
getGenerationStatus,
|
|
aiRecommendClips,
|
|
generateCover,
|
|
getEditPlanGenerations,
|
|
getGenerationTaskResults,
|
|
cancelGeneration,
|
|
getEditPlanClips,
|
|
getEditPlanClip,
|
|
createEditPlanClip,
|
|
updateEditPlanClip,
|
|
deleteEditPlanClip,
|
|
reorderEditPlanClips,
|
|
batchDeleteEditPlanClips,
|
|
createClipsFromAssets,
|
|
copyEditPlan,
|
|
getMediaAssets,
|
|
getMediaAsset,
|
|
} from "@/api/template-editor"
|
|
|
|
const mockGet = vi.fn()
|
|
const mockPost = vi.fn()
|
|
const mockPut = vi.fn()
|
|
const mockDelete = vi.fn()
|
|
const mockPatch = vi.fn()
|
|
|
|
vi.mock("@/api/client", () => ({
|
|
default: {
|
|
get: (...args: unknown[]) => mockGet(...args),
|
|
post: (...args: unknown[]) => mockPost(...args),
|
|
put: (...args: unknown[]) => mockPut(...args),
|
|
delete: (...args: unknown[]) => mockDelete(...args),
|
|
patch: (...args: unknown[]) => mockPatch(...args),
|
|
},
|
|
}))
|
|
|
|
vi.mock("antd", () => ({ message: { error: vi.fn(), success: vi.fn() } }))
|
|
vi.mock("@/store/authStore", () => ({ useAuthStore: { getState: vi.fn(() => ({})) } }))
|
|
|
|
describe("editPlans API", () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks()
|
|
mockGet.mockResolvedValue({ data: { success: true, items: [] } })
|
|
mockPost.mockResolvedValue({ data: { success: true, items: [] } })
|
|
mockPut.mockResolvedValue({ data: { success: true, items: [] } })
|
|
mockDelete.mockResolvedValue({ data: { success: true, items: [] } })
|
|
mockPatch.mockResolvedValue({ data: { success: true, items: [] } })
|
|
})
|
|
|
|
describe("getEditPlans", () => {
|
|
it("should resolve successfully", async () => {
|
|
await expect(getEditPlans("test-params?")).resolves.not.toThrow()
|
|
})
|
|
|
|
it("should reject on API error", async () => {
|
|
mockGet.mockRejectedValue(new Error("Network error"))
|
|
mockPost.mockRejectedValue(new Error("Network error"))
|
|
mockPut.mockRejectedValue(new Error("Network error"))
|
|
mockDelete.mockRejectedValue(new Error("Network error"))
|
|
mockPatch.mockRejectedValue(new Error("Network error"))
|
|
|
|
await expect(getEditPlans("test-params?")).rejects.toThrow()
|
|
})
|
|
})
|
|
|
|
describe("getEditPlan", () => {
|
|
it("should resolve successfully", async () => {
|
|
await expect(getEditPlan("test-planId")).resolves.not.toThrow()
|
|
})
|
|
|
|
it("should reject on API error", async () => {
|
|
mockGet.mockRejectedValue(new Error("Network error"))
|
|
mockPost.mockRejectedValue(new Error("Network error"))
|
|
mockPut.mockRejectedValue(new Error("Network error"))
|
|
mockDelete.mockRejectedValue(new Error("Network error"))
|
|
mockPatch.mockRejectedValue(new Error("Network error"))
|
|
|
|
await expect(getEditPlan("test-planId")).rejects.toThrow()
|
|
})
|
|
})
|
|
|
|
describe("createEditPlan", () => {
|
|
it("should resolve successfully", async () => {
|
|
await expect(createEditPlan({ name: "test-item" })).resolves.not.toThrow()
|
|
})
|
|
|
|
it("should reject on API error", async () => {
|
|
mockGet.mockRejectedValue(new Error("Network error"))
|
|
mockPost.mockRejectedValue(new Error("Network error"))
|
|
mockPut.mockRejectedValue(new Error("Network error"))
|
|
mockDelete.mockRejectedValue(new Error("Network error"))
|
|
mockPatch.mockRejectedValue(new Error("Network error"))
|
|
|
|
await expect(createEditPlan({ name: "test-item" })).rejects.toThrow()
|
|
})
|
|
})
|
|
|
|
describe("updateEditPlan", () => {
|
|
it("should resolve successfully", async () => {
|
|
await expect(updateEditPlan("test-planId")).resolves.not.toThrow()
|
|
})
|
|
|
|
it("should reject on API error", async () => {
|
|
mockGet.mockRejectedValue(new Error("Network error"))
|
|
mockPost.mockRejectedValue(new Error("Network error"))
|
|
mockPut.mockRejectedValue(new Error("Network error"))
|
|
mockDelete.mockRejectedValue(new Error("Network error"))
|
|
mockPatch.mockRejectedValue(new Error("Network error"))
|
|
|
|
await expect(updateEditPlan("test-planId")).rejects.toThrow()
|
|
})
|
|
})
|
|
|
|
describe("deleteEditPlan", () => {
|
|
it("should resolve successfully", async () => {
|
|
await expect(deleteEditPlan("test-planId")).resolves.not.toThrow()
|
|
})
|
|
|
|
it("should reject on API error", async () => {
|
|
mockGet.mockRejectedValue(new Error("Network error"))
|
|
mockPost.mockRejectedValue(new Error("Network error"))
|
|
mockPut.mockRejectedValue(new Error("Network error"))
|
|
mockDelete.mockRejectedValue(new Error("Network error"))
|
|
mockPatch.mockRejectedValue(new Error("Network error"))
|
|
|
|
await expect(deleteEditPlan("test-planId")).rejects.toThrow()
|
|
})
|
|
})
|
|
|
|
describe("generateEditPlan", () => {
|
|
it("should resolve successfully", async () => {
|
|
await expect(generateEditPlan("test-planId")).resolves.not.toThrow()
|
|
})
|
|
|
|
it("should reject on API error", async () => {
|
|
mockGet.mockRejectedValue(new Error("Network error"))
|
|
mockPost.mockRejectedValue(new Error("Network error"))
|
|
mockPut.mockRejectedValue(new Error("Network error"))
|
|
mockDelete.mockRejectedValue(new Error("Network error"))
|
|
mockPatch.mockRejectedValue(new Error("Network error"))
|
|
|
|
await expect(generateEditPlan("test-planId")).rejects.toThrow()
|
|
})
|
|
})
|
|
|
|
describe("getGenerationStatus", () => {
|
|
it("should resolve successfully", async () => {
|
|
await expect(getGenerationStatus("test-planId")).resolves.not.toThrow()
|
|
})
|
|
|
|
it("should reject on API error", async () => {
|
|
mockGet.mockRejectedValue(new Error("Network error"))
|
|
mockPost.mockRejectedValue(new Error("Network error"))
|
|
mockPut.mockRejectedValue(new Error("Network error"))
|
|
mockDelete.mockRejectedValue(new Error("Network error"))
|
|
mockPatch.mockRejectedValue(new Error("Network error"))
|
|
|
|
await expect(getGenerationStatus("test-planId")).rejects.toThrow()
|
|
})
|
|
})
|
|
|
|
describe("aiRecommendClips", () => {
|
|
it("should resolve successfully", async () => {
|
|
await expect(aiRecommendClips("test-planId")).resolves.not.toThrow()
|
|
})
|
|
|
|
it("should reject on API error", async () => {
|
|
mockGet.mockRejectedValue(new Error("Network error"))
|
|
mockPost.mockRejectedValue(new Error("Network error"))
|
|
mockPut.mockRejectedValue(new Error("Network error"))
|
|
mockDelete.mockRejectedValue(new Error("Network error"))
|
|
mockPatch.mockRejectedValue(new Error("Network error"))
|
|
|
|
await expect(aiRecommendClips("test-planId")).rejects.toThrow()
|
|
})
|
|
})
|
|
|
|
describe("generateCover", () => {
|
|
it("should resolve successfully", async () => {
|
|
await expect(generateCover("test-planId")).resolves.not.toThrow()
|
|
})
|
|
|
|
it("should reject on API error", async () => {
|
|
mockGet.mockRejectedValue(new Error("Network error"))
|
|
mockPost.mockRejectedValue(new Error("Network error"))
|
|
mockPut.mockRejectedValue(new Error("Network error"))
|
|
mockDelete.mockRejectedValue(new Error("Network error"))
|
|
mockPatch.mockRejectedValue(new Error("Network error"))
|
|
|
|
await expect(generateCover("test-planId")).rejects.toThrow()
|
|
})
|
|
})
|
|
|
|
describe("getEditPlanGenerations", () => {
|
|
it("should resolve successfully", async () => {
|
|
await expect(getEditPlanGenerations("test-planId")).resolves.not.toThrow()
|
|
})
|
|
|
|
it("should reject on API error", async () => {
|
|
mockGet.mockRejectedValue(new Error("Network error"))
|
|
mockPost.mockRejectedValue(new Error("Network error"))
|
|
mockPut.mockRejectedValue(new Error("Network error"))
|
|
mockDelete.mockRejectedValue(new Error("Network error"))
|
|
mockPatch.mockRejectedValue(new Error("Network error"))
|
|
|
|
await expect(getEditPlanGenerations("test-planId")).rejects.toThrow()
|
|
})
|
|
})
|
|
|
|
describe("getGenerationTaskResults", () => {
|
|
it("should resolve successfully", async () => {
|
|
await expect(getGenerationTaskResults("test-taskId")).resolves.not.toThrow()
|
|
})
|
|
|
|
it("should reject on API error", async () => {
|
|
mockGet.mockRejectedValue(new Error("Network error"))
|
|
mockPost.mockRejectedValue(new Error("Network error"))
|
|
mockPut.mockRejectedValue(new Error("Network error"))
|
|
mockDelete.mockRejectedValue(new Error("Network error"))
|
|
mockPatch.mockRejectedValue(new Error("Network error"))
|
|
|
|
await expect(getGenerationTaskResults("test-taskId")).rejects.toThrow()
|
|
})
|
|
})
|
|
|
|
describe("cancelGeneration", () => {
|
|
it("should resolve successfully", async () => {
|
|
await expect(cancelGeneration("test-planId")).resolves.not.toThrow()
|
|
})
|
|
|
|
it("should reject on API error", async () => {
|
|
mockGet.mockRejectedValue(new Error("Network error"))
|
|
mockPost.mockRejectedValue(new Error("Network error"))
|
|
mockPut.mockRejectedValue(new Error("Network error"))
|
|
mockDelete.mockRejectedValue(new Error("Network error"))
|
|
mockPatch.mockRejectedValue(new Error("Network error"))
|
|
|
|
await expect(cancelGeneration("test-planId")).rejects.toThrow()
|
|
})
|
|
})
|
|
|
|
describe("getEditPlanClips", () => {
|
|
it("should resolve successfully", async () => {
|
|
await expect(getEditPlanClips("test-planId")).resolves.not.toThrow()
|
|
})
|
|
|
|
it("should reject on API error", async () => {
|
|
mockGet.mockRejectedValue(new Error("Network error"))
|
|
mockPost.mockRejectedValue(new Error("Network error"))
|
|
mockPut.mockRejectedValue(new Error("Network error"))
|
|
mockDelete.mockRejectedValue(new Error("Network error"))
|
|
mockPatch.mockRejectedValue(new Error("Network error"))
|
|
|
|
await expect(getEditPlanClips("test-planId")).rejects.toThrow()
|
|
})
|
|
})
|
|
|
|
describe("getEditPlanClip", () => {
|
|
it("should resolve successfully", async () => {
|
|
await expect(getEditPlanClip("test-planId")).resolves.not.toThrow()
|
|
})
|
|
|
|
it("should reject on API error", async () => {
|
|
mockGet.mockRejectedValue(new Error("Network error"))
|
|
mockPost.mockRejectedValue(new Error("Network error"))
|
|
mockPut.mockRejectedValue(new Error("Network error"))
|
|
mockDelete.mockRejectedValue(new Error("Network error"))
|
|
mockPatch.mockRejectedValue(new Error("Network error"))
|
|
|
|
await expect(getEditPlanClip("test-planId")).rejects.toThrow()
|
|
})
|
|
})
|
|
|
|
describe("createEditPlanClip", () => {
|
|
it("should resolve successfully", async () => {
|
|
await expect(createEditPlanClip("test-planId")).resolves.not.toThrow()
|
|
})
|
|
|
|
it("should reject on API error", async () => {
|
|
mockGet.mockRejectedValue(new Error("Network error"))
|
|
mockPost.mockRejectedValue(new Error("Network error"))
|
|
mockPut.mockRejectedValue(new Error("Network error"))
|
|
mockDelete.mockRejectedValue(new Error("Network error"))
|
|
mockPatch.mockRejectedValue(new Error("Network error"))
|
|
|
|
await expect(createEditPlanClip("test-planId")).rejects.toThrow()
|
|
})
|
|
})
|
|
|
|
describe("updateEditPlanClip", () => {
|
|
it("should resolve successfully", async () => {
|
|
await expect(updateEditPlanClip("test-planId")).resolves.not.toThrow()
|
|
})
|
|
|
|
it("should reject on API error", async () => {
|
|
mockGet.mockRejectedValue(new Error("Network error"))
|
|
mockPost.mockRejectedValue(new Error("Network error"))
|
|
mockPut.mockRejectedValue(new Error("Network error"))
|
|
mockDelete.mockRejectedValue(new Error("Network error"))
|
|
mockPatch.mockRejectedValue(new Error("Network error"))
|
|
|
|
await expect(updateEditPlanClip("test-planId")).rejects.toThrow()
|
|
})
|
|
})
|
|
|
|
describe("deleteEditPlanClip", () => {
|
|
it("should resolve successfully", async () => {
|
|
await expect(deleteEditPlanClip("test-planId")).resolves.not.toThrow()
|
|
})
|
|
|
|
it("should reject on API error", async () => {
|
|
mockGet.mockRejectedValue(new Error("Network error"))
|
|
mockPost.mockRejectedValue(new Error("Network error"))
|
|
mockPut.mockRejectedValue(new Error("Network error"))
|
|
mockDelete.mockRejectedValue(new Error("Network error"))
|
|
mockPatch.mockRejectedValue(new Error("Network error"))
|
|
|
|
await expect(deleteEditPlanClip("test-planId")).rejects.toThrow()
|
|
})
|
|
})
|
|
|
|
describe("reorderEditPlanClips", () => {
|
|
it("should resolve successfully", async () => {
|
|
await expect(reorderEditPlanClips("test-planId")).resolves.not.toThrow()
|
|
})
|
|
|
|
it("should reject on API error", async () => {
|
|
mockGet.mockRejectedValue(new Error("Network error"))
|
|
mockPost.mockRejectedValue(new Error("Network error"))
|
|
mockPut.mockRejectedValue(new Error("Network error"))
|
|
mockDelete.mockRejectedValue(new Error("Network error"))
|
|
mockPatch.mockRejectedValue(new Error("Network error"))
|
|
|
|
await expect(reorderEditPlanClips("test-planId")).rejects.toThrow()
|
|
})
|
|
})
|
|
|
|
describe("batchDeleteEditPlanClips", () => {
|
|
it("should resolve successfully", async () => {
|
|
await expect(batchDeleteEditPlanClips("test-planId")).resolves.not.toThrow()
|
|
})
|
|
|
|
it("should reject on API error", async () => {
|
|
mockGet.mockRejectedValue(new Error("Network error"))
|
|
mockPost.mockRejectedValue(new Error("Network error"))
|
|
mockPut.mockRejectedValue(new Error("Network error"))
|
|
mockDelete.mockRejectedValue(new Error("Network error"))
|
|
mockPatch.mockRejectedValue(new Error("Network error"))
|
|
|
|
await expect(batchDeleteEditPlanClips("test-planId")).rejects.toThrow()
|
|
})
|
|
})
|
|
|
|
describe("createClipsFromAssets", () => {
|
|
it("should resolve successfully", async () => {
|
|
await expect(createClipsFromAssets("test-planId")).resolves.not.toThrow()
|
|
})
|
|
|
|
it("should reject on API error", async () => {
|
|
mockGet.mockRejectedValue(new Error("Network error"))
|
|
mockPost.mockRejectedValue(new Error("Network error"))
|
|
mockPut.mockRejectedValue(new Error("Network error"))
|
|
mockDelete.mockRejectedValue(new Error("Network error"))
|
|
mockPatch.mockRejectedValue(new Error("Network error"))
|
|
|
|
await expect(createClipsFromAssets("test-planId")).rejects.toThrow()
|
|
})
|
|
})
|
|
|
|
describe("copyEditPlan", () => {
|
|
it("should resolve successfully", async () => {
|
|
await expect(copyEditPlan("test-planId")).resolves.not.toThrow()
|
|
})
|
|
|
|
it("should reject on API error", async () => {
|
|
mockGet.mockRejectedValue(new Error("Network error"))
|
|
mockPost.mockRejectedValue(new Error("Network error"))
|
|
mockPut.mockRejectedValue(new Error("Network error"))
|
|
mockDelete.mockRejectedValue(new Error("Network error"))
|
|
mockPatch.mockRejectedValue(new Error("Network error"))
|
|
|
|
await expect(copyEditPlan("test-planId")).rejects.toThrow()
|
|
})
|
|
})
|
|
|
|
describe("getMediaAssets", () => {
|
|
it("should resolve successfully", async () => {
|
|
await expect(getMediaAssets("test-libraryId?")).resolves.not.toThrow()
|
|
})
|
|
|
|
it("should reject on API error", async () => {
|
|
mockGet.mockRejectedValue(new Error("Network error"))
|
|
mockPost.mockRejectedValue(new Error("Network error"))
|
|
mockPut.mockRejectedValue(new Error("Network error"))
|
|
mockDelete.mockRejectedValue(new Error("Network error"))
|
|
mockPatch.mockRejectedValue(new Error("Network error"))
|
|
|
|
await expect(getMediaAssets("test-libraryId?")).rejects.toThrow()
|
|
})
|
|
})
|
|
|
|
describe("getMediaAsset", () => {
|
|
it("should resolve successfully", async () => {
|
|
await expect(getMediaAsset("test-id")).resolves.not.toThrow()
|
|
})
|
|
|
|
it("should reject on API error", async () => {
|
|
mockGet.mockRejectedValue(new Error("Network error"))
|
|
mockPost.mockRejectedValue(new Error("Network error"))
|
|
mockPut.mockRejectedValue(new Error("Network error"))
|
|
mockDelete.mockRejectedValue(new Error("Network error"))
|
|
mockPatch.mockRejectedValue(new Error("Network error"))
|
|
|
|
await expect(getMediaAsset("test-id")).rejects.toThrow()
|
|
})
|
|
})
|
|
})
|