Migrate all IPC call sites to typed tauri-specta commands.*
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:
@@ -6,6 +6,20 @@
|
||||
|
||||
import { describe, it, expect, beforeEach, vi } from "vitest";
|
||||
import { preloadUpcomingTracks, updateCacheConfig, getCacheConfig } from "./preload";
|
||||
import type { CacheConfig } from "$lib/api/bindings";
|
||||
|
||||
// updateCacheConfig now takes a full CacheConfig (matches the backend command)
|
||||
function makeConfig(overrides: Partial<CacheConfig> = {}): CacheConfig {
|
||||
return {
|
||||
queuePrecacheEnabled: true,
|
||||
queuePrecacheCount: 5,
|
||||
albumAffinityEnabled: false,
|
||||
albumAffinityThreshold: 0.75,
|
||||
storageLimit: 2 * 1024 * 1024 * 1024,
|
||||
wifiOnly: false,
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
vi.mock("@tauri-apps/api/core", () => ({
|
||||
invoke: vi.fn(async (command: string, args?: any) => {
|
||||
@@ -135,10 +149,10 @@ describe("preload service", () => {
|
||||
|
||||
describe("updateCacheConfig", () => {
|
||||
it("should update cache config", async () => {
|
||||
const config = {
|
||||
const config = makeConfig({
|
||||
queuePrecacheEnabled: false,
|
||||
queuePrecacheCount: 10,
|
||||
};
|
||||
});
|
||||
|
||||
await expect(updateCacheConfig(config)).resolves.toBeUndefined();
|
||||
});
|
||||
@@ -147,7 +161,7 @@ describe("preload service", () => {
|
||||
const { invoke } = await import("@tauri-apps/api/core");
|
||||
const invokeSpy = vi.mocked(invoke);
|
||||
|
||||
const config = { queuePrecacheEnabled: true };
|
||||
const config = makeConfig({ queuePrecacheEnabled: true });
|
||||
await updateCacheConfig(config);
|
||||
|
||||
const call = invokeSpy.mock.calls.find(
|
||||
@@ -157,8 +171,8 @@ describe("preload service", () => {
|
||||
expect(call![1]).toHaveProperty("config", config);
|
||||
});
|
||||
|
||||
it("should support partial config updates", async () => {
|
||||
const config = { wifiOnly: true };
|
||||
it("should support overriding individual config options", async () => {
|
||||
const config = makeConfig({ wifiOnly: true });
|
||||
await expect(updateCacheConfig(config)).resolves.toBeUndefined();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user