Files
minstrel/web/src/routes/library/hidden/hidden.test.ts
T
bvandeusenandClaude Opus 5.5 4e1807cbba
release / web (push) Failing after 1m16s
release / go (push) Successful in 1m48s
release / govulncheck (push) Successful in 20s
release / integration (push) Successful in 4m0s
release / android (push) Successful in 4m34s
release / Build signed APK (push) Successful in 5m9s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Skipped
release / Verify release artifacts (tag releases only) (push) Skipped
test: invented artists, albums and MusicBrainz ids in place of real ones
Test data and example comments named real artists, records and songs, and
carried real MusicBrainz ids. One mapping swaps them for invented ones
throughout (Fields of Ontario, Plastic Apes, Marlo Davies, ...), keeping
what each case tests: sort order, index letter, escaping, title keys,
artist-prefix stripping. A test username is no longer the operator's name.

The cover-art and Last.fm connection checks still query real releases;
they reach live services and need something that exists there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 13:21:34 -05:00

60 lines
2.3 KiB
TypeScript

import { afterEach, describe, expect, test, vi } from 'vitest';
import { render, screen, fireEvent } from '@testing-library/svelte';
import { mockQuery } from '../../../test-utils/query';
vi.mock('#lib/api/quarantine.js', () => ({
createMyQuarantineQuery: vi.fn(),
unflagTrack: vi.fn().mockResolvedValue(undefined)
}));
import HiddenPage from './+page.svelte';
import { createMyQuarantineQuery, unflagTrack } from '#lib/api/quarantine.js';
import type { QuarantineMineRow } from '#lib/api/types.js';
const baseRow: QuarantineMineRow = {
track_id: 't1',
reason: 'bad_rip',
notes: 'crackles',
created_at: new Date(Date.now() - 2 * 24 * 3_600_000).toISOString(), // 2 days ago
track_title: 'Prismatic',
track_duration_ms: 200000,
album_id: 'a1',
album_title: 'Geomantic',
album_cover_art_path: null,
artist_id: 'ar1',
artist_name: 'Fields of Ontario'
};
afterEach(() => vi.clearAllMocks());
describe('/library/hidden', () => {
test('renders one row per quarantine with title + meta + reason pill + notes', () => {
(createMyQuarantineQuery as ReturnType<typeof vi.fn>).mockReturnValue(mockQuery({ data: [baseRow] }));
render(HiddenPage);
expect(screen.getByText('Prismatic')).toBeInTheDocument();
expect(screen.getByText(/by fields of ontario · geomantic/i)).toBeInTheDocument();
expect(screen.getByText('Bad rip')).toBeInTheDocument();
expect(screen.getByText('crackles')).toBeInTheDocument();
});
test('un-hide button calls unflagTrack', async () => {
(createMyQuarantineQuery as ReturnType<typeof vi.fn>).mockReturnValue(mockQuery({ data: [baseRow] }));
render(HiddenPage);
await fireEvent.click(screen.getByRole('button', { name: /un-hide prismatic/i }));
expect(unflagTrack).toHaveBeenCalledWith('t1');
});
test('empty state shows "Nothing hidden yet."', () => {
(createMyQuarantineQuery as ReturnType<typeof vi.fn>).mockReturnValue(mockQuery({ data: [] }));
render(HiddenPage);
expect(screen.getByText(/nothing hidden yet/i)).toBeInTheDocument();
});
test('notes are absent when row.notes is null', () => {
const row = { ...baseRow, notes: null };
(createMyQuarantineQuery as ReturnType<typeof vi.fn>).mockReturnValue(mockQuery({ data: [row] }));
render(HiddenPage);
expect(screen.queryByText('crackles')).not.toBeInTheDocument();
});
});