Files
portal/app/tests/Frontend/BalanceCard.spec.ts
T
Дмитрий 0bcafe7ad6 fix/runway: единый прогноз дашборд↔биллинг при нет активных проектов B1-2
Раньше при 0 активных проектов дашборд показывал хватит на 0 дней при полном балансе,
а биллинг — Запас бесконечность. Унифицировано: оба показывают нет активных проектов
прочерк. Бэкенд дашборда больше не приводит null к 0; фронт рисует null как нет проектов.
Заодно поправлен пред-существующий красный тест 28 дня на верную форму 28 дней.
TDD: DashboardSummaryTest 11/11, фронт BalanceCard/Dashboard/Billing 27/27.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 12:21:55 +03:00

73 lines
3.2 KiB
TypeScript

import { mount } from '@vue/test-utils';
import { describe, expect, it } from 'vitest';
import BalanceCard from '../../resources/js/components/billing/BalanceCard.vue';
import { createVuetify } from 'vuetify';
const vuetify = createVuetify();
const baseProps = {
walletRub: 5000,
affordableLeads: 46,
currentTierPriceRub: '120.00',
requiredLeadsPerDay: 4,
};
describe('BalanceCard (Billing v2 Spec A; ряд Деньги → Лиды → Запас)', () => {
it('shows wallet ₽ formatted with thousands separator', () => {
const w = mount(BalanceCard, { props: baseProps, global: { plugins: [vuetify] } });
// Intl.NumberFormat('ru-RU') uses U+00A0 (non-breaking space) — match any whitespace
expect(w.text()).toMatch(/5\s000/);
});
it('shows «≈ N лидов» using affordableLeads', () => {
const w = mount(BalanceCard, { props: baseProps, global: { plugins: [vuetify] } });
expect(w.text()).toContain('≈ 46');
expect(w.text()).toContain('лидов');
});
it('does NOT contain «(ГЦК)»', () => {
const w = mount(BalanceCard, { props: baseProps, global: { plugins: [vuetify] } });
expect(w.text()).not.toContain('ГЦК');
});
it('does NOT contain «округление вниз ₽→лиды»', () => {
const w = mount(BalanceCard, { props: baseProps, global: { plugins: [vuetify] } });
expect(w.text()).not.toContain('округление вниз');
});
it('renders «сейчас по X ₽/лид» subline', () => {
const w = mount(BalanceCard, { props: baseProps, global: { plugins: [vuetify] } });
expect(w.text()).toContain('120.00 ₽/лид');
});
it('does NOT contain the removed «Тариф» card', () => {
const w = mount(BalanceCard, { props: baseProps, global: { plugins: [vuetify] } });
expect(w.text()).not.toContain('Тариф');
});
it('Запас = affordableLeads / requiredLeadsPerDay (живой заказ): 46 / 4 → 11 дн.', () => {
const w = mount(BalanceCard, { props: baseProps, global: { plugins: [vuetify] } });
expect(w.text()).toContain('Запас');
expect(w.text()).toMatch(/11\s*дн\./);
expect(w.text()).toContain('при 4');
});
it('Запас = — и «нет активных проектов» когда проекты не заказывают (B1-2, requiredLeadsPerDay = 0)', () => {
const w = mount(BalanceCard, {
props: { ...baseProps, requiredLeadsPerDay: 0 },
global: { plugins: [vuetify] },
});
// B1-2: было «∞ дн.» — расходилось с дашбордом; теперь «—» + «нет активных проектов».
expect(w.text()).not.toContain('∞');
expect(w.text()).toContain('—');
expect(w.text()).toContain('нет активных проектов');
});
it('НЕ содержит строки-чтения (дубль убран)', () => {
const w = mount(BalanceCard, { props: baseProps, global: { plugins: [vuetify] } });
expect(w.text()).not.toContain('тыс ₽ =');
expect(w.text()).not.toContain('млн ₽ =');
});
});