Files
minstrel/web/src/routes/library/albums/empty.test.ts
T
bvandeusenandClaude Opus 5.5 10d50dccbd docs: web comments say what the app does, not how it came to be (#6277)
Rewrites the web app's comments to rule 32. Task, milestone, rule and
spec ids are gone; regression stories are restated as the trap they
guard (public auth routes, the menu's stopPropagation, universal loads
under adapter-static, metric deltas with their margin). Flutter and
Tauri mentions now name the Android app or a native shell, operator
quotes and dates are dropped, and one library's counts no longer
appear outside test fixtures. Verified with a TypeScript-scanner token
comparison (template literals and regex literals re-scanned): only
comment text changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 12:42:12 -04:00

47 lines
1.6 KiB
TypeScript

import { afterEach, describe, expect, test, vi } from 'vitest';
import { cleanup, render, screen } from '@testing-library/svelte';
import { readable } from 'svelte/store';
import { apiClientMock } from '../../../test-utils/mocks/client';
vi.mock('#lib/api/albums.js', () => ({
createAlbumsAlphaInfiniteQuery: () =>
readable({
data: { pages: [{ items: [], total: 0, limit: 50, offset: 0 }] },
isPending: false,
isError: false,
hasNextPage: false,
isFetchingNextPage: false,
refetch: () => {},
fetchNextPage: () => {}
}),
ALBUM_PAGE_SIZE: 50
}));
vi.mock('#lib/api/client.js', () => apiClientMock());
import Page from './+page.svelte';
import { setUser } from '#lib/auth/user.svelte.js';
import type { User } from '#lib/api/client.js';
afterEach(() => {
cleanup();
setUser(null);
});
// An empty library sends an admin to Admin to run a scan, and nobody to
// Settings.
describe('/library/albums with an empty library', () => {
test('an admin is sent to Admin to run a scan', () => {
setUser({ id: 'u1', username: 'root', is_admin: true } as User);
render(Page);
expect(screen.getByRole('link', { name: /run a scan/i }).getAttribute('href')).toBe('/admin');
expect(screen.queryByRole('link', { name: /open settings/i })).toBeNull();
});
test('anyone else is told the admin scans the library, with no link', () => {
setUser({ id: 'u2', username: 'alice', is_admin: false } as User);
render(Page);
expect(screen.getByText(/your server's admin has scanned the library/i)).toBeInTheDocument();
expect(screen.queryByRole('link')).toBeNull();
});
});