e1601e7862
Spec C §3.6/§6.2. Бэкенд: GET /api/billing/balance-status (frozen + capacity + required + дефицит ₽/leads), Pest 6. Фронт: BalanceFrozenBanner (в AppLayout, глобально), BalanceCapacityIndicator (в BillingView под балансом), ProjectLimitOverloadDialog (409-перехват в NewProjectDialog: save-blocked/set-zero), tenantStore + api getBalanceStatus. Vitest +18. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
47 lines
2.2 KiB
TypeScript
47 lines
2.2 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { mount } from '@vue/test-utils';
|
|
import BalanceCapacityIndicator from '../../resources/js/components/billing/BalanceCapacityIndicator.vue';
|
|
|
|
// Billing v2 Spec C Task 1.10 — подсказка под балансом (§3.6). Чистый
|
|
// presentational-компонент: статус по соотношению ёмкости и требуемого/день.
|
|
|
|
describe('BalanceCapacityIndicator', () => {
|
|
it('зелёный, когда ёмкости хватает на 3+ дня', () => {
|
|
const w = mount(BalanceCapacityIndicator, {
|
|
props: { balanceRub: '3000.00', capacityLeads: 90, requiredLeadsPerDay: 25 },
|
|
});
|
|
expect(w.text()).toContain('90');
|
|
expect(w.classes()).toContain('capacity-ok');
|
|
});
|
|
|
|
it('жёлтый, когда ёмкости хватает меньше чем на 3 дня', () => {
|
|
const w = mount(BalanceCapacityIndicator, {
|
|
props: { balanceRub: '1000.00', capacityLeads: 30, requiredLeadsPerDay: 25 },
|
|
});
|
|
expect(w.classes()).toContain('capacity-warning');
|
|
});
|
|
|
|
it('красный, когда ёмкости меньше требуемого', () => {
|
|
const w = mount(BalanceCapacityIndicator, {
|
|
props: { balanceRub: '500.00', capacityLeads: 10, requiredLeadsPerDay: 25 },
|
|
});
|
|
expect(w.classes()).toContain('capacity-insufficient');
|
|
});
|
|
|
|
it('зелёный (бесконечный запас), когда проекты ничего не заказывают', () => {
|
|
const w = mount(BalanceCapacityIndicator, {
|
|
props: { balanceRub: '500.00', capacityLeads: 10, requiredLeadsPerDay: 0 },
|
|
});
|
|
expect(w.classes()).toContain('capacity-ok');
|
|
});
|
|
|
|
it('показывает баланс, ёмкость и дневной заказ', () => {
|
|
const w = mount(BalanceCapacityIndicator, {
|
|
props: { balanceRub: '1000.00', capacityLeads: 30, requiredLeadsPerDay: 25 },
|
|
});
|
|
expect(w.text()).toContain('1000.00');
|
|
expect(w.text()).toContain('30');
|
|
expect(w.text()).toContain('25');
|
|
});
|
|
});
|