feat(web): polish AlbumCard with FabledSword tokens + play overlay
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -8,7 +8,8 @@ vi.mock('$lib/api/client', () => ({
|
||||
api: { get: vi.fn() }
|
||||
}));
|
||||
vi.mock('$lib/player/store.svelte', () => ({
|
||||
enqueueTracks: vi.fn()
|
||||
enqueueTracks: vi.fn(),
|
||||
playQueue: vi.fn()
|
||||
}));
|
||||
|
||||
vi.mock('$lib/api/likes', () => ({
|
||||
@@ -28,7 +29,7 @@ vi.mock('@tanstack/svelte-query', async (orig) => {
|
||||
|
||||
import AlbumCard from './AlbumCard.svelte';
|
||||
import { api } from '$lib/api/client';
|
||||
import { enqueueTracks } from '$lib/player/store.svelte';
|
||||
import { enqueueTracks, playQueue } from '$lib/player/store.svelte';
|
||||
|
||||
const album: AlbumRef = {
|
||||
id: 'xyz',
|
||||
@@ -89,4 +90,23 @@ describe('AlbumCard', () => {
|
||||
await Promise.resolve();
|
||||
expect(enqueueTracks).toHaveBeenCalledWith(tracks);
|
||||
});
|
||||
|
||||
test('play overlay click fetches album detail and calls playQueue at index 0', async () => {
|
||||
const tracks: TrackRef[] = [
|
||||
{ id: 't1', title: 'So What',
|
||||
album_id: 'xyz', album_title: 'Kind of Blue',
|
||||
artist_id: 'm-davis', artist_name: 'Miles Davis',
|
||||
track_number: 1, disc_number: 1, duration_sec: 545,
|
||||
stream_url: '/api/tracks/t1/stream' }
|
||||
];
|
||||
const detail: AlbumDetail = { ...album, tracks };
|
||||
(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 }));
|
||||
expect(api.get).toHaveBeenCalledWith('/api/albums/xyz');
|
||||
await Promise.resolve();
|
||||
await Promise.resolve();
|
||||
expect(playQueue).toHaveBeenCalledWith(tracks, 0);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user