Migrate all IPC call sites to typed tauri-specta commands.*
🏗️ Build and Test JellyTau / Run Tests (pull_request) Successful in 4m39s
Traceability Validation / Check Requirement Traces (pull_request) Failing after 36s
🏗️ Build and Test JellyTau / Build Android APK (pull_request) Failing after 1m57s

Replace the remaining ~155 untyped invoke() calls across stores, services,
components, and routes with the generated commands.* wrappers from
$lib/api/bindings, so every IPC call is compile-time-checked against the
command signatures.

- Register repository_get_subtitle_url and repository_get_video_download_url
  in specta_builder() and the invoke_handler; regenerate bindings.ts.
- Source duplicated wire types (AutoplaySettings, CacheConfig, Session,
  ConnectivityStatus, audio/video settings, etc.) from bindings.
- Fix two bugs surfaced by the typed wrappers:
  - VideoDownloadButton passed an un-awaited Promise as the stream URL.
  - setAutoplaySettings omitted the required userId argument.
- Update unit tests asserting the old invoke(name, args) shape.
- Remove the five param-naming guard tests; the compiler and codegen now
  enforce what they checked.

svelte-check: 0 errors. vitest: green. cargo test --lib: green.
This commit is contained in:
2026-06-21 08:47:04 +02:00
parent 14e9d7e03a
commit d01c2aab9f
47 changed files with 456 additions and 2119 deletions
+23 -9
View File
@@ -10,6 +10,7 @@ import {
playNextEpisode,
type AutoplaySettings,
} from "./autoplay";
import type { PlayItemRequest } from "./bindings";
vi.mock("@tauri-apps/api/core", () => ({
invoke: vi.fn(async (command: string, args?: any) => {
@@ -33,6 +34,23 @@ vi.mock("@tauri-apps/api/core", () => ({
}),
}));
// setAutoplaySettings sources the user id from the auth store
vi.mock("$lib/stores/auth", () => ({
auth: { getUserId: () => "user-1" },
}));
// Minimal valid PlayItemRequest for playNextEpisode tests
function makeItem(overrides: Partial<PlayItemRequest> = {}): PlayItemRequest {
return {
id: "item-123",
title: "Episode 1",
streamUrl: "http://example/stream",
videoCodec: "h264",
needsTranscoding: false,
...overrides,
};
}
describe("autoplay API", () => {
beforeEach(() => {
vi.clearAllMocks();
@@ -98,7 +116,7 @@ describe("autoplay API", () => {
(c) => c[0] === "player_set_autoplay_settings"
);
expect(call).toBeDefined();
expect(call![1]).toEqual({ settings });
expect(call![1]).toEqual({ userId: "user-1", settings });
});
it("should support different countdown values", async () => {
@@ -130,11 +148,7 @@ describe("autoplay API", () => {
describe("playNextEpisode", () => {
it("should play next episode with item", async () => {
const mockItem = {
id: "item-123",
name: "Episode 1",
seriesId: "series-456",
};
const mockItem = makeItem();
await playNextEpisode(mockItem);
@@ -150,9 +164,9 @@ describe("autoplay API", () => {
it("should handle different item types", async () => {
const items = [
{ id: "1", name: "Episode 1" },
{ id: "2", name: "Episode 2", seasonNumber: 1 },
{ id: "3", name: "Episode 3", episodeNumber: 5 },
makeItem({ id: "1", title: "Episode 1" }),
makeItem({ id: "2", title: "Episode 2" }),
makeItem({ id: "3", title: "Episode 3" }),
];
for (const item of items) {