Files
jellytau/src/lib/player/localSource.test.ts
T
dtourolle 7545de6cc7 refactor: delete two orphans, and record why the reparent design changed
`resolveVideoSource` chose between a local file and a remote URL for video
playback. Backend-owned stream selection took that decision into Rust —
`media_local_selection` for a downloaded file, `get_stream_selection` for a
streamed one — and its last caller went with it. What remained was the function
plus sixty lines of tests exercising nothing that ships.

`fittedVideoSize` computed the rendered size of a video letterboxed into its
container. Nothing has ever called it: it arrived with the fix that made the
video fill its viewport and was superseded by `object-fit: contain` in the same
change. There is some irony in a helper that models letterboxing sitting unused
beside a container that was not letterboxing at all — the bug fixed in the
previous commit was CSS, and this function would not have helped.

A survey for exported symbols referenced only by their own tests finds 22 more.
Most are legitimate — test mocks, deliberate reset hooks, public utility APIs —
and the rest are unrelated to this work, so they are left for a cleanup that can
be reviewed on its own terms rather than smuggled into a playback branch.

Also records in the spec why DR-231's design changed. Reparenting Tauri's
webview into a GtkOverlay aborts the process on the first click: Linux calls
`attach_resize_handler` unconditionally (the Windows path guards it with
`is_decorated()`), and its handler walks webview -> GtkBox -> GtkWindow with an
unwrap that an overlay breaks. So the webview is not moved at all — mpv draws
into the default vbox's own `draw` handler via `gdk_cairo_draw_from_gl()`, and
GTK's container-before-children order puts the webview on top for free. No
reparent, one less widget, and nothing a Tauri upgrade can invalidate by
assuming its own layout.
2026-08-22 13:45:04 +02:00

32 lines
1.4 KiB
TypeScript

import { describe, it, expect } from "vitest";
import { downloadedFilePath } from "./localSource";
describe("downloadedFilePath", () => {
// The download worker rewrites `downloads.file_path` to the absolute path it
// actually wrote once the transfer completes, so a completed row is already
// rooted. Joining it onto the storage root again produced
// `/data/user/0/app//data/user/0/app/videos/x.mp4`, which the asset protocol
// cannot open — offline video died with MEDIA_ERR_SRC_NOT_SUPPORTED while
// audio, which resolves the same column through Rust, played fine.
it("leaves a completed download's absolute path alone", () => {
const root = "/data/user/0/com.dtourolle.jellytau";
const stored = `${root}/videos/Taming of the Shrew.mp4`;
expect(downloadedFilePath(root, stored)).toBe(stored);
});
it("roots a path that is still relative to the storage directory", () => {
// Rows only hold a relative path before the worker completes them, but a
// half-migrated database can still carry one.
expect(downloadedFilePath("/var/data/jellytau", "videos/film.mp4")).toBe(
"/var/data/jellytau/videos/film.mp4",
);
});
it("leaves an absolute Windows path alone", () => {
const stored = "C:\\Users\\u\\AppData\\jellytau\\videos\\film.mp4";
expect(downloadedFilePath("C:\\Users\\u\\AppData\\jellytau", stored)).toBe(stored);
});
});