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:
@@ -21,16 +21,15 @@ import {
|
||||
} from './store.svelte';
|
||||
import { api } from '$lib/api/client';
|
||||
import type { TrackRef } from '$lib/api/types';
|
||||
import { makeTrack } from '$test-utils/fixtures/track';
|
||||
|
||||
function track(id: string, dur = 200): TrackRef {
|
||||
return {
|
||||
id, title: `T ${id}`,
|
||||
album_id: 'a', album_title: 'A',
|
||||
artist_id: 'ar', artist_name: 'Ar',
|
||||
track_number: Number(id), disc_number: 1,
|
||||
return makeTrack({
|
||||
id,
|
||||
title: `T ${id}`,
|
||||
duration_sec: dur,
|
||||
stream_url: `/api/tracks/${id}/stream`
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
|
||||
import { flushSync } from 'svelte';
|
||||
import type { TrackRef } from '$lib/api/types';
|
||||
import { makeTrack } from '$test-utils/fixtures/track';
|
||||
|
||||
function track(id: string): TrackRef {
|
||||
return {
|
||||
id, title: `T ${id}`,
|
||||
album_id: 'a1', album_title: 'A',
|
||||
artist_id: 'ar1', artist_name: 'Ar',
|
||||
track_number: Number(id), disc_number: 1,
|
||||
duration_sec: 180, stream_url: `/api/tracks/${id}/stream`
|
||||
};
|
||||
return makeTrack({
|
||||
id,
|
||||
title: `T ${id}`,
|
||||
stream_url: `/api/tracks/${id}/stream`
|
||||
});
|
||||
}
|
||||
|
||||
type Handler = (details: MediaSessionActionDetails) => void;
|
||||
|
||||
@@ -1,17 +1,8 @@
|
||||
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
|
||||
import { readPersistedQueue, writePersistedQueue, clearPersistedQueue } from './persisted';
|
||||
import type { TrackRef } from '$lib/api/types';
|
||||
import { makeTrack } from '$test-utils/fixtures/track';
|
||||
|
||||
const sampleTrack: TrackRef = {
|
||||
id: 't1',
|
||||
title: 'Foo',
|
||||
album_id: 'al1',
|
||||
album_title: 'Baz',
|
||||
artist_id: 'ar1',
|
||||
artist_name: 'Bar',
|
||||
duration_sec: 200,
|
||||
stream_url: '/stream/t1'
|
||||
};
|
||||
const sampleTrack = makeTrack();
|
||||
|
||||
describe('persisted queue', () => {
|
||||
beforeEach(() => {
|
||||
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
} from './store.svelte';
|
||||
import type { TrackRef } from '$lib/api/types';
|
||||
import { writePersistedQueue, clearPersistedQueue } from './persisted';
|
||||
import { makeTrack } from '$test-utils/fixtures/track';
|
||||
|
||||
vi.mock('$lib/auth/store.svelte', () => ({
|
||||
user: {
|
||||
@@ -29,14 +30,12 @@ vi.mock('$lib/auth/store.svelte', () => ({
|
||||
}));
|
||||
|
||||
function track(id: string, dur = 180): TrackRef {
|
||||
return {
|
||||
id, title: `T ${id}`,
|
||||
album_id: 'a1', album_title: 'A',
|
||||
artist_id: 'ar1', artist_name: 'Ar',
|
||||
track_number: Number(id), disc_number: 1,
|
||||
return makeTrack({
|
||||
id,
|
||||
title: `T ${id}`,
|
||||
duration_sec: dur,
|
||||
stream_url: `/api/tracks/${id}/stream`
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
Reference in New Issue
Block a user