feat: filter artist discography + counts to core releases unless showAllTypes
This commit is contained in:
@@ -57,4 +57,26 @@ describe("artists collection API", () => {
|
||||
const a = (await res.json()).artists[0];
|
||||
expect(a).toMatchObject({ mbid: "a1", name: "John Mayer", releaseCount: 1, monitoredCount: 1, haveCount: 1 });
|
||||
});
|
||||
|
||||
it("counts only core releases unless showAllTypes is set", async () => {
|
||||
await prisma.watchedArtist.create({
|
||||
data: {
|
||||
mbid: "a2",
|
||||
name: "Live Band",
|
||||
releases: {
|
||||
create: [
|
||||
{ artistMbid: "a2", artistName: "Live Band", rgMbid: "rg-core", album: "Studio Album", primaryType: "Album", secondaryTypes: [], firstReleaseDate: "2010", monitored: true, state: "grabbed", currentQualityClass: 1 },
|
||||
{ artistMbid: "a2", artistName: "Live Band", rgMbid: "rg-live", album: "Live at the Roxy", primaryType: "Album", secondaryTypes: ["Live"], firstReleaseDate: "2011", monitored: true, state: "wanted", currentQualityClass: 2 },
|
||||
],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const before = (await (await GET()).json()).artists.find((a: { mbid: string }) => a.mbid === "a2");
|
||||
expect(before).toMatchObject({ showAllTypes: false, releaseCount: 1, monitoredCount: 1, haveCount: 1 });
|
||||
|
||||
await prisma.watchedArtist.update({ where: { mbid: "a2" }, data: { showAllTypes: true } });
|
||||
const after = (await (await GET()).json()).artists.find((a: { mbid: string }) => a.mbid === "a2");
|
||||
expect(after).toMatchObject({ showAllTypes: true, releaseCount: 2, monitoredCount: 2, haveCount: 2 });
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user