// Synthetic UI fixtures: exercise real rendering and navigation, not streaming. async function openClassic(page, { populated = false, settings = {}, standalone = false } = {}) { await page.route('**/api/**', route => route.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, results: [], items: [], holders: [], data: null }), })); await page.route('**/fixture-cover.svg', route => route.fulfill({ contentType: 'image/svg+xml', body: 'Studio sessionSynthetic preview fixture', })); await page.addInitScript(({ populated, settings, standalone }) => { if (standalone) { const match = window.matchMedia.bind(window); window.matchMedia = query => query.includes('display-mode: standalone') ? match(query.replace(/\(display-mode: standalone\)/g, '(min-width: 0px)')) : match(query); } const videos = Array.from({ length: 12 }, (_, i) => ({ id: 'preview' + String(i).padStart(4, '0'), title: ['A quiet morning — live studio session', 'Late afternoon, piano and strings', 'An extended conversation about making music and finding a little room to listen'][i % 3], channel: 'Preview fixtures', duration: 240 + i * 36, thumbnail: '/fixture-cover.svg', })); localStorage.setItem('_ytpdata', JSON.stringify({ settings: { layout: 'classic', reduceMotion: true, p2pShare: false, p2pReceive: false, ...settings }, playlists: populated ? [{ id: 'studio', name: 'Studio sessions', videos }] : [], history: populated ? videos : [], queue: populated ? videos : [], })); }, { populated, settings, standalone }); await page.goto('/'); await page.waitForFunction(() => document.documentElement.dataset.layout === 'classic' && document.querySelectorAll('.smart-pl-list .playlist-item').length > 0); await page.locator('#searchInput').blur(); } async function showPlayingFixture(page) { await page.evaluate(() => { const videos = data.playlists[0].videos; current = { meta: videos[0], qualities: [], audioUrl: '' }; queue = videos; queueIndex = 0; queueSource = 'playlist:studio'; view = { type: 'playlist', id: 'studio' }; document.getElementById('playerPane').classList.remove('empty'); document.getElementById('playerPlaceholder').classList.add('hidden'); document.getElementById('controls').classList.remove('hidden'); document.getElementById('nowPlayingMeta').classList.remove('hidden'); document.getElementById('npTitle').textContent = videos[0].title; document.getElementById('npChannel').textContent = videos[0].channel; document.getElementById('artFallback').classList.remove('hidden'); document.getElementById('artImg').src = '/fixture-cover.svg'; updateNowPlayingActions(); render(); renderUpNext(); document.querySelector('.body').scrollTop = 0; }); } module.exports = { openClassic, showPlayingFixture };