// @vitest-environment happy-dom import { describe, it, expect } from 'vitest' import ActiveDownloadsPanel from '../../src/components/subscriptions/ActiveDownloadsPanel.vue' import { useDownloadsStore } from '../../src/stores/downloads.js' import { freshPinia, mountComponent } from '../support/mountComponent.js' describe('ActiveDownloadsPanel', () => { it('lists a running download with its artist', () => { const pinia = freshPinia() useDownloadsStore().activeEvents = [{ id: 1, status: 'running', started_at: new Date(Date.now() - 65000).toISOString(), platform: 'patreon', artist_name: 'Alice', }] const w = mountComponent(ActiveDownloadsPanel, { pinia }) const t = w.text() expect(t).toContain('Alice') expect(t).toContain('downloading') w.unmount() // clear the 1s elapsed-timer interval }) // #387 A1: the live payload gained a `gated` count. Shown only when non-zero // so a healthy run stays uncluttered — a "🔒 0" on every download would be // noise, and noise is what stops the number being noticed when it matters. it('ticks the tier-gated count mid-walk when there is one', () => { const pinia = freshPinia() useDownloadsStore().activeEvents = [{ id: 1, status: 'running', started_at: new Date(Date.now() - 65000).toISOString(), platform: 'patreon', artist_name: 'Alice', live: { downloaded: 2, skipped: 0, errors: 0, posts: 12, gated: 9 }, }] const w = mountComponent(ActiveDownloadsPanel, { pinia }) expect(w.text()).toContain('9') w.unmount() }) it('omits the gated count when nothing was gated', () => { const pinia = freshPinia() useDownloadsStore().activeEvents = [{ id: 1, status: 'running', started_at: new Date(Date.now() - 65000).toISOString(), platform: 'patreon', artist_name: 'Alice', live: { downloaded: 2, skipped: 0, errors: 0, posts: 12, gated: 0 }, }] const w = mountComponent(ActiveDownloadsPanel, { pinia }) expect(w.find('.fc-active__count--gated').exists()).toBe(false) w.unmount() }) it('renders nothing when there is no active work', () => { const pinia = freshPinia() useDownloadsStore().activeEvents = [] const w = mountComponent(ActiveDownloadsPanel, { pinia }) expect(w.text()).toBe('') w.unmount() }) })