mirror of
https://github.com/webadderallorg/Recordly.git
synced 2026-09-27 08:15:42 +00:00
test(editor): cover whisper preferences and caption source selection
This commit is contained in:
@@ -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");
|
||||
});
|
||||
});
|
||||
@@ -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",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user