diff --git a/src/lib/components/player/VideoPlayer.tapSurface.test.ts b/src/lib/components/player/VideoPlayer.tapSurface.test.ts index 30fd09fd..86bd91a4 100644 --- a/src/lib/components/player/VideoPlayer.tapSurface.test.ts +++ b/src/lib/components/player/VideoPlayer.tapSurface.test.ts @@ -32,6 +32,7 @@ import { describe, it, expect, vi, beforeEach } from "vitest"; import { render } from "@testing-library/svelte"; import { tick } from "svelte"; +import { invoke } from "@tauri-apps/api/core"; import VideoPlayer from "./VideoPlayer.svelte"; import { SEEK_FORWARD_SECONDS } from "./tapGestures"; @@ -128,6 +129,23 @@ function renderPlayer() { describe("VideoPlayer tap surface (real component)", () => { beforeEach(() => { vi.clearAllMocks(); + // This file deliberately does NOT mock `$lib/api/bindings` — it renders the + // real component against the real bindings, which bottom out in the globally + // mocked `invoke`. That mock resolves `undefined` for every command, so the + // commands whose results are *rendered* have to be answered here: the + // quality picker assigns the result straight to state and then does + // `streamingQualities.length` in the template, which throws (asynchronously, + // outside any test) on undefined and fails the run with an unhandled error. + vi.mocked(invoke).mockImplementation(async (cmd: string) => { + switch (cmd) { + case "player_get_streaming_qualities": + return []; + case "player_get_video_settings": + return { streamingQuality: "original" }; + default: + return undefined; + } + }); }); it("a single tap on the video toggles play/pause exactly once", async () => {