feat(vibe): reconcile mutable session previews in playback

This commit is contained in:
kami
2026-08-01 23:47:02 +04:00
parent 51ef7c84db
commit 57df1cfe9f
20 changed files with 1311 additions and 312 deletions
@@ -0,0 +1,41 @@
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { beforeEach, describe, expect, it } from 'vitest';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import type { Track } from '../types';
import { usePlaybackStore } from '../store/usePlaybackStore';
import { VibeTimeline } from './VibeTimeline';
const track = (id: string): Track => ({
id, path: `/music/${id}.mp3`, hash: id, title: id, artist: 'Artist', album_id: 'album',
duration: 180, state: 'LIBRARY', source_type: 'MANUAL', play_count: 0, skip_count: 0, dislike_count: 0,
});
describe('VibeTimeline', () => {
beforeEach(() => {
const current = track('current');
usePlaybackStore.setState({
currentTrack: current, queue: [current, track('upcoming')], currentIndex: 0,
isPlaying: true, queueOwner: 'vibe', vibeAdvanceHandler: () => undefined,
});
});
it('renders upcoming plan entries as display-only so they cannot hand queue ownership to ordinary playback', async () => {
const user = userEvent.setup();
render(
<QueryClientProvider client={new QueryClient({ defaultOptions: { queries: { retry: false } } })}>
<VibeTimeline currentTrack={track('current')} upcoming={[track('upcoming')]} />
</QueryClientProvider>
);
const queued = screen.getAllByRole('button', { name: 'upcoming is queued by Vibe' });
expect(queued).toHaveLength(2);
expect(queued[0]).toBeDisabled();
expect(queued[1]).toBeDisabled();
await user.click(queued[0]);
expect(usePlaybackStore.getState()).toMatchObject({
queueOwner: 'vibe', currentTrack: track('current'),
});
});
});