// @vitest-environment happy-dom import { describe, it, expect } from 'vitest' import SourceHealthDot from '../../src/components/subscriptions/SourceHealthDot.vue' import { VTooltipStub, mountComponent } from '../support/mountComponent.js' // Milestone #387 A3. The dot is the only always-visible signal per source, so // the grade it picks IS the claim FC makes about that subscription. These pin // that no-access is graded as its own thing — not as healthy (which hides it) // and not as a failure (which would send the operator hunting for a break that // isn't there). const checked = { last_checked_at: '2026-09-09T12:00:00+00:00' } function dotClass (w) { return w.find('.fc-health-dot').classes().join(' ') } describe('SourceHealthDot', () => { it('grades a tier-gated source as no-access, not healthy', () => { const w = mountComponent(SourceHealthDot, { stubs: { VTooltip: VTooltipStub }, props: { source: { ...checked, consecutive_failures: 0, error_type: 'tier_limited' }, }, }) expect(dotClass(w)).toContain('fc-health-dot--no-access') expect(dotClass(w)).not.toContain('fc-health-dot--healthy') }) it('shows the gated count when the list endpoint supplied one', () => { const w = mountComponent(SourceHealthDot, { stubs: { VTooltip: VTooltipStub }, props: { source: { ...checked, consecutive_failures: 0, error_type: 'tier_limited', tier_gated_count: 47, }, }, }) expect(w.text()).toContain('47 posts') }) it('states the condition without a number when no count was joined in', () => { const w = mountComponent(SourceHealthDot, { stubs: { VTooltip: VTooltipStub }, props: { source: { ...checked, consecutive_failures: 0, error_type: 'tier_limited', tier_gated_count: null, }, }, }) // Absent is not zero: never render "0 posts you don't have access to". expect(w.text()).not.toContain('0 post') expect(w.text()).toContain("tier you don't hold") }) it('a genuinely failing source still grades as a failure, gated or not', () => { const w = mountComponent(SourceHealthDot, { stubs: { VTooltip: VTooltipStub }, props: { source: { ...checked, consecutive_failures: 9, error_type: 'tier_limited' }, warningThreshold: 5, }, }) expect(dotClass(w)).toContain('fc-health-dot--critical') expect(dotClass(w)).not.toContain('fc-health-dot--no-access') }) it('an unchecked source is still unchecked', () => { const w = mountComponent(SourceHealthDot, { stubs: { VTooltip: VTooltipStub }, props: { source: { last_checked_at: null, consecutive_failures: 0 } }, }) expect(dotClass(w)).toContain('fc-health-dot--unchecked') }) })