import { describe, it, expect } from 'vitest'; import { mount } from '@vue/test-utils'; import { createVuetify } from 'vuetify'; import BalanceFrozenBanner from '../../resources/js/components/billing/BalanceFrozenBanner.vue'; // Billing v2 Spec C Task 1.10 — красный баннер заморозки (§3.6). Показывается // на всех страницах, когда tenant.frozen_by_balance_at !== null. const routerLinkStub = { RouterLink: { props: ['to'], inheritAttrs: false, template: '', }, }; const mountBanner = (props: { frozen: boolean; deficitRub?: string; deficitLeads?: number }) => mount(BalanceFrozenBanner, { props, global: { plugins: [createVuetify()], stubs: routerLinkStub }, }); describe('BalanceFrozenBanner', () => { it('не заморожен — баннер не рендерится', () => { const w = mountBanner({ frozen: false }); expect(w.find('[data-testid="balance-frozen-banner"]').exists()).toBe(false); }); it('заморожен — красный баннер с текстом «приостановлен»', () => { const w = mountBanner({ frozen: true, deficitRub: '380.00', deficitLeads: 10 }); const banner = w.find('[data-testid="balance-frozen-banner"]'); expect(banner.exists()).toBe(true); expect(banner.text()).toContain('приостановлен'); }); it('показывает дефицит в рублях и лидах', () => { const w = mountBanner({ frozen: true, deficitRub: '380.00', deficitLeads: 10 }); const text = w.find('[data-testid="balance-frozen-banner"]').text(); expect(text).toContain('380'); expect(text).toContain('10'); }); it('две ссылки — на /billing и на /projects', () => { const w = mountBanner({ frozen: true, deficitRub: '380.00', deficitLeads: 10 }); expect(w.find('[data-testid="banner-topup-link"]').attributes('href')).toBe('/billing'); expect(w.find('[data-testid="banner-projects-link"]').attributes('href')).toBe('/projects'); }); });