test(player): stub likes API in queue component tests — #1596
test-web / test (push) Failing after 33s
test-web / test (push) Failing after 33s
QueueTrackRow now renders a LikeButton, which reads createLikedIdsQuery and needs a QueryClient in Svelte context. The QueueTrackRow / QueueDrawer unit tests render the rows without one, so they failed with "No QueryClient was found in Svelte context". Mock $lib/api/likes with the shared emptyLikesMock() helper — the same pattern PlayerBar/TrackMenu and 17 other component tests already use. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,12 @@ import { render, screen, fireEvent } from '@testing-library/svelte';
|
||||
import QueueDrawer from './QueueDrawer.svelte';
|
||||
import type { TrackRef } from '$lib/api/types';
|
||||
import { makeTrack } from '$test-utils/fixtures/track';
|
||||
import { emptyLikesMock } from '../../test-utils/mocks/likes';
|
||||
|
||||
// QueueTrackRow (rendered inside QueueDrawer → QueueList) now renders a
|
||||
// LikeButton, which reads createLikedIdsQuery. Stub the likes API so the
|
||||
// rows don't need a real QueryClient in context.
|
||||
vi.mock('$lib/api/likes', () => emptyLikesMock());
|
||||
|
||||
const closeQueueDrawer = vi.fn();
|
||||
let queueValue: TrackRef[] = [];
|
||||
|
||||
@@ -2,6 +2,11 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
import { render, screen, fireEvent } from '@testing-library/svelte';
|
||||
import QueueTrackRow from './QueueTrackRow.svelte';
|
||||
import { makeTrack } from '$test-utils/fixtures/track';
|
||||
import { emptyLikesMock } from '../../test-utils/mocks/likes';
|
||||
|
||||
// QueueTrackRow now renders a LikeButton, which reads createLikedIdsQuery.
|
||||
// Stub the likes API so the row doesn't need a real QueryClient in context.
|
||||
vi.mock('$lib/api/likes', () => emptyLikesMock());
|
||||
|
||||
const playFromQueueIndex = vi.fn();
|
||||
const removeFromQueue = vi.fn();
|
||||
|
||||
Reference in New Issue
Block a user