mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-10 03:09:50 +08:00
fix(frontend): 优化移动端弹窗并完善提供商配额刷新
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { createApp, defineComponent, h } from 'vue'
|
||||
|
||||
import ProxyNodeSelect from '@/features/providers/components/ProxyNodeSelect.vue'
|
||||
import { createI18n } from '@/i18n'
|
||||
|
||||
const proxyNodesStore = vi.hoisted(() => ({
|
||||
loading: false,
|
||||
nodes: [],
|
||||
onlineNodes: [],
|
||||
ensureLoaded: vi.fn(() => Promise.resolve()),
|
||||
}))
|
||||
|
||||
vi.mock('@/stores/proxy-nodes', () => ({
|
||||
useProxyNodesStore: () => proxyNodesStore,
|
||||
}))
|
||||
|
||||
vi.mock('@/components/ui', async () => {
|
||||
const { defineComponent, h } = await import('vue')
|
||||
const passthrough = (name: string) => defineComponent({
|
||||
name,
|
||||
setup(_, { slots }) {
|
||||
return () => h('div', slots.default?.())
|
||||
},
|
||||
})
|
||||
|
||||
return {
|
||||
Select: passthrough('SelectStub'),
|
||||
SelectTrigger: passthrough('SelectTriggerStub'),
|
||||
SelectValue: passthrough('SelectValueStub'),
|
||||
SelectContent: passthrough('SelectContentStub'),
|
||||
SelectItem: passthrough('SelectItemStub'),
|
||||
}
|
||||
})
|
||||
|
||||
describe('ProxyNodeSelect', () => {
|
||||
it('loads proxy nodes when mounted', () => {
|
||||
const root = document.createElement('div')
|
||||
const app = createApp(defineComponent({
|
||||
setup() {
|
||||
return () => h(ProxyNodeSelect, { modelValue: '' })
|
||||
},
|
||||
}))
|
||||
|
||||
app.use(createI18n())
|
||||
app.mount(root)
|
||||
|
||||
expect(proxyNodesStore.ensureLoaded).toHaveBeenCalledTimes(1)
|
||||
|
||||
app.unmount()
|
||||
})
|
||||
})
|
||||
+30
@@ -5,10 +5,40 @@ import {
|
||||
formatCodexResetCreditDays,
|
||||
getCodexResetCreditAvailableCount,
|
||||
getVisibleCodexResetCreditItems,
|
||||
mergeCodexQuotaDisplays,
|
||||
} from '@/features/providers/components/codex-reset-credit-display'
|
||||
import type { QuotaResetCreditsSnapshot } from '@/api/endpoints/types'
|
||||
|
||||
describe('codex reset credit display helpers', () => {
|
||||
it('keeps reset credits and usage windows when snapshot sources are partially populated', () => {
|
||||
const merged = mergeCodexQuotaDisplays(
|
||||
{
|
||||
updated_at: 1_700_000_100,
|
||||
primary_used_percent: 25,
|
||||
reset_credits: {
|
||||
available_count: 2,
|
||||
},
|
||||
},
|
||||
{
|
||||
updated_at: 1_700_000_000,
|
||||
secondary_used_percent: 40,
|
||||
reset_credits: {
|
||||
credits: [{ id: 'credit-1', expires_at: 1_700_086_400 }],
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
expect(merged).toMatchObject({
|
||||
updated_at: 1_700_000_100,
|
||||
primary_used_percent: 25,
|
||||
secondary_used_percent: 40,
|
||||
reset_credits: {
|
||||
available_count: 2,
|
||||
credits: [{ id: 'credit-1', expires_at: 1_700_086_400 }],
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
it('keeps zero available credits displayable but non-positive detail items hidden', () => {
|
||||
const snapshot: QuotaResetCreditsSnapshot = {
|
||||
available_count: 0,
|
||||
|
||||
Reference in New Issue
Block a user