缓存问题修复

This commit is contained in:
ZheFox
2026-07-16 18:55:28 +08:00
parent 715a5ed626
commit f009fb73c3
5 changed files with 148 additions and 6 deletions
@@ -7,6 +7,7 @@ import {
getCodexResetCreditAvailableCount,
getVisibleCodexResetCreditItems,
mergeCodexQuotaDisplays,
shouldRefreshMissingCodexResetCredits,
} from '@/features/providers/components/codex-reset-credit-display'
import type { QuotaResetCreditsSnapshot } from '@/api/endpoints/types'
@@ -59,6 +60,21 @@ describe('codex reset credit display helpers', () => {
expect(getVisibleCodexResetCreditItems(snapshot, 1_700_000_000)).toEqual([])
})
it('retries missing reset credits only when the cached detail check is stale', () => {
expect(shouldRefreshMissingCodexResetCredits(null, 1_700_000_000)).toBe(true)
expect(shouldRefreshMissingCodexResetCredits({
detail_status: 'failed',
updated_at: 1_699_999_900,
}, 1_700_000_000)).toBe(false)
expect(shouldRefreshMissingCodexResetCredits({
detail_status: 'failed',
updated_at: 1_699_999_600,
}, 1_700_000_000)).toBe(true)
expect(shouldRefreshMissingCodexResetCredits({
available_count: 0,
}, 1_700_000_000)).toBe(false)
})
it('sorts available detail items by remaining time and labels visible items with short ordinal keys', () => {
const snapshot: QuotaResetCreditsSnapshot = {
available_count: 7,