summaryrefslogtreecommitdiffhomepage
path: root/yt-music-dl-web/src/features/segment-editor/metadata.test.ts
diff options
context:
space:
mode:
authorAdam Malczewski <[email protected]>2026-07-01 22:16:09 +0900
committerAdam Malczewski <[email protected]>2026-07-01 22:16:52 +0900
commitb476f7703c594e9c8ff1b1ecc77f8e2493ef04b4 (patch)
tree22971336f0a7a1ec68f7b9b4f24c80d159ea1118 /yt-music-dl-web/src/features/segment-editor/metadata.test.ts
parent6402a83fe83a0b1a9f5959ff7f45d07d3e309c6e (diff)
downloadyt-walkerman-main.tar.gz
yt-walkerman-main.zip
Phase 8: album art in metadata search results (frontend)HEADmain
Diffstat (limited to 'yt-music-dl-web/src/features/segment-editor/metadata.test.ts')
-rw-r--r--yt-music-dl-web/src/features/segment-editor/metadata.test.ts57
1 files changed, 57 insertions, 0 deletions
diff --git a/yt-music-dl-web/src/features/segment-editor/metadata.test.ts b/yt-music-dl-web/src/features/segment-editor/metadata.test.ts
index b917195..c4ff8dc 100644
--- a/yt-music-dl-web/src/features/segment-editor/metadata.test.ts
+++ b/yt-music-dl-web/src/features/segment-editor/metadata.test.ts
@@ -265,6 +265,23 @@ describe("sidebarItems (pure)", () => {
expect(item.score).toBe(50);
});
+ it("toSidebarItem maps artUrl when the result has one", () => {
+ const r: MetadataResult = {
+ id: "m1",
+ type: "recording",
+ title: "T",
+ artist: "A",
+ score: 70,
+ artUrl: "https://coverartarchive.org/release/abc/front",
+ };
+ expect(toSidebarItem(r).artUrl).toBe("https://coverartarchive.org/release/abc/front");
+ });
+
+ it("toSidebarItem omits artUrl when the result has none", () => {
+ const r: MetadataResult = { id: "m1", type: "recording", title: "T", artist: "A", score: 70 };
+ expect(toSidebarItem(r).artUrl).toBeUndefined();
+ });
+
it("youtubeItem reflects the segment's current parsed fields", () => {
const item = youtubeItem(seg("s1", "Title", "Artist", "Album", 5));
expect(item).toEqual({
@@ -329,10 +346,50 @@ describe("fillActions (pure)", () => {
expect(actions.some((a) => a.type === "editSegmentTrackNumber")).toBe(false);
});
+ it("emits editSegmentAlbumArt when the result has artUrl", () => {
+ const r: MetadataResult = {
+ id: "m1",
+ type: "recording",
+ title: "T",
+ artist: "A",
+ score: 70,
+ artUrl: "https://coverartarchive.org/release/abc/front",
+ };
+ const actions = fillActions("s1", toSidebarItem(r));
+ expect(actions).toContainEqual({
+ type: "editSegmentAlbumArt",
+ segmentId: "s1",
+ albumArt: { kind: "url", url: "https://coverartarchive.org/release/abc/front" },
+ });
+ });
+
+ it("omits editSegmentAlbumArt when the result has no artUrl", () => {
+ const r: MetadataResult = { id: "m1", type: "recording", title: "T", artist: "A", score: 70 };
+ const actions = fillActions("s1", toSidebarItem(r));
+ expect(actions.some((a) => a.type === "editSegmentAlbumArt")).toBe(false);
+ });
+
it("fillFromResult matches fillActions(toSidebarItem)", () => {
const r = mbResult("m1", "T", "A", "Al", 2, 90);
expect(fillFromResult("s1", r)).toEqual(fillActions("s1", toSidebarItem(r)));
});
+
+ it("fillFromResult carries artUrl through to an editSegmentAlbumArt action", () => {
+ const r: MetadataResult = {
+ id: "m1",
+ type: "recording",
+ title: "T",
+ artist: "A",
+ score: 80,
+ artUrl: "https://coverartarchive.org/release/xyz/front",
+ };
+ expect(fillFromResult("s1", r)).toEqual(fillActions("s1", toSidebarItem(r)));
+ expect(fillFromResult("s1", r)).toContainEqual({
+ type: "editSegmentAlbumArt",
+ segmentId: "s1",
+ albumArt: { kind: "url", url: "https://coverartarchive.org/release/xyz/front" },
+ });
+ });
});
// ─── match-album → actions ───────────────────────────────────────────────────