mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-12-05 16:07:33 +00:00
fix(accounts): show local Antigravity usage statistics
This commit is contained in:
1 parent
8f2cbb53d9
commit
e8d71b932e
2 files changed
+37
No files matched your search
@@ -201,6 +201,11 @@
|
||||
|
||||
<!-- Antigravity OAuth accounts: fetch usage from API -->
|
||||
<template v-else-if="account.platform === 'antigravity' && account.type === 'oauth'">
|
||||
<div v-if="todayStats" class="mb-1 text-[10px] text-gray-500 dark:text-gray-400">
|
||||
{{ formatKeyRequests }} req · {{ formatKeyTokens }} ·
|
||||
<span :title="t('usage.accountBilled')">A ${{ formatKeyCost }}</span>
|
||||
<span v-if="todayStats.user_cost != null" :title="t('usage.userBilled')"> · U ${{ formatKeyUserCost }}</span>
|
||||
</div>
|
||||
<!-- 账户类型徽章 -->
|
||||
<div v-if="antigravityTierLabel" class="mb-1 flex items-center gap-1">
|
||||
<span
|
||||
|
||||
@@ -113,6 +113,38 @@ const cnUsageCellStubs = {
|
||||
}
|
||||
|
||||
describe('AccountUsageCell', () => {
|
||||
it('shows Antigravity local usage and separate account/user costs when the upstream query fails', async () => {
|
||||
getUsage.mockRejectedValue(new Error('upstream quota unavailable'))
|
||||
const wrapper = mount(AccountUsageCell, {
|
||||
props: {
|
||||
account: makeAccount({ id: 6401 }),
|
||||
todayStats: { requests: 56, tokens: 5715898, cost: 2.6253228, user_cost: 0.003426 }
|
||||
},
|
||||
global: { stubs: { AccountQuotaInfo: true } }
|
||||
})
|
||||
await flushPromises()
|
||||
expect(wrapper.text()).toContain('56 req')
|
||||
expect(wrapper.find('[title="usage.accountBilled"]').text()).toBe('A $2.63')
|
||||
expect(wrapper.find('[title="usage.userBilled"]').text()).toBe('· U $0.00')
|
||||
wrapper.unmount()
|
||||
})
|
||||
|
||||
it('renders zero local usage without inventing a user cost', async () => {
|
||||
getUsage.mockResolvedValue({})
|
||||
const wrapper = mount(AccountUsageCell, {
|
||||
props: {
|
||||
account: makeAccount({ id: 6402 }),
|
||||
todayStats: { requests: 0, tokens: 0, cost: 0 }
|
||||
},
|
||||
global: { stubs: { AccountQuotaInfo: true } }
|
||||
})
|
||||
await flushPromises()
|
||||
expect(wrapper.text()).toContain('0 req')
|
||||
expect(wrapper.find('[title="usage.accountBilled"]').text()).toBe('A $0.00')
|
||||
expect(wrapper.find('[title="usage.userBilled"]').exists()).toBe(false)
|
||||
wrapper.unmount()
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
getUsage.mockReset()
|
||||
Object.defineProperty(window, 'matchMedia', {
|
||||
|
||||
Reference in new issue
Block a user