test: invented artists, albums and MusicBrainz ids in place of real ones
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 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>
This commit is contained in:
2026-11-25 13:21:34 -05:00
co-authored by Claude Opus 5.5
parent 4244d81dfd
commit 4e1807cbba
80 changed files with 570 additions and 570 deletions
+6 -6
View File
@@ -29,9 +29,9 @@ beforeEach(() => {
const baseQuarantineRow: AdminQuarantineRow = {
track_id: 't1',
track_title: 'Avril 14th',
artist_name: 'Aphex Twin',
album_title: 'Drukqs',
track_title: 'Juin 21st',
artist_name: 'Apex Sibling',
album_title: 'Drumkits',
album_id: 'alb1',
report_count: 1,
latest_at: '2026-01-01T00:00:00Z',
@@ -47,9 +47,9 @@ const baseAction: ActionResult = {
const baseActionRow: QuarantineActionRow = {
id: 'a1',
track_id: 't1',
track_title: 'Avril 14th',
artist_name: 'Aphex Twin',
album_title: 'Drukqs',
track_title: 'Juin 21st',
artist_name: 'Apex Sibling',
album_title: 'Drumkits',
action: 'resolved',
admin_id: 'admin1',
affected_users: 1,
+3 -3
View File
@@ -31,13 +31,13 @@ const mockMineRow: QuarantineMineRow = {
reason: 'bad_rip',
notes: null,
created_at: '2026-01-01T00:00:00Z',
track_title: 'Avril 14th',
track_title: 'Juin 21st',
track_duration_ms: 120000,
album_id: 'alb1',
album_title: 'Drukqs',
album_title: 'Drumkits',
album_cover_art_path: null,
artist_id: 'art1',
artist_name: 'Aphex Twin'
artist_name: 'Apex Sibling'
};
beforeEach(() => {
+4 -4
View File
@@ -150,9 +150,9 @@ describe("AcoustIDCard", () => {
vi.mocked(listUnsettledAcoustID).mockResolvedValue([
{
track_id: "t1",
title: "WWW",
artist: "Moe Shop",
album: "WWW",
title: "XYZ",
artist: "Mochi Shop",
album: "XYZ",
file_path: "/music/a.mp3",
state: "ambiguous",
best_score: 0.97,
@@ -168,7 +168,7 @@ describe("AcoustIDCard", () => {
details.open = true;
await fireEvent(details, new Event("toggle"));
const list = await screen.findByTestId("acoustid-unsettled");
expect(list.textContent).toMatch(/WWW/);
expect(list.textContent).toMatch(/XYZ/);
expect(list.textContent).toMatch(/2 recordings/);
});
+14 -14
View File
@@ -39,10 +39,10 @@ import { enqueueTracks, playQueue } from '#lib/player/store.svelte.js';
const album: AlbumRef = {
id: 'xyz',
title: 'Kind of Blue',
sort_title: 'Kind of Blue',
artist_id: 'm-davis',
artist_name: 'Miles Davis',
title: 'Kind of Grey',
sort_title: 'Kind of Grey',
artist_id: 'm-davies',
artist_name: 'Marlo Davies',
year: 1959,
track_count: 5,
duration_sec: 2630,
@@ -57,8 +57,8 @@ describe('AlbumCard', () => {
const { container } = render(AlbumCard, { props: { album } });
const link = screen.getByRole('link');
expect(link).toHaveAttribute('href', '/albums/xyz');
expect(link).toHaveTextContent('Kind of Blue');
expect(link).toHaveTextContent('Miles Davis');
expect(link).toHaveTextContent('Kind of Grey');
expect(link).toHaveTextContent('Marlo Davies');
// The year is intentionally omitted from the Home tile —
// dropped in the visual polish pass; the album detail page
// still shows it.
@@ -85,9 +85,9 @@ describe('AlbumCard', () => {
test('+ queue button fetches album detail and calls enqueueTracks', async () => {
const tracks: TrackRef[] = [
makeTrack({
title: 'So What',
album_id: 'xyz', album_title: 'Kind of Blue',
artist_id: 'm-davis', artist_name: 'Miles Davis',
title: 'So Then',
album_id: 'xyz', album_title: 'Kind of Grey',
artist_id: 'm-davies', artist_name: 'Marlo Davies',
duration_sec: 545
})
];
@@ -106,9 +106,9 @@ describe('AlbumCard', () => {
test('play overlay click fetches album detail and calls playQueue at index 0', async () => {
const tracks: TrackRef[] = [
makeTrack({
title: 'So What',
album_id: 'xyz', album_title: 'Kind of Blue',
artist_id: 'm-davis', artist_name: 'Miles Davis',
title: 'So Then',
album_id: 'xyz', album_title: 'Kind of Grey',
artist_id: 'm-davies', artist_name: 'Marlo Davies',
duration_sec: 545
})
];
@@ -116,7 +116,7 @@ describe('AlbumCard', () => {
(api.get as ReturnType<typeof vi.fn>).mockResolvedValueOnce(detail);
render(AlbumCard, { props: { album } });
await fireEvent.click(screen.getByRole('button', { name: /play kind of blue/i }));
await fireEvent.click(screen.getByRole('button', { name: /play kind of grey/i }));
expect(api.get).toHaveBeenCalledWith('/api/albums/xyz');
await Promise.resolve();
await Promise.resolve();
@@ -125,6 +125,6 @@ describe('AlbumCard', () => {
test('renders the bottom-right kebab menu trigger', () => {
render(AlbumCard, { props: { album } });
expect(screen.getByRole('button', { name: /Album actions for Kind of Blue/i })).toBeInTheDocument();
expect(screen.getByRole('button', { name: /Album actions for Kind of Grey/i })).toBeInTheDocument();
});
});
+8 -8
View File
@@ -20,8 +20,8 @@ import { playQueue } from '#lib/player/store.svelte.js';
const artist: ArtistRef = {
id: 'art-1',
name: 'Boards of Canada',
sort_name: 'Boards of Canada',
name: 'Fields of Ontario',
sort_name: 'Fields of Ontario',
album_count: 5,
cover_url: '/api/albums/cov-1/cover'
};
@@ -48,13 +48,13 @@ describe('ArtistCard', () => {
test('play overlay fetches tracks, shuffles, calls playQueue', async () => {
const tracks: TrackRef[] = makeTracks(2, {
album_id: 'al-1', album_title: 'X',
artist_id: 'art-1', artist_name: 'BoC',
artist_id: 'art-1', artist_name: 'FoO',
duration_sec: 1
});
(api.get as ReturnType<typeof vi.fn>).mockResolvedValueOnce(tracks);
render(ArtistCard, { props: { artist } });
await fireEvent.click(screen.getByRole('button', { name: /play boards of canada/i }));
await fireEvent.click(screen.getByRole('button', { name: /play fields of ontario/i }));
expect(api.get).toHaveBeenCalledWith('/api/artists/art-1/tracks');
await Promise.resolve();
await Promise.resolve();
@@ -70,22 +70,22 @@ describe('ArtistCard', () => {
// Like button (LikeButton's aria-label is dynamic Like|Unlike).
expect(screen.getByRole('button', { name: /^(Like|Unlike)$/ })).toBeInTheDocument();
// Add-to-queue button.
expect(screen.getByRole('button', { name: /Add Boards of Canada to queue/i })).toBeInTheDocument();
expect(screen.getByRole('button', { name: /Add Fields of Ontario to queue/i })).toBeInTheDocument();
});
test('renders the bottom-right kebab', () => {
render(ArtistCard, { props: { artist } });
expect(screen.getByRole('button', { name: /Artist actions for Boards of Canada/i })).toBeInTheDocument();
expect(screen.getByRole('button', { name: /Artist actions for Fields of Ontario/i })).toBeInTheDocument();
});
test('+queue button calls listArtistTracks then enqueueTracks', async () => {
const fakeTracks = [
makeTrack({ artist_id: 'art-1', artist_name: 'BoC' })
makeTrack({ artist_id: 'art-1', artist_name: 'FoO' })
];
const { listArtistTracks } = await import('#lib/api/artists.js');
(listArtistTracks as unknown as ReturnType<typeof vi.fn>).mockResolvedValueOnce(fakeTracks);
render(ArtistCard, { props: { artist } });
const btn = screen.getByRole('button', { name: /Add Boards of Canada to queue/i });
const btn = screen.getByRole('button', { name: /Add Fields of Ontario to queue/i });
await fireEvent.click(btn);
// Allow promise microtask to flush.
await new Promise((r) => setTimeout(r, 0));
@@ -39,7 +39,7 @@ function item(over: Partial<NotificationItem> = {}): NotificationItem {
id: 'n1',
kind: 'new_music',
title: 'New album',
body: 'Boards of Canada – Geogaddi is in the library.',
body: 'Fields of Ontario – Geomantic is in the library.',
link: '/albums/al-1',
created_at: new Date().toISOString(),
read_at: null,
@@ -95,7 +95,7 @@ describe('NotificationBell', () => {
test('lists each kind with the server-rendered title and body, unread marked', async () => {
setInbox([
item({ id: 'a', kind: 'new_music', title: 'New album', body: 'Geogaddi is in the library.' }),
item({ id: 'a', kind: 'new_music', title: 'New album', body: 'Geomantic is in the library.' }),
item({
id: 'b',
kind: 'tracks_missing',
@@ -111,7 +111,7 @@ describe('NotificationBell', () => {
const rows = screen.getAllByTestId('notification-item');
expect(rows).toHaveLength(2);
expect(rows[0]).toHaveTextContent('New album');
expect(rows[0]).toHaveTextContent('Geogaddi is in the library.');
expect(rows[0]).toHaveTextContent('Geomantic is in the library.');
expect(rows[0]).toHaveAttribute('data-unread', 'true');
expect(rows[1]).toHaveTextContent('4 tracks went missing');
expect(rows[1]).not.toHaveAttribute('data-unread');
+5 -5
View File
@@ -59,9 +59,9 @@ import {
function track(): TrackRef {
return makeTrack({
title: 'So What',
album_id: 'xyz', album_title: 'Kind of Blue',
artist_id: 'md', artist_name: 'Miles Davis',
title: 'So Then',
album_id: 'xyz', album_title: 'Kind of Grey',
artist_id: 'md', artist_name: 'Marlo Davies',
duration_sec: 545
});
}
@@ -94,10 +94,10 @@ afterEach(() => vi.clearAllMocks());
describe('PlayerBar', () => {
test('renders title, artist, and cover linked to /now-playing', () => {
render(PlayerBar);
expect(compact().getByText('So What')).toBeInTheDocument();
expect(compact().getByText('So Then')).toBeInTheDocument();
// The artist label sits under the title in compact (no link wrapper);
// look for it as plain text.
expect(compact().getByText('Miles Davis')).toBeInTheDocument();
expect(compact().getByText('Marlo Davies')).toBeInTheDocument();
// Cover + title area links to /now-playing (Spotify/YouTube Music
// pattern). Album reachable via the album-name link inside NowPlaying.
const cover = compact().getByRole('link', { name: /open now playing/i });
+11 -11
View File
@@ -36,9 +36,9 @@ const live: PlaylistTrack = {
track_id: 't-1',
album_id: 'a-1',
artist_id: 'ar-1',
title: 'Roygbiv',
artist_name: 'Boards of Canada',
album_title: 'MHTRTC',
title: 'Prismatic',
artist_name: 'Fields of Ontario',
album_title: 'MHTRTW',
duration_sec: 137,
stream_url: '/api/tracks/t-1/stream',
added_at: '',
@@ -69,7 +69,7 @@ describe('PlaylistTrackRow', () => {
render(PlaylistTrackRow, {
props: { row: live, isOwner: true, onRemove: vi.fn(), onPlay: vi.fn() }
});
expect(screen.getByText('Roygbiv')).toBeInTheDocument();
expect(screen.getByText('Prismatic')).toBeInTheDocument();
expect(screen.getByText('2:17')).toBeInTheDocument();
});
@@ -79,7 +79,7 @@ describe('PlaylistTrackRow', () => {
});
expect(screen.getByLabelText(/reorder track/i)).toBeInTheDocument();
expect(
screen.getByLabelText(/Remove Roygbiv from playlist/i)
screen.getByLabelText(/Remove Prismatic from playlist/i)
).toBeInTheDocument();
});
@@ -89,7 +89,7 @@ describe('PlaylistTrackRow', () => {
});
expect(screen.queryByLabelText(/reorder track/i)).not.toBeInTheDocument();
expect(
screen.queryByLabelText(/Remove Roygbiv from playlist/i)
screen.queryByLabelText(/Remove Prismatic from playlist/i)
).not.toBeInTheDocument();
});
@@ -117,7 +117,7 @@ describe('PlaylistTrackRow', () => {
render(PlaylistTrackRow, {
props: { row: removed, isOwner: true, onRemove: vi.fn(), onPlay: vi.fn() }
});
const titleEl = screen.getByText('Roygbiv');
const titleEl = screen.getByText('Prismatic');
expect(titleEl.className).toContain('line-through');
});
@@ -126,7 +126,7 @@ describe('PlaylistTrackRow', () => {
render(PlaylistTrackRow, {
props: { row: live, isOwner: true, onRemove: vi.fn(), onPlay }
});
await fireEvent.click(screen.getByText('Roygbiv'));
await fireEvent.click(screen.getByText('Prismatic'));
expect(onPlay).toHaveBeenCalledWith(2);
});
@@ -137,7 +137,7 @@ describe('PlaylistTrackRow', () => {
props: { row: missingFile, isOwner: true, onRemove: vi.fn(), onPlay: vi.fn() }
});
expect(screen.getByText(/file missing/i)).toBeTruthy();
expect(screen.getByText('Roygbiv').className).not.toContain('line-through');
expect(screen.getByText('Prismatic').className).not.toContain('line-through');
});
test('clicking a missing-file row does not play it', async () => {
@@ -145,7 +145,7 @@ describe('PlaylistTrackRow', () => {
render(PlaylistTrackRow, {
props: { row: missingFile, isOwner: true, onRemove: vi.fn(), onPlay }
});
await fireEvent.click(screen.getByText('Roygbiv'));
await fireEvent.click(screen.getByText('Prismatic'));
expect(onPlay).not.toHaveBeenCalled();
});
@@ -154,6 +154,6 @@ describe('PlaylistTrackRow', () => {
render(PlaylistTrackRow, {
props: { row: missingFile, isOwner: true, onRemove: vi.fn(), onPlay: vi.fn() }
});
expect(screen.getByLabelText(/remove roygbiv from playlist/i)).toBeTruthy();
expect(screen.getByLabelText(/remove prismatic from playlist/i)).toBeTruthy();
});
});
+12 -12
View File
@@ -21,15 +21,15 @@ vi.mock('#lib/api/quarantine.js', () => emptyQuarantineMock());
import TrackListRow from './TrackListRow.svelte';
import { enqueueTrack, playRadio } from '#lib/player/store.svelte.js';
const track = makeTrack({ id: 't1', title: 'Roygbiv', duration_sec: 137 });
const track = makeTrack({ id: 't1', title: 'Prismatic', duration_sec: 137 });
function base(overrides: Record<string, unknown> = {}) {
return {
title: 'Roygbiv',
subtitle: 'Boards of Canada · MHTRTC',
title: 'Prismatic',
subtitle: 'Fields of Ontario · MHTRTW',
durationSec: 137,
track,
ariaLabel: 'Roygbiv',
ariaLabel: 'Prismatic',
onActivate: vi.fn(),
...overrides
};
@@ -43,19 +43,19 @@ afterEach(() => {
describe('TrackListRow', () => {
test('draws title, subtitle and duration', () => {
render(TrackListRow, { props: base() });
expect(screen.getByText('Roygbiv')).toBeInTheDocument();
expect(screen.getByText('Boards of Canada · MHTRTC')).toBeInTheDocument();
expect(screen.getByText('Prismatic')).toBeInTheDocument();
expect(screen.getByText('Fields of Ontario · MHTRTW')).toBeInTheDocument();
expect(screen.getByText('2:17')).toBeInTheDocument();
});
test('a plain row is striped; the now-playing row is banded instead', () => {
const { unmount } = render(TrackListRow, { props: base() });
expect(screen.getByRole('button', { name: 'Roygbiv' }).className).toContain('odd:bg-surface/50');
expect(screen.getByRole('button', { name: 'Prismatic' }).className).toContain('odd:bg-surface/50');
unmount();
player.current = { id: 't1' };
render(TrackListRow, { props: base() });
const row = screen.getByRole('button', { name: 'Roygbiv' });
const row = screen.getByRole('button', { name: 'Prismatic' });
expect(row.className).toContain('border-l-accent');
expect(row.className).not.toContain('odd:bg-surface/50');
});
@@ -63,7 +63,7 @@ describe('TrackListRow', () => {
test('click and Enter activate the row', async () => {
const props = base();
render(TrackListRow, { props });
const row = screen.getByRole('button', { name: 'Roygbiv' });
const row = screen.getByRole('button', { name: 'Prismatic' });
await fireEvent.click(row);
await fireEvent.keyDown(row, { key: 'Enter' });
expect(props.onActivate).toHaveBeenCalledTimes(2);
@@ -74,7 +74,7 @@ describe('TrackListRow', () => {
test('Enter on an inner control does not activate the row', async () => {
const props = base();
render(TrackListRow, { props });
await fireEvent.keyDown(screen.getByRole('button', { name: /add roygbiv to queue/i }), { key: 'Enter' });
await fireEvent.keyDown(screen.getByRole('button', { name: /add prismatic to queue/i }), { key: 'Enter' });
expect(props.onActivate).not.toHaveBeenCalled();
});
@@ -82,7 +82,7 @@ describe('TrackListRow', () => {
const props = base();
render(TrackListRow, { props });
await fireEvent.click(screen.getByRole('button', { name: /play radio/i }));
await fireEvent.click(screen.getByRole('button', { name: /add roygbiv to queue/i }));
await fireEvent.click(screen.getByRole('button', { name: /add prismatic to queue/i }));
expect(playRadio).toHaveBeenCalledWith('t1');
expect(enqueueTrack).toHaveBeenCalledWith(track);
expect(props.onActivate).not.toHaveBeenCalled();
@@ -98,7 +98,7 @@ describe('TrackListRow', () => {
test('a disabled row does not activate', async () => {
const props = base({ disabled: true });
render(TrackListRow, { props });
await fireEvent.click(screen.getByRole('button', { name: 'Roygbiv' }));
await fireEvent.click(screen.getByRole('button', { name: 'Prismatic' }));
expect(props.onActivate).not.toHaveBeenCalled();
});
});
+2 -2
View File
@@ -36,7 +36,7 @@ vi.mock('#lib/player/store.svelte.js', () => ({
import TrackMenu from './TrackMenu.svelte';
import { playNext, enqueueTrack, playRadio } from '#lib/player/store.svelte.js';
const track = makeTrack({ title: 'Roygbiv' });
const track = makeTrack({ title: 'Prismatic' });
afterEach(() => {
vi.clearAllMocks();
@@ -46,7 +46,7 @@ afterEach(() => {
describe('TrackMenu', () => {
test('kebab toggles aria-expanded', async () => {
render(TrackMenu, { props: { track } });
const kebab = screen.getByRole('button', { name: /track actions for roygbiv/i });
const kebab = screen.getByRole('button', { name: /track actions for prismatic/i });
expect(kebab.getAttribute('aria-expanded')).toBe('false');
await fireEvent.click(kebab);
expect(kebab.getAttribute('aria-expanded')).toBe('true');
+13 -13
View File
@@ -21,8 +21,8 @@ import { playQueue, enqueueTrack, playRadio } from '#lib/player/store.svelte.js'
import { selection, clearSelection } from '#lib/selection/store.svelte.js';
const tracks: TrackRef[] = [
makeTrack({ title: 'So What', duration_sec: 545 }),
makeTrack({ id: 't2', title: 'Freddie Freeloader', track_number: 2, duration_sec: 565, stream_url: '/api/tracks/t2/stream' })
makeTrack({ title: 'So Then', duration_sec: 545 }),
makeTrack({ id: 't2', title: 'Freddie Freewheeler', track_number: 2, duration_sec: 565, stream_url: '/api/tracks/t2/stream' })
];
beforeEach(() => clearSelection());
@@ -32,7 +32,7 @@ describe('TrackRow', () => {
test('renders track number, title, formatted duration', () => {
render(TrackRow, { props: { tracks, index: 0 } });
expect(screen.getByText('1')).toBeInTheDocument();
expect(screen.getByText('So What')).toBeInTheDocument();
expect(screen.getByText('So Then')).toBeInTheDocument();
expect(screen.getByText('9:05')).toBeInTheDocument();
});
@@ -44,26 +44,26 @@ describe('TrackRow', () => {
test('clicking the row calls playQueue(tracks, index)', async () => {
render(TrackRow, { props: { tracks, index: 1 } });
await fireEvent.click(screen.getByRole('button', { name: 'Freddie Freeloader' }));
await fireEvent.click(screen.getByRole('button', { name: 'Freddie Freewheeler' }));
expect(playQueue).toHaveBeenCalledWith(tracks, 1);
});
test('Enter on the row activates play', async () => {
render(TrackRow, { props: { tracks, index: 0 } });
await fireEvent.keyDown(screen.getByRole('button', { name: 'So What' }), { key: 'Enter' });
await fireEvent.keyDown(screen.getByRole('button', { name: 'So Then' }), { key: 'Enter' });
expect(playQueue).toHaveBeenCalledWith(tracks, 0);
});
test('Space on the row activates play', async () => {
render(TrackRow, { props: { tracks, index: 0 } });
await fireEvent.keyDown(screen.getByRole('button', { name: 'So What' }), { key: ' ' });
await fireEvent.keyDown(screen.getByRole('button', { name: 'So Then' }), { key: ' ' });
expect(playQueue).toHaveBeenCalledWith(tracks, 0);
});
test('onPlay prop overrides default playQueue', async () => {
const onPlay = vi.fn();
render(TrackRow, { props: { tracks, index: 1, onPlay } });
await fireEvent.click(screen.getByRole('button', { name: 'Freddie Freeloader' }));
await fireEvent.click(screen.getByRole('button', { name: 'Freddie Freewheeler' }));
expect(onPlay).toHaveBeenCalledWith(tracks, 1);
expect(playQueue).not.toHaveBeenCalled();
});
@@ -93,7 +93,7 @@ describe('TrackRow', () => {
test('a missing file is marked, does not play, and offers no actions', async () => {
const withMissing = [{ ...tracks[0], unavailable: true }, tracks[1]];
render(TrackRow, { props: { tracks: withMissing, index: 0 } });
const row = screen.getByRole('button', { name: 'So What' });
const row = screen.getByRole('button', { name: 'So Then' });
expect(row).toHaveAttribute('aria-disabled', 'true');
expect(screen.getByText(/file missing/i)).toBeInTheDocument();
await fireEvent.click(row);
@@ -106,7 +106,7 @@ describe('TrackRow', () => {
describe('selection mode', () => {
test('clicking the checkbox toggles selection without playing', async () => {
render(TrackRow, { props: { tracks, index: 0 } });
const box = screen.getByRole('checkbox', { name: /select so what/i });
const box = screen.getByRole('checkbox', { name: /select so then/i });
await fireEvent.click(box);
expect(selection.isSelected('t1')).toBe(true);
expect(playQueue).not.toHaveBeenCalled();
@@ -114,12 +114,12 @@ describe('TrackRow', () => {
test('row click toggles selection (not play) once any row is selected', async () => {
render(TrackRow, { props: { tracks, index: 0 } });
const box = screen.getByRole('checkbox', { name: /select so what/i });
const box = screen.getByRole('checkbox', { name: /select so then/i });
await fireEvent.click(box);
// Re-render at index 1 — selection mode is now active globally.
const { container } = render(TrackRow, { props: { tracks, index: 1 } });
const row = container.querySelector('[role="button"][aria-label="Freddie Freeloader"]')!;
const row = container.querySelector('[role="button"][aria-label="Freddie Freewheeler"]')!;
await fireEvent.click(row);
expect(selection.isSelected('t2')).toBe(true);
expect(playQueue).not.toHaveBeenCalled();
@@ -127,11 +127,11 @@ describe('TrackRow', () => {
test('shift+click on the row extends the range from the anchor', async () => {
render(TrackRow, { props: { tracks, index: 0 } });
const box = screen.getByRole('checkbox', { name: /select so what/i });
const box = screen.getByRole('checkbox', { name: /select so then/i });
await fireEvent.click(box);
const { container } = render(TrackRow, { props: { tracks, index: 1 } });
const row = container.querySelector('[role="button"][aria-label="Freddie Freeloader"]')!;
const row = container.querySelector('[role="button"][aria-label="Freddie Freewheeler"]')!;
await fireEvent.click(row, { shiftKey: true });
expect(selection.isSelected('t1')).toBe(true);
expect(selection.isSelected('t2')).toBe(true);
@@ -7,9 +7,9 @@ const row: PlaylistTrack = {
track_id: 't-1',
album_id: 'a-1',
artist_id: 'ar-1',
title: 'Roygbiv',
artist_name: 'Boards of Canada',
album_title: 'MHTRTC',
title: 'Prismatic',
artist_name: 'Fields of Ontario',
album_title: 'MHTRTW',
duration_sec: 137,
stream_url: '/api/tracks/t-1/stream',
added_at: '',
@@ -20,11 +20,11 @@ describe('playlistTrackToRef', () => {
test('maps a playable row onto a TrackRef', () => {
expect(playlistTrackToRef(row)).toEqual({
id: 't-1',
title: 'Roygbiv',
title: 'Prismatic',
album_id: 'a-1',
album_title: 'MHTRTC',
album_title: 'MHTRTW',
artist_id: 'ar-1',
artist_name: 'Boards of Canada',
artist_name: 'Fields of Ontario',
duration_sec: 137,
stream_url: '/api/tracks/t-1/stream'
});
+3 -3
View File
@@ -192,8 +192,8 @@ describe('admin Overview status', () => {
setupOverview(summary(), vi.fn(), status({
listening: {
now: [{
username: 'bryan', track_id: 't1', title: 'Avril 14th', artist_name: 'Aphex Twin', album_id: 'al1',
album_title: 'Drukqs', duration_ms: 125_000, started_at: minutesAgo(1), client: 'android', device_class: 'phone'
username: 'alex', track_id: 't1', title: 'Juin 21st', artist_name: 'Apex Sibling', album_id: 'al1',
album_title: 'Drumkits', duration_ms: 125_000, started_at: minutesAgo(1), client: 'android', device_class: 'phone'
}],
plays_day: 37, listeners_day: 2, last_play_at: minutesAgo(1)
}
@@ -201,7 +201,7 @@ describe('admin Overview status', () => {
render(OverviewPage);
const rows = screen.getAllByTestId('listening-row');
expect(rows).toHaveLength(1);
expect(rows[0].textContent?.replace(/\s+/g, ' ')).toMatch(/bryan Avril 14th · Aphex Twin android · started 1m ago/);
expect(rows[0].textContent?.replace(/\s+/g, ' ')).toMatch(/alex Juin 21st · Apex Sibling android · started 1m ago/);
expect(textOf('listening-day')).toBe('37 plays by 2 people in the last day, the latest 1m ago.');
});
+14 -14
View File
@@ -28,8 +28,8 @@ import { createAlbumQuery } from '#lib/api/queries.js';
function track(id: string, title: string, number: number, dur: number): TrackRef {
return makeTrack({
id, title,
album_id: 'xyz', album_title: 'Kind of Blue',
artist_id: 'md', artist_name: 'Miles Davis',
album_id: 'xyz', album_title: 'Kind of Grey',
artist_id: 'md', artist_name: 'Marlo Davies',
track_number: number,
duration_sec: dur,
stream_url: `/api/tracks/${id}/stream`
@@ -44,28 +44,28 @@ afterEach(() => {
describe('album detail page', () => {
test('renders hero metadata + one TrackRow per track', () => {
const detail: AlbumDetail = {
id: 'xyz', title: 'Kind of Blue', sort_title: 'Kind of Blue',
artist_id: 'md', artist_name: 'Miles Davis',
id: 'xyz', title: 'Kind of Grey', sort_title: 'Kind of Grey',
artist_id: 'md', artist_name: 'Marlo Davies',
year: 1959, track_count: 2, duration_sec: 544 + 565,
cover_url: '/api/albums/xyz/cover',
cover_art_source: null,
tracks: [track('t1', 'So What', 1, 544), track('t2', 'Freddie Freeloader', 2, 565)],
tracks: [track('t1', 'So Then', 1, 544), track('t2', 'Freddie Freewheeler', 2, 565)],
genres: ['Jazz']
};
(createAlbumQuery as ReturnType<typeof vi.fn>).mockReturnValue(mockQuery({ data: detail }));
render(AlbumPage);
expect(screen.getByRole('heading', { level: 1 })).toHaveTextContent('Kind of Blue');
expect(screen.getByRole('heading', { level: 1 })).toHaveTextContent('Kind of Grey');
// Two links point at /artists/md: the back chevron and the inline hero
// link. getAllByRole returns both; both should target the artist page.
const artistLinks = screen.getAllByRole('link', { name: /Miles Davis/ });
const artistLinks = screen.getAllByRole('link', { name: /Marlo Davies/ });
expect(artistLinks.length).toBeGreaterThanOrEqual(1);
artistLinks.forEach((l) => expect(l).toHaveAttribute('href', '/artists/md'));
expect(screen.getByText(/1959/)).toBeInTheDocument();
expect(screen.getByText(/2 tracks/i)).toBeInTheDocument();
expect(screen.getByText('So What')).toBeInTheDocument();
expect(screen.getByText('Freddie Freeloader')).toBeInTheDocument();
expect(screen.getByText('So Then')).toBeInTheDocument();
expect(screen.getByText('Freddie Freewheeler')).toBeInTheDocument();
const img = screen.getByRole('img') as HTMLImageElement;
expect(img.src).toContain('/api/albums/xyz/cover');
@@ -74,7 +74,7 @@ describe('album detail page', () => {
test('back link points to /artists/:artistId with the artist name', () => {
const detail: AlbumDetail = {
id: 'xyz', title: 'T', sort_title: 'T',
artist_id: 'md', artist_name: 'Miles Davis',
artist_id: 'md', artist_name: 'Marlo Davies',
track_count: 0, duration_sec: 0,
cover_url: '/api/albums/xyz/cover',
cover_art_source: null,
@@ -85,7 +85,7 @@ describe('album detail page', () => {
render(AlbumPage);
// Back chevron specifically (disambiguated from the inline artist link by
// the leading arrow character).
const back = screen.getByRole('link', { name: /^← Miles Davis/ });
const back = screen.getByRole('link', { name: /^← Marlo Davies/ });
expect(back).toHaveAttribute('href', '/artists/md');
});
@@ -126,8 +126,8 @@ describe('album detail page', () => {
// a slash-bearing tag is why browse selection lives in the query string.
test('year and genre are quick-jump links into the browse axes', () => {
const detail: AlbumDetail = {
id: 'xyz', title: 'Kind of Blue', sort_title: 'Kind of Blue',
artist_id: 'md', artist_name: 'Miles Davis',
id: 'xyz', title: 'Kind of Grey', sort_title: 'Kind of Grey',
artist_id: 'md', artist_name: 'Marlo Davies',
year: 1959, track_count: 0, duration_sec: 0,
cover_url: '/api/albums/xyz/cover',
cover_art_source: null,
@@ -154,7 +154,7 @@ describe('album detail page', () => {
test('no genre chips when the album carries no genre tags', () => {
const detail: AlbumDetail = {
id: 'xyz', title: 'Untagged', sort_title: 'Untagged',
artist_id: 'md', artist_name: 'Miles Davis',
artist_id: 'md', artist_name: 'Marlo Davies',
track_count: 0, duration_sec: 0,
cover_url: '/api/albums/xyz/cover',
cover_art_source: null,
@@ -14,11 +14,11 @@ vi.mock('#lib/api/admin.js', () => ({
dismissDuplicateGroup: vi.fn().mockResolvedValue(undefined),
mergeDuplicateGroup: vi.fn().mockResolvedValue({
survivor_track_id: 'www-01',
removed_paths: ['/music/Moe Shop/WWW (2020)/www-02.mp3']
removed_paths: ['/music/Mochi Shop/XYZ (2020)/www-02.mp3']
}),
removeWrongSlotFiles: vi.fn().mockResolvedValue({
kept_track_id: null,
removed_paths: ['/music/Moe Shop/WWW (2020)/www-01.mp3', '/music/Moe Shop/WWW (2020)/www-02.mp3']
removed_paths: ['/music/Mochi Shop/XYZ (2020)/www-01.mp3', '/music/Mochi Shop/XYZ (2020)/www-02.mp3']
})
}));
vi.mock('#lib/player/store.svelte.js', () => ({ playQueue: vi.fn() }));
@@ -51,12 +51,12 @@ const allFingerprinted = { total: 1200, fingerprinted: 1200, rejected: 0, pendin
function member(id: string, extra: Partial<AdminDuplicatesResponse['groups'][number]['members'][number]> = {}) {
return {
track_id: id,
title: 'WWW',
title: 'XYZ',
artist_id: 'ar-1',
artist_name: 'Moe Shop',
artist_name: 'Mochi Shop',
album_id: 'al-1',
album_title: 'WWW',
file_path: `/music/Moe Shop/WWW (2020)/${id}.mp3`,
album_title: 'XYZ',
file_path: `/music/Mochi Shop/XYZ (2020)/${id}.mp3`,
file_format: 'mp3',
file_size: 6_900_000,
duration_sec: 215,
@@ -199,14 +199,14 @@ describe('admin duplicates', () => {
);
});
// Identical audio titled "WWW" and "WWW (instrumental)". One file
// Identical audio titled "XYZ" and "XYZ (instrumental)". One file
// claimed to be the vocal and wasn't, and nothing said the vocal was missing.
describe('identical audio under different titles', () => {
function www() {
const r = response();
r.groups[0] = {
...r.groups[0],
members: [member('www-01'), member('www-02', { title: 'WWW (instrumental)' })]
members: [member('www-01'), member('www-02', { title: 'XYZ (instrumental)' })]
};
return r;
}
@@ -214,16 +214,16 @@ describe('admin duplicates', () => {
test('says the copies are titled differently and names both titles', () => {
renderWith(www());
const notice = text(screen.getByTestId('title-mismatch'));
expect(notice).toContain('titled “WWW” and “WWW (instrumental)”');
expect(notice).toContain('titled “XYZ” and “XYZ (instrumental)”');
expect(notice).toContain("isn't in your library");
});
test('three different titles are all named', () => {
const r = www();
r.groups[0].members.push(member('www-03', { title: 'WWW (Radio Edit)' }));
r.groups[0].members.push(member('www-03', { title: 'XYZ (Radio Edit)' }));
renderWith(r);
expect(text(screen.getByTestId('title-mismatch'))).toContain(
'“WWW”, “WWW (instrumental)” and “WWW (Radio Edit)”'
'“XYZ”, “XYZ (instrumental)” and “XYZ (Radio Edit)”'
);
});
@@ -232,7 +232,7 @@ describe('admin duplicates', () => {
r.groups[0] = {
...r.groups[0],
members: [
member('www-01', { title: 'WWW (Instrumental)' }),
member('www-01', { title: 'XYZ (Instrumental)' }),
member('www-02', { title: ' www (instrumental) ' })
]
};
@@ -253,14 +253,14 @@ describe('admin duplicates', () => {
expect(screen.queryByTestId('title-mismatch')).toBeNull();
});
// Unless the resolver found different songs on one album: Savant's Mortals
// Unless the resolver found different songs on one album: Savanta's Immortals
// held one recording as 16 tracks, each cut to its own song's length.
test('an acoustic group the resolver found to be different songs says so', () => {
const r = www();
r.groups[0] = { ...r.groups[0], tier: 'acoustic', worst_bit_error_rate: 0, class: 'mismatch' };
renderWith(r);
const notice = text(screen.getByTestId('title-mismatch'));
expect(notice).toContain('The music is the same, but the copies are titled “WWW” and “WWW (instrumental)”');
expect(notice).toContain('The music is the same, but the copies are titled “XYZ” and “XYZ (instrumental)”');
expect(notice).toContain("If you can't tell, get the album again");
});
});
@@ -276,7 +276,7 @@ describe('admin duplicates', () => {
tier: 'acoustic',
worst_bit_error_rate: 0.04,
class: 'mismatch',
members: [member('www-01'), member('www-02', { title: 'WWW (instrumental)' })]
members: [member('www-01'), member('www-02', { title: 'XYZ (instrumental)' })]
};
return r;
}
@@ -303,11 +303,11 @@ describe('admin duplicates', () => {
test('naming the song keeps that copy and removes the others', async () => {
renderWith(slots());
await fireEvent.click(screen.getByRole('radio', { name: /This is WWW \(instrumental\)/ }));
await fireEvent.click(screen.getByRole('radio', { name: /This is XYZ \(instrumental\)/ }));
expect(screen.getByTestId('song-badge')).toBeTruthy();
await fireEvent.click(screen.getByRole('button', { name: 'Keep “WWW (instrumental)”…' }));
await fireEvent.click(screen.getByRole('button', { name: 'Keep “XYZ (instrumental)”…' }));
expect(text(screen.getByTestId('refetch-confirm'))).toContain(
'The copy titled “WWW (instrumental)” stays, and 1 copy under other titles will be deleted from disk'
'The copy titled “XYZ (instrumental)” stays, and 1 copy under other titles will be deleted from disk'
);
await fireEvent.click(screen.getByRole('button', { name: 'Remove 1 file' }));
expect(removeWrongSlotFiles).toHaveBeenCalledWith('g-1', { keep_track_id: 'www-02' });
@@ -443,15 +443,15 @@ describe('admin duplicates', () => {
action: 'duplicate_merge',
created_at: ago(HOUR),
details: {
survivor_path: '/music/Gorillaz/Humanz (2017)/03 - Saturnz Barz.mp3',
survivor_path: '/music/Plastic Apes/Mammalz (2017)/03 - Neptunez Barz.mp3',
survivor_reason: 'the copy that is not a video rip',
removed: [{ track_id: 't-2', file_path: '/music/Gorillaz/Humanz (2017)/03 - Saturnz Barz (Official Video).mp3' }]
removed: [{ track_id: 't-2', file_path: '/music/Plastic Apes/Mammalz (2017)/03 - Neptunez Barz (Official Video).mp3' }]
}
}
]);
await fireEvent.click(screen.getByRole('tab', { name: /resolved automatically/i }));
const items = screen.getAllByTestId('resolved-item').map(text);
expect(items[0]).toContain('Kept 03 - Saturnz Barz.mp3 (the copy that is not a video rip) and removed 1 file.');
expect(items[0]).toContain('Kept 03 - Neptunez Barz.mp3 (the copy that is not a video rip) and removed 1 file.');
expect(screen.queryByTestId('duplicate-group')).toBeNull();
});
@@ -461,16 +461,16 @@ describe('admin duplicates', () => {
id: 'a-2',
action: 'duplicate_dismiss',
created_at: ago(HOUR),
details: { artist: 'Moe Shop', titles: ['Lovesick', 'Lovesick (Instrumental)'] }
details: { artist: 'Mochi Shop', titles: ['Homesick', 'Homesick (Instrumental)'] }
},
{
id: 'a-3',
action: 'duplicate_wrong_file',
created_at: ago(HOUR),
details: {
artist: 'Savant',
artist: 'Savanta',
kept_title: 'Void',
removed: [{ track_id: 't-9', file_path: '/data/Music/Savant/Void/17 - Reach.m4a', title: 'Reach' }]
removed: [{ track_id: 't-9', file_path: '/data/Music/Savanta/Void/17 - Reach.m4a', title: 'Reach' }]
}
},
{
@@ -478,23 +478,23 @@ describe('admin duplicates', () => {
action: 'duplicate_wrong_file',
created_at: ago(HOUR),
details: {
artist: 'Shnabubula',
artist: 'Shnorkelbub',
removed: [
{ track_id: 't-5', file_path: '/data/Music/Shnabubula/05 - Fading Light.mp3', title: 'Fading Light' },
{ track_id: 't-10', file_path: '/data/Music/Shnabubula/10 - Looking for Answers.mp3', title: 'Looking for Answers' }
{ track_id: 't-5', file_path: '/data/Music/Shnorkelbub/05 - Fading Light.mp3', title: 'Fading Light' },
{ track_id: 't-10', file_path: '/data/Music/Shnorkelbub/10 - Looking for Answers.mp3', title: 'Looking for Answers' }
]
}
}
]);
await fireEvent.click(screen.getByRole('tab', { name: /resolved automatically/i }));
const items = screen.getAllByTestId('resolved-item').map(text);
expect(items[0]).toContain('Moe Shop: Lovesick and Lovesick (Instrumental) are different versions, not duplicates. Both kept.');
expect(items[0]).toContain('Mochi Shop: Homesick and Homesick (Instrumental) are different versions, not duplicates. Both kept.');
expect(items[1]).toContain(
'Savant: the recording of Void was also filed as Reach. Removed from there; those tracks wait in Needs a file.'
'Savanta: the recording of Void was also filed as Reach. Removed from there; those tracks wait in Needs a file.'
);
expect(items[1]).toContain('/data/Music/Savant/Void/17 - Reach.m4a');
expect(items[1]).toContain('/data/Music/Savanta/Void/17 - Reach.m4a');
expect(items[2]).toContain(
'Shnabubula: one recording was filed as Fading Light and Looking for Answers, and it is none of them. Removed; those tracks wait in Needs a file.'
'Shnorkelbub: one recording was filed as Fading Light and Looking for Answers, and it is none of them. Removed; those tracks wait in Needs a file.'
);
});
});
@@ -22,10 +22,10 @@ function track(
track_id: `t-${title}`,
title,
artist_id: 'ar-1',
artist_name: 'Linkin Park',
artist_name: 'Lincoln Yard',
album_id: 'al-1',
album_title: 'Minutes to Midnight',
file_path: `/music/Linkin Park/Minutes to Midnight/${title}.flac`,
album_title: 'Minutes to Noon',
file_path: `/music/Lincoln Yard/Minutes to Noon/${title}.flac`,
duration_sec: 185,
disc_number: 1,
track_number: 1,
@@ -44,7 +44,7 @@ const response: AdminMissingResponse = {
offset: 0,
groups: [
{
directory: '/music/Linkin Park/Minutes to Midnight',
directory: '/music/Lincoln Yard/Minutes to Noon',
missing_since: new Date(Date.now() - 3 * DAY).toISOString(),
tracks: [
track('Given Up', { lastPlayed: new Date(Date.now() - 2 * DAY).toISOString() }),
@@ -52,7 +52,7 @@ const response: AdminMissingResponse = {
]
},
{
directory: '/music/Boards of Canada/Geogaddi',
directory: '/music/Fields of Ontario/Geomantic',
missing_since: new Date(Date.now() - 9 * DAY).toISOString(),
tracks: [track('1969')]
}
@@ -71,8 +71,8 @@ function renderWith(data: AdminMissingResponse | undefined, extra = {}) {
describe('/collection/missing', () => {
test('groups rows under their directory', () => {
renderWith(response);
expect(screen.getByText('/music/Linkin Park/Minutes to Midnight')).toBeTruthy();
expect(screen.getByText('/music/Boards of Canada/Geogaddi')).toBeTruthy();
expect(screen.getByText('/music/Lincoln Yard/Minutes to Noon')).toBeTruthy();
expect(screen.getByText('/music/Fields of Ontario/Geomantic')).toBeTruthy();
expect(screen.getAllByTestId('missing-track-row')).toHaveLength(3);
});
@@ -160,7 +160,7 @@ describe('/collection/missing', () => {
test('Forget all takes the whole folder', async () => {
renderWith(response);
await fireEvent.click(
screen.getByRole('button', { name: 'Forget the 2 tracks in /music/Linkin Park/Minutes to Midnight' })
screen.getByRole('button', { name: 'Forget the 2 tracks in /music/Lincoln Yard/Minutes to Noon' })
);
await fireEvent.click(within(screen.getByRole('dialog')).getByRole('button', { name: /confirm forget/i }));
await waitFor(() => expect(forgetMissingTracks).toHaveBeenCalledWith(['t-Given Up', 't-Bleed It Out']));
@@ -29,9 +29,9 @@ const hoursAgo = (h: number) => new Date(Date.now() - h * 3_600_000).toISOString
const flagged: AdminQuarantineRow = {
track_id: 't1',
track_title: 'Roygbiv',
artist_name: 'Boards of Canada',
album_title: 'Geogaddi',
track_title: 'Prismatic',
artist_name: 'Fields of Ontario',
album_title: 'Geomantic',
album_id: 'al1',
report_count: 1,
latest_at: hoursAgo(5),
@@ -49,7 +49,7 @@ const failure = (id: string, track: string, title: string, h: number): AdminPlay
occurred_at: hoursAgo(h),
track_title: title,
track_file_path: `/music/${title}.flac`,
artist_name: 'Annadale',
artist_name: 'Ashdale',
album_title: 'Dial Tone',
album_id: 'al2'
});
@@ -67,7 +67,7 @@ function setup(q: AdminQuarantineRow[], e: AdminPlaybackError[], opts: { error?:
describe('/collection/reports', () => {
test('a flagged track and a track that failed to play are one list, one row per track, newest first', () => {
setup([flagged], [failure('e1', 't1', 'Roygbiv', 1), failure('e2', 't2', 'Intro', 9)]);
setup([flagged], [failure('e1', 't1', 'Prismatic', 1), failure('e2', 't2', 'Intro', 9)]);
const rows = screen.getAllByTestId('report-row');
expect(rows).toHaveLength(2);
expect(screen.getByTestId('reports-verdict').textContent).toMatch(/2 tracks need a look/);
@@ -78,8 +78,8 @@ describe('/collection/reports', () => {
});
test('Resolve clears the listeners\' reports and marks the playback errors fixed', async () => {
setup([flagged], [failure('e1', 't1', 'Roygbiv', 1)]);
await fireEvent.click(screen.getByRole('button', { name: /resolve roygbiv/i }));
setup([flagged], [failure('e1', 't1', 'Prismatic', 1)]);
await fireEvent.click(screen.getByRole('button', { name: /resolve prismatic/i }));
await waitFor(() => expect(resolveQuarantine).toHaveBeenCalledWith('t1'));
await waitFor(() => expect(resolvePlaybackError).toHaveBeenCalledWith('e1', 'fixed'));
});
@@ -110,20 +110,20 @@ describe('/collection/reports', () => {
test("on a phone the row's other actions are in its menu", async () => {
setup([flagged], [failure('e2', 't2', 'Intro', 2)]);
const roygbiv = screen.getAllByTestId('report-row').find((r) => r.textContent?.includes('Roygbiv'))!;
await fireEvent.click(within(roygbiv).getByRole('button', { name: /more actions/i }));
const prismatic = screen.getAllByTestId('report-row').find((r) => r.textContent?.includes('Prismatic'))!;
await fireEvent.click(within(prismatic).getByRole('button', { name: /more actions/i }));
const menu = within(screen.getByRole('menu'));
expect(menu.getByText('Remove the file')).toBeInTheDocument();
expect(menu.getByText('Remove from library')).toBeInTheDocument();
});
test('details show who flagged it, who it failed for, and the file', async () => {
setup([flagged], [failure('e1', 't1', 'Roygbiv', 1)]);
setup([flagged], [failure('e1', 't1', 'Prismatic', 1)]);
await fireEvent.click(screen.getByRole('button', { name: /^details$/i }));
const details = screen.getByTestId('report-details').textContent?.replace(/\s+/g, ' ');
expect(details).toMatch(/alice flagged it · Bad rip · crackles/);
expect(details).toMatch(/Failed to play for bob · Wouldn't load/);
expect(details).toMatch(/\/music\/Roygbiv\.flac/);
expect(details).toMatch(/\/music\/Prismatic\.flac/);
});
test('a load failure says so with Try again, and an empty queue says nothing waits', () => {
@@ -91,7 +91,7 @@
}
// Disc and track are shown because junk numbering is the other half of
// the symptom: Humanz's rips were spread over discs 1 to 15.
// the symptom: Mammalz's rips were spread over discs 1 to 15.
function position(t: AdminSuspectTrack): string {
const parts: string[] = [];
if (t.disc_number != null) parts.push(`disc ${t.disc_number}`);
@@ -14,17 +14,17 @@ import { createSuspectSourcesQuery, removeSuspectFile, setSuspectVerdict } from
const mocked = createSuspectSourcesQuery as ReturnType<typeof vi.fn>;
const HUMANZ = '/music/Gorillaz/Humanz (2017)';
const MAMMALZ = '/music/Plastic Apes/Mammalz (2017)';
function track(title: string, file: string, markers: string[], disc: number | null = 15): AdminSuspectTrack {
return {
track_id: `t-${title}`,
title,
artist_id: 'ar-1',
artist_name: 'Gorillaz',
artist_name: 'Plastic Apes',
album_id: 'al-1',
album_title: 'Humanz',
file_path: `${HUMANZ}/${file}`,
album_title: 'Mammalz',
file_path: `${MAMMALZ}/${file}`,
duration_sec: 180,
disc_number: disc,
track_number: 4,
@@ -59,10 +59,10 @@ describe('Suspect sources page', () => {
infinite([
page(0, 2, [
{
directory: HUMANZ,
directory: MAMMALZ,
tracks: [
track('Strobelite', 'Gorillaz - Strobelite (Official Video).mp3', ['music video']),
track('Andromeda', 'Gorillaz - Andromeda [Audio] [HQ].mp3', ['[Audio]', '[HD]'])
track('Strobeline', 'Plastic Apes - Strobeline (Official Video).mp3', ['music video']),
track('Cassiopeia', 'Plastic Apes - Cassiopeia [Audio] [HQ].mp3', ['[Audio]', '[HD]'])
]
}
])
@@ -71,8 +71,8 @@ describe('Suspect sources page', () => {
render(SuspectSourcesPage);
expect(screen.getByTestId('suspect-count-pill')).toHaveTextContent('2');
expect(screen.getByText(HUMANZ)).toBeInTheDocument();
expect(screen.getByText('Gorillaz - Strobelite (Official Video).mp3')).toBeInTheDocument();
expect(screen.getByText(MAMMALZ)).toBeInTheDocument();
expect(screen.getByText('Plastic Apes - Strobeline (Official Video).mp3')).toBeInTheDocument();
expect(screen.getAllByTestId('suspect-marker').map((m) => m.textContent)).toEqual([
'music video',
'[Audio]',
@@ -85,16 +85,16 @@ describe('Suspect sources page', () => {
test('joins a folder that straddles a page boundary', () => {
mocked.mockReturnValue(
infinite([
page(0, 3, [{ directory: HUMANZ, tracks: [track('Strobelite', 'a (Official Video).mp3', ['music video'])] }]),
page(0, 3, [{ directory: MAMMALZ, tracks: [track('Strobeline', 'a (Official Video).mp3', ['music video'])] }]),
page(1, 3, [
{ directory: HUMANZ, tracks: [track('Momentz', 'b (Visualizer).mp3', ['visualiser'])] },
{ directory: '/music/Daft Punk/RAM', tracks: [track('Doin It Right', 'c (Music Video).mp3', ['music video'])] }
{ directory: MAMMALZ, tracks: [track('Minutez', 'b (Visualizer).mp3', ['visualiser'])] },
{ directory: '/music/Deft Monks/RAD', tracks: [track('Doin It Twice', 'c (Music Video).mp3', ['music video'])] }
])
])
);
render(SuspectSourcesPage);
expect(screen.getAllByText(HUMANZ)).toHaveLength(1);
expect(screen.getAllByText(MAMMALZ)).toHaveLength(1);
expect(screen.getAllByText('2 tracks')).toHaveLength(1);
expect(screen.getAllByTestId('suspect-track-row')).toHaveLength(3);
});
@@ -107,7 +107,7 @@ describe('Suspect sources page', () => {
test('loads more as you scroll, with no button', () => {
mocked.mockReturnValue(
infinite([page(0, 80, [{ directory: HUMANZ, tracks: [track('Strobelite', 'a (Official Video).mp3', ['music video'])] }])], {
infinite([page(0, 80, [{ directory: MAMMALZ, tracks: [track('Strobeline', 'a (Official Video).mp3', ['music video'])] }])], {
hasNextPage: true
})
);
@@ -123,8 +123,8 @@ describe('Suspect sources page', () => {
infinite([
page(0, 1, [
{
directory: HUMANZ,
tracks: [track('Strobelite', 'Gorillaz - Strobelite (Official Video).mp3', ['music video'])]
directory: MAMMALZ,
tracks: [track('Strobeline', 'Plastic Apes - Strobeline (Official Video).mp3', ['music video'])]
}
])
])
@@ -133,7 +133,7 @@ describe('Suspect sources page', () => {
expect(screen.getByTestId('suspect-verdict')).toHaveTextContent(/Held back/);
await fireEvent.click(screen.getByRole('button', { name: 'This one is fine' }));
expect(setSuspectVerdict).toHaveBeenCalledWith('t-Strobelite', 'fine');
expect(setSuspectVerdict).toHaveBeenCalledWith('t-Strobeline', 'fine');
expect(await screen.findByText('Marked fine')).toBeInTheDocument();
expect(screen.getByRole('button', { name: 'Hold back again' })).toBeInTheDocument();
});
@@ -145,17 +145,17 @@ describe('Suspect sources page', () => {
infinite([
page(0, 1, [
{
directory: HUMANZ,
tracks: [track('Strobelite', 'Gorillaz - Strobelite (Official Video).mp3', ['music video'])]
directory: MAMMALZ,
tracks: [track('Strobeline', 'Plastic Apes - Strobeline (Official Video).mp3', ['music video'])]
}
])
])
);
render(SuspectSourcesPage);
await fireEvent.click(screen.getByRole('button', { name: 'Remove the file of Strobelite' }));
await fireEvent.click(screen.getByRole('button', { name: 'Remove the file of Strobeline' }));
expect(removeSuspectFile).not.toHaveBeenCalled();
await fireEvent.click(screen.getByRole('button', { name: 'Confirm remove the file of Strobelite' }));
expect(removeSuspectFile).toHaveBeenCalledWith('t-Strobelite');
await fireEvent.click(screen.getByRole('button', { name: 'Confirm remove the file of Strobeline' }));
expect(removeSuspectFile).toHaveBeenCalledWith('t-Strobeline');
});
});
+6 -6
View File
@@ -16,13 +16,13 @@ const baseRow: QuarantineMineRow = {
reason: 'bad_rip',
notes: 'crackles',
created_at: new Date(Date.now() - 2 * 24 * 3_600_000).toISOString(), // 2 days ago
track_title: 'Roygbiv',
track_title: 'Prismatic',
track_duration_ms: 200000,
album_id: 'a1',
album_title: 'Geogaddi',
album_title: 'Geomantic',
album_cover_art_path: null,
artist_id: 'ar1',
artist_name: 'Boards of Canada'
artist_name: 'Fields of Ontario'
};
afterEach(() => vi.clearAllMocks());
@@ -31,8 +31,8 @@ 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('Roygbiv')).toBeInTheDocument();
expect(screen.getByText(/by boards of canada · geogaddi/i)).toBeInTheDocument();
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();
});
@@ -40,7 +40,7 @@ describe('/library/hidden', () => {
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 roygbiv/i }));
await fireEvent.click(screen.getByRole('button', { name: /un-hide prismatic/i }));
expect(unflagTrack).toHaveBeenCalledWith('t1');
});
+9 -9
View File
@@ -38,14 +38,14 @@ function page<T>(items: T[], total: number, offset = 0, limit = 50): Page<T> {
afterEach(() => vi.clearAllMocks());
const ar: ArtistRef = { id: 'a1', name: 'Miles', sort_name: 'Miles', album_count: 1, cover_url: '' };
const ar: ArtistRef = { id: 'a1', name: 'Marlo', sort_name: 'Marlo', album_count: 1, cover_url: '' };
const al: AlbumRef = {
id: 'al1', title: 'Kind of Blue', sort_title: 'Kind of Blue', artist_id: 'a1', artist_name: 'Miles',
id: 'al1', title: 'Kind of Grey', sort_title: 'Kind of Grey', artist_id: 'a1', artist_name: 'Marlo',
year: 1959, track_count: 1, duration_sec: 100, cover_url: '/x', cover_art_source: null
};
const tr: TrackRef = makeTrack({
title: 'So What', album_id: 'al1', album_title: 'Kind of Blue',
artist_id: 'a1', artist_name: 'Miles', duration_sec: 100
title: 'So Then', album_id: 'al1', album_title: 'Kind of Grey',
artist_id: 'a1', artist_name: 'Marlo', duration_sec: 100
});
function setup(opts: {
@@ -78,14 +78,14 @@ describe('liked library page', () => {
'Albums 1',
'Tracks 1'
]);
expect(screen.getByText('Miles')).toBeInTheDocument();
expect(screen.queryByText('So What')).not.toBeInTheDocument();
expect(screen.getByText('Marlo')).toBeInTheDocument();
expect(screen.queryByText('So Then')).not.toBeInTheDocument();
await fireEvent.click(screen.getByRole('tab', { name: /albums/i }));
expect(screen.getByText('Kind of Blue')).toBeInTheDocument();
expect(screen.getByText('Kind of Grey')).toBeInTheDocument();
await fireEvent.click(screen.getByRole('tab', { name: /tracks/i }));
expect(screen.getByText('So What')).toBeInTheDocument();
expect(screen.getByText('So Then')).toBeInTheDocument();
expect(screen.getByRole('tab', { name: /tracks/i })).toHaveAttribute('aria-selected', 'true');
});
@@ -93,7 +93,7 @@ describe('liked library page', () => {
setup({ tracks: page([tr], 1) });
render(LikedPage);
expect(screen.getByRole('tab', { name: /tracks/i })).toHaveAttribute('aria-selected', 'true');
expect(screen.getByText('So What')).toBeInTheDocument();
expect(screen.getByText('So Then')).toBeInTheDocument();
});
test('all three empty renders the whole-page onboarding card and no tabs', () => {
+4 -4
View File
@@ -7,7 +7,7 @@ import { apiClientMock } from '../../../test-utils/mocks/client';
import { pageUrlModule } from '#test-utils/mocks/appState.js';
import type { AlbumRef, Page } from '#lib/api/types.js';
const state = vi.hoisted(() => ({ pageUrl: new URL('http://localhost/search/albums?q=miles') }));
const state = vi.hoisted(() => ({ pageUrl: new URL('http://localhost/search/albums?q=marlo') }));
vi.mock('$app/state', () => pageUrlModule(state));
@@ -30,13 +30,13 @@ function page<T>(items: T[], total: number, offset = 0, limit = 50): Page<T> {
}
const album: AlbumRef = {
id: 'al1', title: 'Kind of Blue', sort_title: 'Kind of Blue', artist_id: 'a1', artist_name: 'Miles Davis',
id: 'al1', title: 'Kind of Grey', sort_title: 'Kind of Grey', artist_id: 'a1', artist_name: 'Marlo Davies',
year: 1959, track_count: 5, duration_sec: 2630, cover_url: '/api/albums/al1/cover', cover_art_source: null
};
afterEach(() => {
vi.clearAllMocks();
state.pageUrl = new URL('http://localhost/search/albums?q=miles');
state.pageUrl = new URL('http://localhost/search/albums?q=marlo');
});
describe('search albums overflow', () => {
@@ -45,7 +45,7 @@ describe('search albums overflow', () => {
mockInfiniteQuery({ pages: [page([album], 1)] })
);
render(AlbumsOverflow);
expect(screen.getByRole('link', { name: /Kind of Blue/ })).toHaveAttribute('href', '/albums/al1');
expect(screen.getByRole('link', { name: /Kind of Grey/ })).toHaveAttribute('href', '/albums/al1');
});
// No button; reaching the end of the list loads the next page.
@@ -6,7 +6,7 @@ import { emptyLikesMock } from '../../../test-utils/mocks/likes';
import { pageUrlModule } from '#test-utils/mocks/appState.js';
import type { ArtistRef, Page } from '#lib/api/types.js';
const state = vi.hoisted(() => ({ pageUrl: new URL('http://localhost/search/artists?q=miles') }));
const state = vi.hoisted(() => ({ pageUrl: new URL('http://localhost/search/artists?q=marlo') }));
vi.mock('$app/state', () => pageUrlModule(state));
@@ -25,19 +25,19 @@ function page<T>(items: T[], total: number, offset = 0, limit = 50): Page<T> {
afterEach(() => {
vi.clearAllMocks();
state.pageUrl = new URL('http://localhost/search/artists?q=miles');
state.pageUrl = new URL('http://localhost/search/artists?q=marlo');
});
describe('search artists overflow', () => {
test('renders a row per artist', () => {
const a1: ArtistRef = { id: 'a1', name: 'Miles Davis', sort_name: 'Miles Davis', album_count: 12, cover_url: '' };
const a2: ArtistRef = { id: 'a2', name: 'Miles Mosley', sort_name: 'Miles Mosley', album_count: 1, cover_url: '' };
const a1: ArtistRef = { id: 'a1', name: 'Marlo Davies', sort_name: 'Marlo Davies', album_count: 12, cover_url: '' };
const a2: ArtistRef = { id: 'a2', name: 'Marlo Mosby', sort_name: 'Marlo Mosby', album_count: 1, cover_url: '' };
(createSearchArtistsInfiniteQuery as ReturnType<typeof vi.fn>).mockReturnValue(
mockInfiniteQuery({ pages: [page([a1, a2], 2)] })
);
render(ArtistsOverflow);
expect(screen.getByRole('link', { name: /Miles Davis/ })).toBeInTheDocument();
expect(screen.getByRole('link', { name: /Miles Mosley/ })).toBeInTheDocument();
expect(screen.getByRole('link', { name: /Marlo Davies/ })).toBeInTheDocument();
expect(screen.getByRole('link', { name: /Marlo Mosby/ })).toBeInTheDocument();
});
// No button; reaching the end of the list loads the next page.
+11 -11
View File
@@ -40,15 +40,15 @@ function emptyResp(): SearchResponse {
};
}
const artist: ArtistRef = { id: 'a1', name: 'Miles Davis', sort_name: 'Miles Davis', album_count: 12, cover_url: '' };
const artist: ArtistRef = { id: 'a1', name: 'Marlo Davies', sort_name: 'Marlo Davies', album_count: 12, cover_url: '' };
const album: AlbumRef = {
id: 'al1', title: 'Kind of Blue', sort_title: 'Kind of Blue', artist_id: 'a1', artist_name: 'Miles Davis',
id: 'al1', title: 'Kind of Grey', sort_title: 'Kind of Grey', artist_id: 'a1', artist_name: 'Marlo Davies',
year: 1959, track_count: 5, duration_sec: 2630, cover_url: '/api/albums/al1/cover', cover_art_source: null
};
const track = makeTrack({
title: 'So What',
album_id: 'al1', album_title: 'Kind of Blue',
artist_id: 'a1', artist_name: 'Miles Davis',
title: 'So Then',
album_id: 'al1', album_title: 'Kind of Grey',
artist_id: 'a1', artist_name: 'Marlo Davies',
duration_sec: 545
});
@@ -66,7 +66,7 @@ describe('search page', () => {
});
test('all three sections render when all three facets have items', () => {
state.pageUrl = new URL('http://localhost/search?q=miles');
state.pageUrl = new URL('http://localhost/search?q=marlo');
const resp: SearchResponse = {
...emptyResp(),
artists: { items: [artist], total: 1, limit: 10, offset: 0 },
@@ -81,7 +81,7 @@ describe('search page', () => {
});
test('empty facets are hidden', () => {
state.pageUrl = new URL('http://localhost/search?q=miles');
state.pageUrl = new URL('http://localhost/search?q=marlo');
const resp: SearchResponse = {
...emptyResp(),
tracks: { items: [track], total: 1, limit: 10, offset: 0 }
@@ -94,7 +94,7 @@ describe('search page', () => {
});
test('"See all N →" link renders when total > items.length', () => {
state.pageUrl = new URL('http://localhost/search?q=miles');
state.pageUrl = new URL('http://localhost/search?q=marlo');
const resp: SearchResponse = {
...emptyResp(),
artists: { items: [artist], total: 47, limit: 10, offset: 0 }
@@ -102,11 +102,11 @@ describe('search page', () => {
(createSearchQuery as ReturnType<typeof vi.fn>).mockReturnValue(mockQuery({ data: resp }));
render(SearchPage);
const link = screen.getByRole('link', { name: /see all 47/i });
expect(link).toHaveAttribute('href', '/search/artists?q=miles');
expect(link).toHaveAttribute('href', '/search/artists?q=marlo');
});
test('"See all" link omitted when total === items.length', () => {
state.pageUrl = new URL('http://localhost/search?q=miles');
state.pageUrl = new URL('http://localhost/search?q=marlo');
const resp: SearchResponse = {
...emptyResp(),
tracks: { items: [track], total: 1, limit: 10, offset: 0 }
@@ -127,7 +127,7 @@ describe('search page', () => {
});
test('error state renders ApiErrorBanner', () => {
state.pageUrl = new URL('http://localhost/search?q=miles');
state.pageUrl = new URL('http://localhost/search?q=marlo');
(createSearchQuery as ReturnType<typeof vi.fn>).mockReturnValue(
mockQuery({ isError: true, error: { code: 'server_error', message: 'boom' } })
);
+5 -5
View File
@@ -8,7 +8,7 @@ import { pageUrlModule } from '#test-utils/mocks/appState.js';
import type { TrackRef, Page } from '#lib/api/types.js';
import { makeTrack } from '#test-utils/fixtures/track.js';
const state = vi.hoisted(() => ({ pageUrl: new URL('http://localhost/search/tracks?q=miles') }));
const state = vi.hoisted(() => ({ pageUrl: new URL('http://localhost/search/tracks?q=marlo') }));
vi.mock('$app/state', () => pageUrlModule(state));
@@ -35,11 +35,11 @@ function page<T>(items: T[], total: number, offset = 0, limit = 50): Page<T> {
return { items, total, offset, limit };
}
const track = makeTrack({ title: 'So What' });
const track = makeTrack({ title: 'So Then' });
afterEach(() => {
vi.clearAllMocks();
state.pageUrl = new URL('http://localhost/search/tracks?q=miles');
state.pageUrl = new URL('http://localhost/search/tracks?q=marlo');
});
describe('search tracks overflow', () => {
@@ -48,7 +48,7 @@ describe('search tracks overflow', () => {
mockInfiniteQuery({ pages: [page([track], 1)] })
);
render(TracksOverflow);
expect(screen.getByRole('button', { name: 'So What' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: 'So Then' })).toBeInTheDocument();
});
test('clicking a track row triggers playRadio with the track id', async () => {
@@ -56,7 +56,7 @@ describe('search tracks overflow', () => {
mockInfiniteQuery({ pages: [page([track], 1)] })
);
render(TracksOverflow);
await fireEvent.click(screen.getByRole('button', { name: 'So What' }));
await fireEvent.click(screen.getByRole('button', { name: 'So Then' }));
expect(playRadio).toHaveBeenCalledWith('t1');
});