refactor(web): sweep 24 test files to use makeTrack/makeTracks fixtures (#375)
Replaces inline TrackRef literal redefinitions with calls to the test-utils helper. Tests that asserted on default field values (e.g. track titles, artist names rendered in the DOM) keep explicit overrides; tests that only need a stub for shape now use makeTrack() with no overrides. PlaylistCard.test.ts, PlaylistTrackRow.test.ts, and playlist.test.ts SKIPPED — they use PlaylistTrack (with track_id/added_at), not TrackRef. ArtistCard.svelte and +page.svelte route files (matched by initial grep) SKIPPED — live code, not test files. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@ import type { TrackRef } from '$lib/api/types';
|
||||
import { readable } from 'svelte/store';
|
||||
import { emptyLikesMock } from '../../test-utils/mocks/likes';
|
||||
import { emptyQuarantineMock } from '../../test-utils/mocks/quarantine';
|
||||
import { makeTracks } from '$test-utils/fixtures/track';
|
||||
|
||||
vi.mock('$lib/api/likes', () => emptyLikesMock());
|
||||
|
||||
@@ -35,17 +36,11 @@ vi.mock('$lib/player/store.svelte', () => ({
|
||||
import CompactTrackCard from './CompactTrackCard.svelte';
|
||||
import { playQueue, enqueueTrack } from '$lib/player/store.svelte';
|
||||
|
||||
const tracks: TrackRef[] = [
|
||||
{ id: 't1', title: 'First', album_id: 'a1', album_title: 'A',
|
||||
artist_id: 'art-1', artist_name: 'Artist',
|
||||
track_number: 1, disc_number: 1, duration_sec: 1, stream_url: '/a' },
|
||||
{ id: 't2', title: 'Second', album_id: 'a1', album_title: 'A',
|
||||
artist_id: 'art-1', artist_name: 'Artist',
|
||||
track_number: 2, disc_number: 1, duration_sec: 1, stream_url: '/b' },
|
||||
{ id: 't3', title: 'Third', album_id: 'a1', album_title: 'A',
|
||||
artist_id: 'art-1', artist_name: 'Artist',
|
||||
track_number: 3, disc_number: 1, duration_sec: 1, stream_url: '/c' }
|
||||
];
|
||||
const titles = ['First', 'Second', 'Third'];
|
||||
const tracks: TrackRef[] = makeTracks(3, { artist_name: 'Artist' }).map((t, i) => ({
|
||||
...t,
|
||||
title: titles[i]
|
||||
}));
|
||||
|
||||
afterEach(() => vi.clearAllMocks());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user