feat(quota): display all Codex reset credit expiry times
- List each expiry chronologically instead of showing only the earliest - Update auth file panels, quota cards, and reset confirmation dialogs - Preserve separate entries for credits with identical expiry times - Add translations and regression coverage
This commit is contained in:
1 parent
20be08f388
commit
1532bdb056
12 files changed
+80
-12
No files matched your search
@@ -7,6 +7,24 @@ import { QuotaCard } from '../src/pages/QuotaPage';
|
||||
|
||||
const render = (quota: QuotaState) => renderToStaticMarkup(<I18nProvider><AuthFileQuotaPanel file={{ name: 'test.json' }} quota={quota} disabled={false} onRefresh={() => {}} /></I18nProvider>);
|
||||
|
||||
it('shows every reset expiry in chronological order, including duplicates, on both surfaces', () => {
|
||||
const quota: QuotaState = {
|
||||
status: 'success', rows: [], resetCredits: 3,
|
||||
resetCreditExpiries: ['2030-12-20T00:00:00Z', '2030-10-10T00:00:00Z', '2030-10-10T00:00:00Z'],
|
||||
};
|
||||
const file = { name: 'codex.json', provider: 'codex' };
|
||||
for (const content of [
|
||||
<AuthFileQuotaPanel file={file} quota={quota} disabled={false} compact dense onRefresh={() => {}} />,
|
||||
<QuotaCard file={file} quota={quota} onRefresh={() => {}} />,
|
||||
]) {
|
||||
const html = renderToStaticMarkup(<I18nProvider>{content}</I18nProvider>);
|
||||
expect(html.match(/<li>/g)).toHaveLength(3);
|
||||
expect(html).toContain('Reset 3 expires');
|
||||
expect(html).not.toContain('Earliest expiry');
|
||||
expect(html.indexOf('10/10/2030')).toBeLessThan(html.indexOf('12/20/2030'));
|
||||
}
|
||||
});
|
||||
|
||||
it('renders real quota values with bounded bars and keeps unknown distinct from zero', () => {
|
||||
const html = render({ status: 'success', rows: [
|
||||
{ label: 'empty', remainingPercent: 0 }, { label: 'full', remainingPercent: 100 },
|
||||
|
||||
Vendored
+1
-1
@@ -24,7 +24,7 @@ createRoot(document.getElementById('root')!).render(
|
||||
{[1, 2, 3, 4, 5, 6].map((id) => <QuotaCard key={id} file={{ name: `kimi-${id}-long-credential-name@example.com.json`, provider: 'kimi' }} quota={{ status: 'success', rows }} onRefresh={() => {}} />)}
|
||||
</div>
|
||||
<div className="real-quota-grid">
|
||||
<QuotaCard file={{ name: 'codex.json', provider: 'codex' }} quota={{ status: 'success', rows, resetCredits: 2, resetCreditsApplicable: 2, plan: 'team', subscriptionActiveUntil: '2030-10-17T13:58:00Z', resetCreditsEarliestExpiry: '2030-10-23T05:10:00Z' }} onRefresh={() => {}} onReset={() => {}} />
|
||||
<QuotaCard file={{ name: 'codex.json', provider: 'codex' }} quota={{ status: 'success', rows, resetCredits: 2, resetCreditsApplicable: 2, plan: 'team', subscriptionActiveUntil: '2030-10-17T13:58:00Z', resetCreditExpiries: ['2030-10-23T05:10:00Z', '2030-11-23T05:10:00Z'] }} onRefresh={() => {}} onReset={() => {}} />
|
||||
<QuotaCard file={claudeFile} quota={claudeQuota} onRefresh={() => {}} onReset={() => {}} />
|
||||
<QuotaCard file={{ name: 'failed.json', provider: 'kimi' }} quota={{ status: 'error', rows: [], error: 'Quota request failed' }} onRefresh={() => {}} />
|
||||
<QuotaCard file={{ name: 'loading.json', provider: 'kimi' }} quota={{ status: 'loading', rows: [] }} onRefresh={() => {}} />
|
||||
|
||||
@@ -136,11 +136,12 @@ describe('quotaRowsFor', () => {
|
||||
expect(result).toEqual({
|
||||
availableCount: 2,
|
||||
earliestExpiry: '2026-08-12T18:06:25Z',
|
||||
expiries: ['2026-08-12T18:06:25Z', '2026-08-20T00:00:00Z'],
|
||||
});
|
||||
});
|
||||
|
||||
it('重置次数支持 applicable 字段、空列表,不把过期积分算入推断次数', () => {
|
||||
expect(codexResetCreditDetailsFor({ credits: [] })).toEqual({ availableCount: undefined, earliestExpiry: undefined });
|
||||
expect(codexResetCreditDetailsFor({ credits: [] })).toEqual({ availableCount: undefined, earliestExpiry: undefined, expiries: [] });
|
||||
expect(codexResetCreditDetailsFor({
|
||||
applicableAvailableCount: '0',
|
||||
credits: [
|
||||
@@ -150,7 +151,7 @@ describe('quotaRowsFor', () => {
|
||||
{ resetType: 'other', status: 'available', expiresAt: '2030-01-01T00:00:00Z' },
|
||||
],
|
||||
}, Date.parse('2026-01-01T00:00:00Z'))).toEqual({
|
||||
availableCount: 1, applicableAvailableCount: 0, earliestExpiry: '2030-01-01T00:00:00Z',
|
||||
availableCount: 1, applicableAvailableCount: 0, earliestExpiry: '2030-01-01T00:00:00Z', expiries: ['2030-01-01T00:00:00Z'],
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user