feat: Reports, Duplicates and Suspect sources live under Collection, with their counts on its rail and a "To look at" line naming the ones waiting; notices link there (M504 #5625)
release / govulncheck (push) Successful in 21s
release / web (push) Successful in 1m21s
release / go (push) Successful in 1m39s
release / integration (push) Successful in 5m31s
release / android (push) Successful in 6m5s
release / Build signed APK (releases and dev) (push) Successful in 6m21s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Successful in 32s
release / Verify release artifacts (tag releases only) (push) Skipped
release / govulncheck (push) Successful in 21s
release / web (push) Successful in 1m21s
release / go (push) Successful in 1m39s
release / integration (push) Successful in 5m31s
release / android (push) Successful in 6m5s
release / Build signed APK (releases and dev) (push) Successful in 6m21s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Successful in 32s
release / Verify release artifacts (tag releases only) (push) Skipped
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,154 @@
|
||||
import { afterEach, describe, expect, test, vi } from 'vitest';
|
||||
import { fireEvent, render, screen } from '@testing-library/svelte';
|
||||
import { readable } from 'svelte/store';
|
||||
import type { AdminSuspectResponse, AdminSuspectTrack } from '#lib/api/types.js';
|
||||
|
||||
vi.mock('#lib/api/admin.js', () => ({
|
||||
createSuspectSourcesQuery: vi.fn(),
|
||||
setSuspectVerdict: vi.fn(async () => {})
|
||||
}));
|
||||
|
||||
import SuspectSourcesPage from './+page.svelte';
|
||||
import { createSuspectSourcesQuery, setSuspectVerdict } from '#lib/api/admin.js';
|
||||
|
||||
const mocked = createSuspectSourcesQuery as ReturnType<typeof vi.fn>;
|
||||
|
||||
const HUMANZ = '/music/Gorillaz/Humanz (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',
|
||||
album_id: 'al-1',
|
||||
album_title: 'Humanz',
|
||||
file_path: `${HUMANZ}/${file}`,
|
||||
duration_sec: 180,
|
||||
disc_number: disc,
|
||||
track_number: 4,
|
||||
markers,
|
||||
verdict: 'suspect',
|
||||
verdict_at: new Date(Date.now() - 3_600_000).toISOString(),
|
||||
replacing: false,
|
||||
searched_at: null
|
||||
};
|
||||
}
|
||||
|
||||
function page(offset: number, total: number, groups: AdminSuspectResponse['groups']): AdminSuspectResponse {
|
||||
return { total, limit: 50, offset, groups };
|
||||
}
|
||||
|
||||
// The page reads only these fields of the infinite query.
|
||||
function infinite(pages: AdminSuspectResponse[], opts: { hasNextPage?: boolean; isPending?: boolean } = {}) {
|
||||
return readable({
|
||||
data: { pages },
|
||||
isPending: opts.isPending ?? false,
|
||||
isError: false,
|
||||
hasNextPage: opts.hasNextPage ?? false,
|
||||
isFetchingNextPage: false,
|
||||
fetchNextPage: () => {},
|
||||
refetch: () => {}
|
||||
});
|
||||
}
|
||||
|
||||
afterEach(() => vi.clearAllMocks());
|
||||
|
||||
describe('Suspect sources page', () => {
|
||||
test('shows each flagged track with its file name and markers', () => {
|
||||
mocked.mockReturnValue(
|
||||
infinite([
|
||||
page(0, 2, [
|
||||
{
|
||||
directory: HUMANZ,
|
||||
tracks: [
|
||||
track('Strobelite', 'Gorillaz - Strobelite (Official Video).mp3', ['music video']),
|
||||
track('Andromeda', 'Gorillaz - Andromeda [Audio] [HQ].mp3', ['[Audio]', '[HD]'])
|
||||
]
|
||||
}
|
||||
])
|
||||
])
|
||||
);
|
||||
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.getAllByTestId('suspect-marker').map((m) => m.textContent)).toEqual([
|
||||
'music video',
|
||||
'[Audio]',
|
||||
'[HD]'
|
||||
]);
|
||||
expect(screen.getAllByText(/disc 15, track 4/)).toHaveLength(2);
|
||||
});
|
||||
|
||||
// A folder split across two pages is still one folder on screen.
|
||||
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(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'])] }
|
||||
])
|
||||
])
|
||||
);
|
||||
render(SuspectSourcesPage);
|
||||
|
||||
expect(screen.getAllByText(HUMANZ)).toHaveLength(1);
|
||||
expect(screen.getAllByText('2 tracks')).toHaveLength(1);
|
||||
expect(screen.getAllByTestId('suspect-track-row')).toHaveLength(3);
|
||||
});
|
||||
|
||||
test('empty library explains what would land here', () => {
|
||||
mocked.mockReturnValue(infinite([page(0, 0, [])]));
|
||||
render(SuspectSourcesPage);
|
||||
expect(screen.getByText(/no file names look like video rips/i)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
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'])] }])], {
|
||||
hasNextPage: true
|
||||
})
|
||||
);
|
||||
const { container } = render(SuspectSourcesPage);
|
||||
expect(container.querySelector('div[aria-hidden="true"].h-px')).not.toBeNull();
|
||||
expect(screen.queryByRole('button', { name: /more/i })).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
// M498 #5439: a flagged track is held back from radio and the mixes, and the
|
||||
// operator can let it back.
|
||||
test('This one is fine lets a held-back track back in', async () => {
|
||||
mocked.mockReturnValue(
|
||||
infinite([
|
||||
page(0, 1, [
|
||||
{
|
||||
directory: HUMANZ,
|
||||
tracks: [track('Strobelite', 'Gorillaz - Strobelite (Official Video).mp3', ['music video'])]
|
||||
}
|
||||
])
|
||||
])
|
||||
);
|
||||
render(SuspectSourcesPage);
|
||||
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(await screen.findByText('Marked fine')).toBeInTheDocument();
|
||||
expect(screen.getByRole('button', { name: 'Hold back again' })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
// #5524: a rip's album is wanted for a clean copy, and the row says when
|
||||
// one was last looked for.
|
||||
test('shows that a clean copy is wanted, and when it was looked for', () => {
|
||||
const t = track('Strobelite', 'Gorillaz - Strobelite (Official Video).mp3', ['music video']);
|
||||
t.replacing = true;
|
||||
t.searched_at = new Date(Date.now() - 7_200_000).toISOString();
|
||||
mocked.mockReturnValue(infinite([page(0, 1, [{ directory: HUMANZ, tracks: [t] }])]));
|
||||
render(SuspectSourcesPage);
|
||||
const line = screen.getByTestId('suspect-searched');
|
||||
expect(line).toHaveTextContent(/Looked for a clean copy/);
|
||||
expect(line).toHaveAttribute('href', '/collection/upgrades');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user