this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

test(firehose): added test case for tracks with artists

ansxor 3614c7ba e0f0bde3

+55
+55
apps/firehose/tests/firehose.test.ts
··· 79 79 }, 80 80 }; 81 81 82 + const createTrackWithArtistsEvent: JetstreamEvent = { 83 + did: SAMPLE_DID, 84 + time_us: Date.now() * 1000, 85 + kind: "commit", 86 + commit: { 87 + operation: "create", 88 + collection: SAMPLE_COLLECTION, 89 + rkey: SAMPLE_RKEY, 90 + rev: "3jui7kd54zh2i", 91 + cid: SAMPLE_CID, 92 + record: { 93 + $type: "ca.ansxor.catnip.track", 94 + title: "Midnight Echoes", 95 + createdAt: new Date().toISOString(), 96 + audio: { 97 + $type: "blob", 98 + ref: { 99 + $link: "bafyreig2fjxi3a743bb54z2at6lsv2brz4f5d3hefma6ludqt5d2k2ofey", 100 + }, 101 + mimeType: "audio/ogg", 102 + size: 5_000_000, 103 + }, 104 + artists: [ 105 + { did: SAMPLE_DID, name: "Echo Artist" }, 106 + { name: "Guest Vocalist" }, 107 + ], 108 + } satisfies InferOutput<typeof CaAnsxorCatnipTrack.mainSchema>, 109 + }, 110 + }; 111 + 82 112 test("inserts track from create commit event", async () => { 83 113 const subscription = mockSubscription([createTrackEvent]); 84 114 await loop(subscription, txDb); ··· 95 125 expect(track!.cid).toBe(SAMPLE_CID); 96 126 expect(track!.title).toBe("Midnight Echoes"); 97 127 }); 128 + 129 + test("inserts artists from create commit event", async () => { 130 + const subscription = mockSubscription([createTrackWithArtistsEvent]); 131 + await loop(subscription, txDb); 132 + 133 + const artists = await txDb.query.artists.findMany(); 134 + expect(artists).toHaveLength(2); 135 + 136 + const didArtist = artists.find((a) => a.did === SAMPLE_DID); 137 + expect(didArtist).not.toBeUndefined(); 138 + expect(didArtist!.name).toBe("Echo Artist"); 139 + 140 + const nameOnlyArtist = artists.find((a) => a.name === "Guest Vocalist"); 141 + expect(nameOnlyArtist).not.toBeUndefined(); 142 + expect(nameOnlyArtist!.did).toBeNull(); 143 + 144 + const trackArtistLinks = await txDb.query.trackArtists.findMany({ 145 + orderBy: (ta, { asc }) => [asc(ta.position)], 146 + }); 147 + expect(trackArtistLinks).toHaveLength(2); 148 + expect(trackArtistLinks[0]!.artistId).toBe(didArtist!.id); 149 + expect(trackArtistLinks[0]!.position).toBe(0); 150 + expect(trackArtistLinks[1]!.artistId).toBe(nameOnlyArtist!.id); 151 + expect(trackArtistLinks[1]!.position).toBe(1); 152 + });