Skip to content

Commit ba85cd8

Browse files
GraysonCAdamsclaude
andcommitted
Fix test failures: update mocks and assertions for new features
- Add SpotifyRateLimitError to spotify mock in tracks route test - Add missing date fields (createdAt, addedAt) in playlists route test - Add notifyCircleMembers to notifications mock - Update notification-prefs test to expect 7 types (added newSwaplist) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 767a743 commit ba85cd8

3 files changed

Lines changed: 21 additions & 3 deletions

File tree

src/app/api/playlists/[playlistId]/tracks/route.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ vi.mock('@/lib/spotify', () => ({
3636
this.circleId = circleId;
3737
}
3838
},
39+
SpotifyRateLimitError: class SpotifyRateLimitError extends Error {
40+
path: string;
41+
retryAfterSeconds: number;
42+
constructor(path: string, retryAfterSeconds: number) {
43+
super(`Spotify rate limit on ${path} — retry after ${retryAfterSeconds}s`);
44+
this.name = 'SpotifyRateLimitError';
45+
this.path = path;
46+
this.retryAfterSeconds = retryAfterSeconds;
47+
}
48+
},
3949
}));
4050

4151
vi.mock('@/lib/rate-limit', () => ({

src/app/api/playlists/__tests__/route.test.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ vi.mock('@/lib/utils', () => ({
7373
}));
7474

7575
// Mock notifications and other side effects
76-
vi.mock('@/lib/notifications', () => ({ notifyPlaylistMembers: vi.fn() }));
76+
vi.mock('@/lib/notifications', () => ({
77+
notifyPlaylistMembers: vi.fn(),
78+
notifyCircleMembers: vi.fn(),
79+
}));
7780
vi.mock('@/lib/playlist-sort', () => ({ sortPlaylistTracks: vi.fn() }));
7881
vi.mock('@/lib/polling', () => ({ setAutoReaction: vi.fn() }));
7982
vi.mock('@/lib/logger', () => ({
@@ -232,20 +235,24 @@ describe('GET /api/playlists', () => {
232235
},
233236
},
234237
],
238+
createdAt: new Date('2025-01-01T00:00:00Z'),
235239
tracks: [
236240
{
237241
spotifyTrackId: 'track-1',
238242
addedByUserId: 'user-2',
243+
addedAt: new Date('2025-01-02T00:00:00Z'),
239244
removedAt: null,
240245
},
241246
{
242247
spotifyTrackId: 'track-2',
243248
addedByUserId: 'user-1',
249+
addedAt: new Date('2025-01-03T00:00:00Z'),
244250
removedAt: null,
245251
},
246252
{
247253
spotifyTrackId: 'track-3',
248254
addedByUserId: 'user-2',
255+
addedAt: new Date('2025-01-04T00:00:00Z'),
249256
removedAt: new Date(), // removed track
250257
},
251258
],

src/lib/notification-prefs.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,10 @@ describe('DEFAULT_NOTIFICATION_PREFS', () => {
141141
});
142142

143143
describe('NOTIFICATION_TYPES', () => {
144-
it('contains all six notification types', () => {
145-
expect(NOTIFICATION_TYPES).toHaveLength(6);
144+
it('contains all seven notification types', () => {
145+
expect(NOTIFICATION_TYPES).toHaveLength(7);
146146
expect(NOTIFICATION_TYPES).toContain('newTrack');
147+
expect(NOTIFICATION_TYPES).toContain('newSwaplist');
147148
expect(NOTIFICATION_TYPES).toContain('memberJoined');
148149
expect(NOTIFICATION_TYPES).toContain('reactions');
149150
expect(NOTIFICATION_TYPES).toContain('trackRemoved');

0 commit comments

Comments
 (0)