fix(web): add player stub to player-store mocks for TrackRow tests
#401 introduced player.current?.id reads into TrackRow.svelte and PlaylistTrackRow.svelte, breaking 26 test cases across 6 files whose existing vi.mock('$lib/player/store.svelte', ...) blocks only stubbed the functions used by the original components. Added player: { current: undefined } to each affected mock — keeps the existing function spies and lets the new isCurrent derivation read a defined (false-y) player.current without blowing up. Only updated the 6 files that failed; 16 other player-store mocks exist across the suite but their tests don't render Track/Playlist rows so the derivation never fires. Future tests that render those rows will need the same stub (visible at the failure point with a clear error message). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -29,7 +29,8 @@ vi.mock('$lib/player/store.svelte', () => ({
|
||||
playNext: vi.fn(),
|
||||
enqueueTrack: vi.fn(),
|
||||
playQueue: vi.fn(),
|
||||
playRadio: vi.fn()
|
||||
playRadio: vi.fn(),
|
||||
player: { current: undefined }
|
||||
}));
|
||||
|
||||
import PlaylistTrackRow from './PlaylistTrackRow.svelte';
|
||||
|
||||
@@ -8,7 +8,8 @@ import { makeTrack } from '$test-utils/fixtures/track';
|
||||
vi.mock('$lib/player/store.svelte', () => ({
|
||||
playQueue: vi.fn(),
|
||||
enqueueTrack: vi.fn(),
|
||||
playRadio: vi.fn()
|
||||
playRadio: vi.fn(),
|
||||
player: { current: undefined }
|
||||
}));
|
||||
|
||||
vi.mock('$lib/api/likes', () => emptyLikesMock());
|
||||
|
||||
@@ -21,7 +21,8 @@ vi.mock('$lib/api/likes', () => ({
|
||||
|
||||
vi.mock('$lib/api/client', () => apiClientMock());
|
||||
vi.mock('$lib/player/store.svelte', () => ({
|
||||
playQueue: vi.fn(), enqueueTrack: vi.fn(), enqueueTracks: vi.fn()
|
||||
playQueue: vi.fn(), enqueueTrack: vi.fn(), enqueueTracks: vi.fn(),
|
||||
player: { current: undefined }
|
||||
}));
|
||||
|
||||
import LikedPage from './+page.svelte';
|
||||
|
||||
@@ -30,7 +30,8 @@ vi.mock('$lib/player/store.svelte', () => ({
|
||||
playQueue: vi.fn(),
|
||||
enqueueTracks: vi.fn(),
|
||||
playNext: vi.fn(),
|
||||
enqueueTrack: vi.fn()
|
||||
enqueueTrack: vi.fn(),
|
||||
player: { current: undefined }
|
||||
}));
|
||||
|
||||
// Cascade through PlaylistTrackRow's mocks (LikeButton + TrackMenu transitively).
|
||||
|
||||
@@ -21,7 +21,8 @@ vi.mock('$lib/player/store.svelte', () => ({
|
||||
playQueue: vi.fn(),
|
||||
playRadio: vi.fn(),
|
||||
enqueueTrack: vi.fn(),
|
||||
enqueueTracks: vi.fn()
|
||||
enqueueTracks: vi.fn(),
|
||||
player: { current: undefined }
|
||||
}));
|
||||
|
||||
vi.mock('$lib/api/client', () => apiClientMock());
|
||||
|
||||
@@ -18,7 +18,8 @@ vi.mock('$lib/api/queries', () => ({
|
||||
vi.mock('$lib/player/store.svelte', () => ({
|
||||
playQueue: vi.fn(),
|
||||
playRadio: vi.fn(),
|
||||
enqueueTrack: vi.fn()
|
||||
enqueueTrack: vi.fn(),
|
||||
player: { current: undefined }
|
||||
}));
|
||||
|
||||
vi.mock('$lib/api/likes', () => emptyLikesMock());
|
||||
|
||||
Reference in New Issue
Block a user