fix(billing-v2): BillingView — drop «лидов запас», wire new BalanceCard props
This commit is contained in:
@@ -29,10 +29,10 @@ const topupSnackbar = ref(false);
|
||||
const txTableRef = ref<InstanceType<typeof TransactionsTable> | null>(null);
|
||||
|
||||
const walletRub = computed(() => Number(wallet.value?.balance_rub ?? 0));
|
||||
const leadsBalance = computed(() => wallet.value?.balance_leads ?? 0);
|
||||
const affordableLeads = computed(() => wallet.value?.affordable_leads ?? 0);
|
||||
const currentTierPriceRub = computed(() => wallet.value?.current_tier?.price_rub ?? '0.00');
|
||||
const runwayDays = computed(() => wallet.value?.runway_days ?? null);
|
||||
const tariffName = computed(() => wallet.value?.tariff?.name ?? null);
|
||||
const tariffPrice = computed(() => wallet.value?.tariff?.price_monthly ?? null);
|
||||
const tariffFeatures = computed<string[]>(() => (wallet.value?.tariff?.features ?? []).map(featureLabel));
|
||||
|
||||
async function loadWallet(): Promise<void> {
|
||||
@@ -73,10 +73,6 @@ defineExpose({ loadWallet, wallet, topupOpen });
|
||||
<span
|
||||
><span class="num text-primary">{{ formatPlain(walletRub) }}</span> кошелёк</span
|
||||
>
|
||||
<span class="sep">·</span>
|
||||
<span
|
||||
><span class="num">{{ leadsBalance }}</span> лидов запас</span
|
||||
>
|
||||
<template v-if="runwayDays !== null">
|
||||
<span class="sep">·</span>
|
||||
<span
|
||||
@@ -111,9 +107,9 @@ defineExpose({ loadWallet, wallet, topupOpen });
|
||||
<template v-else-if="wallet">
|
||||
<BalanceCard
|
||||
:wallet-rub="walletRub"
|
||||
:leads-balance="leadsBalance"
|
||||
:affordable-leads="affordableLeads"
|
||||
:current-tier-price-rub="currentTierPriceRub"
|
||||
:tariff-name="tariffName"
|
||||
:tariff-price="tariffPrice"
|
||||
:tariff-features="tariffFeatures"
|
||||
@topup="topupOpen = true"
|
||||
/>
|
||||
|
||||
@@ -12,13 +12,15 @@ const vuetify = createVuetify();
|
||||
function makeWallet(): Wallet {
|
||||
return {
|
||||
balance_rub: '14250.00',
|
||||
balance_leads: 285,
|
||||
affordable_leads: 28,
|
||||
current_tier: { no: 1, price_rub: '500.00', leads_left_in_tier: 100 },
|
||||
next_tier: { no: 2, price_rub: '450.00', leads_in_tier: 200 },
|
||||
delivered_in_month: 0,
|
||||
runway_days: 142,
|
||||
tiers_preview: [],
|
||||
tariff: {
|
||||
code: 'pro',
|
||||
name: 'Про',
|
||||
price_monthly: '990.00',
|
||||
billing_model: 'hybrid',
|
||||
features: ['webhook', 'kanban', 'api'],
|
||||
},
|
||||
};
|
||||
@@ -49,7 +51,12 @@ describe('BillingView.vue', () => {
|
||||
expect(billingApi.getWallet).toHaveBeenCalled();
|
||||
const text = wrapper.text();
|
||||
expect(text).toMatch(/14\s+250\s*₽/);
|
||||
expect(text).toContain('285');
|
||||
});
|
||||
|
||||
it('не показывает чип «лидов запас» в шапке', async () => {
|
||||
const wrapper = factory();
|
||||
await flushPromises();
|
||||
expect(wrapper.text()).not.toContain('лидов запас');
|
||||
});
|
||||
|
||||
it('показывает тариф из API в BalanceCard', async () => {
|
||||
@@ -64,8 +71,12 @@ describe('BillingView.vue', () => {
|
||||
it('показывает «Тариф не выбран» при tariff=null', async () => {
|
||||
vi.mocked(billingApi.getWallet).mockResolvedValue({
|
||||
balance_rub: '0.00',
|
||||
balance_leads: 0,
|
||||
affordable_leads: 0,
|
||||
current_tier: null,
|
||||
next_tier: null,
|
||||
delivered_in_month: 0,
|
||||
runway_days: null,
|
||||
tiers_preview: [],
|
||||
tariff: null,
|
||||
});
|
||||
const wrapper = factory();
|
||||
|
||||
Reference in New Issue
Block a user