feat(downloads): a bare link is titled once, a missing picture shows a glyph

A job with no name yet is titled by its short link, as the link itself;
the channel line no longer falls back to the ref and the link line does
not repeat it. No picture at all draws a film (or note) glyph instead of
an empty box.
This commit is contained in:
2026-09-27 07:12:51 +02:00
parent f48f16830e
commit 098b8dbe43
3 changed files with 104 additions and 21 deletions
@@ -213,3 +213,46 @@ describe("DownloadRow · narrow", () => {
expect(texts).not.toContain("0");
});
});
// A link queued (or failed) before its details: the title, the channel line and the link line all
// fell back to the same URL (the owner, 2026-09-27). Now the title IS the short link, once.
describe("DownloadRow · a link with no details yet", () => {
const bare: DownloadJob = {
...baseJob,
status: "error",
source_kind: "url",
source_ref: "https://www.facebook.com/watch?v=12345",
source_url: "https://www.facebook.com/watch?v=12345",
display_name: null,
asset: null,
};
it("shows the short link once, as the title's link, with no channel line", () => {
const { container } = render(<DownloadRow job={bare} />);
const links = [...container.querySelectorAll("a")].filter((a) => a.href === bare.source_url);
expect(links.map((a) => a.textContent)).toEqual(["www.facebook.com/watch?v=12345"]);
expect(container.textContent).not.toContain("https://");
});
it("keeps the named row as it was: title text, and the link on its own line", () => {
const named = { ...bare, display_name: "A clip" };
const { container } = render(<DownloadRow job={named} />);
expect(screen.getByText("A clip").closest("a")).toBeNull();
const links = [...container.querySelectorAll("a")].filter((a) => a.href === bare.source_url);
expect(links.map((a) => a.textContent)).toEqual(["www.facebook.com/watch?v=12345"]);
});
});
// No picture at all: a quiet glyph of what it is instead of an empty box (the owner, 2026-09-27).
describe("DownloadRow · no picture", () => {
it("draws a film glyph for a video, a note for audio", () => {
const { container, unmount } = render(<DownloadRow job={withAsset("mp4")} />);
expect(container.querySelector("img")).toBeNull();
expect(container.querySelector("svg.lucide-film")).not.toBeNull();
unmount();
const { container: audio } = render(
<DownloadRow job={withAsset("m4a", { media_kind: "audio" })} />,
);
expect(audio.querySelector("svg.lucide-music")).not.toBeNull();
});
});