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:
2026-05-10 15:58:14 -04:00
co-authored by Claude Opus 4.7
parent 993bcc6a14
commit 9b4f907db6
24 changed files with 95 additions and 202 deletions
+7 -9
View File
@@ -2,6 +2,7 @@ import { afterEach, describe, expect, test, vi } from 'vitest';
import { render, screen, fireEvent } from '@testing-library/svelte';
import { emptyLikesMock } from '../../test-utils/mocks/likes';
import type { ArtistRef, TrackRef } from '$lib/api/types';
import { makeTrack, makeTracks } from '$test-utils/fixtures/track';
vi.mock('$lib/api/client', () => ({
api: { get: vi.fn() }
@@ -46,14 +47,11 @@ describe('ArtistCard', () => {
});
test('play overlay fetches tracks, shuffles, calls playQueue', async () => {
const tracks: TrackRef[] = [
{ id: 't1', title: 'A', album_id: 'al-1', album_title: 'X',
artist_id: 'art-1', artist_name: 'BoC',
track_number: 1, disc_number: 1, duration_sec: 1, stream_url: '/x' },
{ id: 't2', title: 'B', album_id: 'al-1', album_title: 'X',
artist_id: 'art-1', artist_name: 'BoC',
track_number: 2, disc_number: 1, duration_sec: 1, stream_url: '/x' }
];
const tracks: TrackRef[] = makeTracks(2, {
album_id: 'al-1', album_title: 'X',
artist_id: 'art-1', artist_name: 'BoC',
duration_sec: 1
});
(api.get as ReturnType<typeof vi.fn>).mockResolvedValueOnce(tracks);
render(ArtistCard, { props: { artist } });
@@ -83,7 +81,7 @@ describe('ArtistCard', () => {
test('+queue button calls listArtistTracks then enqueueTracks', async () => {
const fakeTracks = [
{ id: 't1', title: 'A', album_id: 'al1', album_title: 'X', artist_id: 'art-1', artist_name: 'BoC', duration_sec: 60, stream_url: '/s/t1' }
makeTrack({ artist_id: 'art-1', artist_name: 'BoC' })
];
const { listArtistTracks } = await import('$lib/api/artists');
(listArtistTracks as unknown as ReturnType<typeof vi.fn>).mockResolvedValueOnce(fakeTracks);