4f6c5995f8
New /library: GET /api/library lists LibraryItems enriched with rgMbid + year from the matching MonitoredRelease. Client renders a cover-art grid with a live filter; clicking an album opens the AlbumModal (tracklist). Added Library to the nav. The album-only overview to see everything downloaded. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
30 lines
1.3 KiB
TypeScript
30 lines
1.3 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
import { prisma } from "@/lib/db";
|
|
import { GET } from "./route";
|
|
|
|
describe("library API", () => {
|
|
it("lists owned albums enriched with rgMbid + year from the matching release", async () => {
|
|
await prisma.monitoredRelease.create({
|
|
data: {
|
|
artistMbid: "a1", artistName: "Radiohead", rgMbid: "rg-inrainbows", album: "In Rainbows",
|
|
primaryType: "Album", firstReleaseDate: "2007-10-10", monitored: true, state: "fulfilled",
|
|
},
|
|
});
|
|
await prisma.libraryItem.create({
|
|
data: { artist: "Radiohead", album: "In Rainbows", path: "/m", source: "qobuz", format: "FLAC", qualityClass: 3 },
|
|
});
|
|
await prisma.libraryItem.create({
|
|
data: { artist: "Unknown", album: "Bootleg", path: "/m", source: "scan", format: "MP3", qualityClass: 1 },
|
|
});
|
|
|
|
const res = await GET();
|
|
expect(res.status).toBe(200);
|
|
const { albums } = await res.json();
|
|
expect(albums).toHaveLength(2);
|
|
const inr = albums.find((a: { album: string }) => a.album === "In Rainbows");
|
|
expect(inr).toMatchObject({ artist: "Radiohead", rgMbid: "rg-inrainbows", year: "2007", format: "FLAC", qualityClass: 3 });
|
|
const boot = albums.find((a: { album: string }) => a.album === "Bootleg");
|
|
expect(boot).toMatchObject({ rgMbid: null, year: null }); // no matching release → no art/tracks
|
|
});
|
|
});
|