An episode that ends while backgrounded in audio-only mode advances in the
backend, but player_exit_background_audio returned only a position, so the
video page reloaded the episode it was mounted with -- the previous one, at
the new episode's timestamp.
The command now returns BackgroundAudioResume { itemId, positionSeconds }.
planHandoffReturn yields "other-item" when the id differs from the mounted
one, and the player page navigates to that episode with resumeAt=<seconds>,
marking the outgoing episode watched and suppressing its stale stop report.
TRACES: UR-040, UR-023 | DR-296 | UT-265, UT-266
44 lines
1.4 KiB
TypeScript
44 lines
1.4 KiB
TypeScript
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
import { invoke } from "@tauri-apps/api/core";
|
|
import { commands } from "$lib/api/bindings";
|
|
|
|
vi.mock("@tauri-apps/api/core");
|
|
|
|
// TRACES: UR-040 | DR-052 | UT-061
|
|
//
|
|
// Guards the Tauri v2 camelCase param rule for the background-audio commands:
|
|
// the command NAME stays snake_case; params are camelCase.
|
|
|
|
describe("background-audio player commands (param naming)", () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks();
|
|
});
|
|
|
|
it("player_enter_background_audio sends item + positionSeconds (camelCase)", async () => {
|
|
(invoke as any).mockResolvedValueOnce({});
|
|
|
|
const item = {
|
|
id: "vid-1",
|
|
title: "Episode 1",
|
|
streamUrl: "https://server/Audio/vid-1/universal?AudioStreamIndex=1",
|
|
videoCodec: "aac",
|
|
needsTranscoding: false,
|
|
};
|
|
await commands.playerEnterBackgroundAudio(item, 193);
|
|
|
|
expect(invoke).toHaveBeenCalledWith("player_enter_background_audio", {
|
|
item,
|
|
positionSeconds: 193,
|
|
});
|
|
});
|
|
|
|
it("player_exit_background_audio takes no params and returns the resume point", async () => {
|
|
(invoke as any).mockResolvedValueOnce({ itemId: "ep2", positionSeconds: 193.5 });
|
|
|
|
const resume = await commands.playerExitBackgroundAudio();
|
|
|
|
expect(resume).toEqual({ itemId: "ep2", positionSeconds: 193.5 });
|
|
expect(invoke).toHaveBeenCalledWith("player_exit_background_audio");
|
|
});
|
|
});
|