351a745ec5
Preview Deploy / Deploy Preview Environment (pull_request) Failing after 16s
AI Code Review / AI Code Review (pull_request) Failing after 36s
Auto Approve CI PRs / Auto Approve on CI Green (pull_request) Successful in 1m49s
Auto Merge CI PRs / Auto Merge on CI Green + Approved (pull_request) Successful in 2m58s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 6s
CI/CD Pipeline / Integration Tests (pull_request) Failing after 1420h15m34s
CI/CD Pipeline / Unit Tests (pull_request) Failing after 1420h15m36s
CI Build & Deploy Pipeline / Production Browser E2E (pull_request) Failing after 1420h15m47s
CI Build & Deploy Pipeline / Staging E2E Tests (pull_request) Failing after 1420h15m47s
CI Build & Deploy Pipeline / Deploy Production (pull_request) Failing after 1420h15m49s
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Failing after 1420h15m37s
CI Build & Deploy Pipeline / Build Staging Web Image (pull_request) Failing after 1420h15m54s
CI Build & Deploy Pipeline / Build Staging API Image (pull_request) Failing after 1420h15m54s
CI Build & Deploy Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Failing after 1420h15m49s
CI Build & Deploy Pipeline / Build Production Worker Image (pull_request) Failing after 1420h15m51s
CI Build & Deploy Pipeline / Build Production Web Image (pull_request) Failing after 1420h15m51s
CI Build & Deploy Pipeline / Build Production API Image (pull_request) Failing after 1420h15m51s
CI/CD Pipeline / Check if frontend-only change (pull_request) Has been skipped
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI Build & Deploy Pipeline / Staging API Integration Tests (pull_request) Failing after 1420h47m52s
CI Build & Deploy Pipeline / Build Staging Worker Image (pull_request) Failing after 1420h47m57s
170 lines
6.0 KiB
TypeScript
170 lines
6.0 KiB
TypeScript
import { describe, expect, it, vi, beforeEach } from "vitest"
|
|
import {
|
|
synthesizeSpeech,
|
|
getTTSJob,
|
|
getTTSJobStatus,
|
|
getTTSJobs,
|
|
saveTtsToLibrary,
|
|
deleteTTSJob,
|
|
getTtsVoices,
|
|
previewTts,
|
|
} from "@/api/tts"
|
|
|
|
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("tts 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("synthesizeSpeech", () => {
|
|
it("should resolve successfully", async () => {
|
|
await expect(synthesizeSpeech({ 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(synthesizeSpeech({ name: "test-item" })).rejects.toThrow()
|
|
})
|
|
})
|
|
|
|
describe("getTTSJob", () => {
|
|
it("should resolve successfully", async () => {
|
|
await expect(getTTSJob("test-jobId")).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(getTTSJob("test-jobId")).rejects.toThrow()
|
|
})
|
|
})
|
|
|
|
describe("getTTSJobStatus", () => {
|
|
it("should resolve successfully", async () => {
|
|
await expect(getTTSJobStatus("test-jobId")).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(getTTSJobStatus("test-jobId")).rejects.toThrow()
|
|
})
|
|
})
|
|
|
|
describe("getTTSJobs", () => {
|
|
it("should resolve successfully", async () => {
|
|
await expect(getTTSJobs("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(getTTSJobs("test-params?")).rejects.toThrow()
|
|
})
|
|
})
|
|
|
|
describe("saveTtsToLibrary", () => {
|
|
it("should resolve successfully", async () => {
|
|
await expect(saveTtsToLibrary("test-jobId")).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(saveTtsToLibrary("test-jobId")).rejects.toThrow()
|
|
})
|
|
})
|
|
|
|
describe("deleteTTSJob", () => {
|
|
it("should resolve successfully", async () => {
|
|
await expect(deleteTTSJob("test-jobId")).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(deleteTTSJob("test-jobId")).rejects.toThrow()
|
|
})
|
|
})
|
|
|
|
describe("getTtsVoices", () => {
|
|
it("should resolve successfully", async () => {
|
|
await expect(getTtsVoices()).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(getTtsVoices()).rejects.toThrow()
|
|
})
|
|
})
|
|
|
|
describe("previewTts", () => {
|
|
it("should resolve successfully", async () => {
|
|
await expect(previewTts({ 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(previewTts({ name: "test-item" })).rejects.toThrow()
|
|
})
|
|
})
|
|
})
|