Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

test(web): update transcribe language tests for AssemblyAI

Richie McIlroy2ead3ad0440d
diff --git a/apps/web/__tests__/unit/transcribe-language.test.ts b/apps/web/__tests__/unit/transcribe-language.test.ts
index cc07bbb43..505c4d1bf 100644
--- a/apps/web/__tests__/unit/transcribe-language.test.ts
+++ b/apps/web/__tests__/unit/transcribe-language.test.ts
@@ -1,69 +1,11 @@
-import { describe, expect, it, vi } from "vitest";
-
-vi.mock("@cap/database", () => ({
- db: vi.fn(),
-}));
-
-vi.mock("@cap/env", () => ({
- serverEnv: vi.fn(() => ({})),
-}));
-
-vi.mock("@cap/utils", () => ({
- userIsPro: vi.fn(),
-}));
-
-vi.mock("@cap/web-backend", () => ({
- Storage: {},
-}));
-
-vi.mock("@deepgram/sdk", () => ({
- createClient: vi.fn(),
-}));
-
-vi.mock("@/lib/audio-enhance", () => ({
- ENHANCED_AUDIO_CONTENT_TYPE: "audio/mpeg",
- ENHANCED_AUDIO_EXTENSION: "mp3",
- enhanceAudioFromUrl: vi.fn(),
-}));
-
-vi.mock("@/lib/audio-extract", () => ({
- checkHasAudioTrack: vi.fn(),
- extractAudioFromUrl: vi.fn(),
-}));
-
-vi.mock("@/lib/generate-ai", () => ({
- startAiGeneration: vi.fn(),
-}));
-
-vi.mock("@/lib/media-client", () => ({
- checkHasAudioTrackViaMediaServer: vi.fn(),
- extractAudioViaMediaServer: vi.fn(),
- isMediaServerConfigured: vi.fn(),
- probeVideoViaMediaServer: vi.fn(),
-}));
-
-vi.mock("@/lib/server", () => ({
- runPromise: vi.fn(),
-}));
-
-vi.mock("@/lib/transcribe-utils", () => ({
- formatToWebVTT: vi.fn(),
-}));
-
-vi.mock("@/lib/video-storage", () => ({
- decodeStorageVideo: vi.fn(),
-}));
-
-vi.mock("workflow", () => ({
- FatalError: class FatalError extends Error {},
-}));
-
import {
+ AI_GENERATION_LANGUAGE_CODES,
AI_GENERATION_LANGUAGES,
isAiGenerationLanguage,
parseAiGenerationLanguage,
} from "@cap/web-domain";
-import { getDeepgramTranscriptionOptions } from "@/workflows/transcribe";
+import { describe, expect, it } from "vitest";
+import { getAssemblyAITranscriptionOptions } from "@/lib/assemblyai";
describe("AI generation language support", () => {
it("exposes Romanian for AI generation", () => {
@@ -78,21 +20,29 @@ describe("AI generation language support", () => {
expect(parseAiGenerationLanguage("pa")).toBe("auto");
});
- it("constrains Deepgram auto-detection to detectable languages", () => {
- expect(getDeepgramTranscriptionOptions("auto")).toMatchObject({
- model: "nova-3",
- detect_language: expect.arrayContaining(["en", "es", "ro", "zh"]),
+ it("uses Universal-3.5 Pro with Universal-2 fallback", () => {
+ const options = getAssemblyAITranscriptionOptions("auto");
+
+ expect(options).toMatchObject({
+ speech_models: ["universal-3-5-pro", "universal-2"],
+ language_detection: true,
});
+ if (!("language_detection_options" in options)) {
+ throw new Error("Expected automatic language detection options");
+ }
+ expect(options.language_detection_options.expected_languages).toEqual(
+ AI_GENERATION_LANGUAGE_CODES,
+ );
});
- it("passes explicit languages to Deepgram", () => {
- expect(getDeepgramTranscriptionOptions("ro")).toMatchObject({
- model: "nova-3",
- language: "ro",
+ it("passes explicit languages to AssemblyAI", () => {
+ expect(getAssemblyAITranscriptionOptions("ro")).toMatchObject({
+ speech_models: ["universal-3-5-pro", "universal-2"],
+ language_code: "ro",
});
- expect(getDeepgramTranscriptionOptions("zh")).toMatchObject({
- model: "nova-3",
- language: "zh",
+ expect(getAssemblyAITranscriptionOptions("zh")).toMatchObject({
+ speech_models: ["universal-3-5-pro", "universal-2"],
+ language_code: "zh",
});
});
});