Skip to content

Create polished demo videos without editing skills. Mac/Windows/Linux

test(editor): cover whisper preferences and caption source selection

webadderall91bdf8b05bf6
diff --git a/src/components/video-editor/autoCaptionSource.test.ts b/src/components/video-editor/autoCaptionSource.test.ts
new file mode 100644
index 00000000..20d3855a
--- /dev/null
+++ b/src/components/video-editor/autoCaptionSource.test.ts
@@ -0,0 +1,39 @@
+import { describe, expect, it } from "vitest";
+
+import { resolveAutoCaptionSourcePath } from "./autoCaptionSource";
+
+describe("resolveAutoCaptionSourcePath", () => {
+ it("prefers the video loaded in the editor over stale session state", () => {
+ expect(
+ resolveAutoCaptionSourcePath({
+ videoSourcePath: "/videos/current.mp4",
+ recordingSessionVideoPath: "/videos/stale.mp4",
+ currentVideoPath: "/videos/fallback.mp4",
+ }),
+ ).toBe("/videos/current.mp4");
+ });
+
+ it("falls back to the loaded file URL when no normalized source path exists", () => {
+ expect(
+ resolveAutoCaptionSourcePath({
+ videoPath: "file:///Users/test/Desktop/capture.mp4",
+ recordingSessionVideoPath: "/videos/stale.mp4",
+ }),
+ ).toBe("/Users/test/Desktop/capture.mp4");
+ });
+
+ it("uses session and current video fallbacks only when nothing is loaded", () => {
+ expect(
+ resolveAutoCaptionSourcePath({
+ recordingSessionVideoPath: "/videos/session.mp4",
+ currentVideoPath: "/videos/fallback.mp4",
+ }),
+ ).toBe("/videos/session.mp4");
+
+ expect(
+ resolveAutoCaptionSourcePath({
+ currentVideoPath: "/videos/fallback.mp4",
+ }),
+ ).toBe("/videos/fallback.mp4");
+ });
+});
diff --git a/src/components/video-editor/editorPreferences.test.ts b/src/components/video-editor/editorPreferences.test.ts
index 848240a2..9983717f 100644
--- a/src/components/video-editor/editorPreferences.test.ts
+++ b/src/components/video-editor/editorPreferences.test.ts
@@ -177,6 +177,23 @@ describe("editorPreferences", () => {
});
});
+ it("preserves custom Whisper paths from stored preferences", () => {
+ vi.stubGlobal(
+ "localStorage",
+ createStorageMock({
+ [EDITOR_PREFERENCES_STORAGE_KEY]: JSON.stringify({
+ whisperExecutablePath: "/usr/local/bin/whisper-cli",
+ whisperModelPath: "/Users/test/models/ggml-base.bin",
+ }),
+ }),
+ );
+
+ expect(loadEditorPreferences()).toMatchObject({
+ whisperExecutablePath: "/usr/local/bin/whisper-cli",
+ whisperModelPath: "/Users/test/models/ggml-base.bin",
+ });
+ });
+
it("saves all editor controls with normalization", () => {
const localStorage = createStorageMock();
vi.stubGlobal("localStorage", localStorage);
@@ -256,4 +273,19 @@ describe("editorPreferences", () => {
whisperModelPath: DEFAULT_EDITOR_PREFERENCES.whisperModelPath,
});
});
+
+ it("saves custom Whisper paths", () => {
+ const localStorage = createStorageMock();
+ vi.stubGlobal("localStorage", localStorage);
+
+ saveEditorPreferences({
+ whisperExecutablePath: "/opt/homebrew/bin/whisper-cli",
+ whisperModelPath: "/Users/test/models/ggml-small.bin",
+ });
+
+ expect(loadEditorPreferences()).toMatchObject({
+ whisperExecutablePath: "/opt/homebrew/bin/whisper-cli",
+ whisperModelPath: "/Users/test/models/ggml-small.bin",
+ });
+ });
});