From 2ec54bc429597b1819d85f7dd15899283a784d56 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Sun, 10 May 2026 15:42:57 -0400 Subject: [PATCH] refactor(web): sweep playlist.test.ts to use emptyQuarantineMock() (#375) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaces the hand-rolled { subscribe, data } quarantine stub with the emptyQuarantineMock() helper. readable() satisfies the same store contract the page actually uses (subscription via $store), and the playlist tests don't assert on quarantine state — the mock is purely a transitive module-load satisfier (PlaylistTrackRow → TrackMenu). Companion to commit 7e8d196 (likes sweep), which initially skipped this file because it shared the hand-rolled stub shape with the likes mock; the quarantine half can safely move to the helper. Five other files in the original 8-file batch (PlaylistTrackRow, TrackMenu, TrackRow, PlayerBar, CompactTrackCard) were absorbed into that likes-sweep commit; search/tracks was absorbed into commit dd67f28 (pageUrl sweep). hidden.test.ts SKIPPED — it imports createMyQuarantineQuery as a vi.fn() to mockReturnValue per-test and asserts on unflagTrack call args; the helper would defeat both. Co-Authored-By: Claude Opus 4.7 (1M context) --- web/src/routes/playlists/[id]/playlist.test.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/web/src/routes/playlists/[id]/playlist.test.ts b/web/src/routes/playlists/[id]/playlist.test.ts index 81621589..4c6f5a10 100644 --- a/web/src/routes/playlists/[id]/playlist.test.ts +++ b/web/src/routes/playlists/[id]/playlist.test.ts @@ -1,6 +1,7 @@ import { describe, expect, test, vi } from 'vitest'; import { render, screen, fireEvent, waitFor } from '@testing-library/svelte'; import { mockQuery } from '../../../test-utils/query'; +import { emptyQuarantineMock } from '../../../test-utils/mocks/quarantine'; import type { PlaylistDetail } from '$lib/api/types'; // Project canonical: $app/state (rune-state), not $app/stores (legacy @@ -38,11 +39,7 @@ vi.mock('$lib/api/likes', () => ({ likeEntity: vi.fn(), unlikeEntity: vi.fn() })); -vi.mock('$lib/api/quarantine', () => ({ - createMyQuarantineQuery: () => ({ subscribe: () => () => {}, data: [] }), - flagTrack: vi.fn(), - unflagTrack: vi.fn() -})); +vi.mock('$lib/api/quarantine', () => emptyQuarantineMock()); vi.mock('$lib/api/admin/tracks', () => ({ removeTrack: vi.fn() })); import PlaylistDetailPage from './+page.svelte';