fix(usage): preserve zero user multipliers in cost details

This commit is contained in:
chihao.ou
2026-09-30 02:24:37 +08:00
parent a60a29549f
commit 7d0bf9c87f
2 changed files with 17 additions and 1 deletions
@@ -497,7 +497,7 @@
</div>
<div class="flex items-center justify-between gap-6">
<span class="text-gray-400">{{ t('usage.rate') }}</span>
<span class="font-semibold text-blue-400">{{ formatMultiplier(tooltipData?.rate_multiplier || 1) }}x</span>
<span class="font-semibold text-blue-400">{{ formatMultiplier(tooltipData?.rate_multiplier ?? 1) }}x</span>
</div>
<div class="flex items-center justify-between gap-6">
<span class="text-gray-400">{{ t('usage.original') }}</span>
@@ -225,6 +225,22 @@ describe('admin UsageTable tooltip', () => {
expect(wrapper.get('[data-testid="native-compaction-badge"]').text()).toBe('Compaction')
})
it.each([
[0, '0.0x'],
[0.5, '0.50x'],
[undefined, '1.00x'],
])('shows the stored user rate %s in cost details', async (rate, expected) => {
const wrapper = mount(UsageTable, {
props: { data: [{ ...baseImageRow, rate_multiplier: rate }], loading: false, columns: [] },
global: { stubs: { DataTable: DataTableStub, EmptyState: true, Icon: true, Teleport: true } },
})
const triggers = wrapper.findAll('.group.relative')
await triggers[triggers.length - 1].trigger('mouseenter')
const rateLabel = wrapper.get('.fixed').findAll('span').find(span => span.text() === 'Rate')!
expect(rateLabel.element.parentElement?.textContent).toContain(expected)
wrapper.unmount()
})
it('shows service tier and billing breakdown in cost tooltip', async () => {
const row = {
request_id: 'req-admin-1',