mirror of
https://github.com/router-for-me/Cli-Proxy-API-Management-Center.git
synced 2026-08-30 17:56:18 +08:00
fix(kimi): reorder usage summary in buildKimiQuotaRows function
This commit is contained in:
+10
-10
@@ -223,16 +223,6 @@ function toKimiUsageRow(
|
||||
export function buildKimiQuotaRows(payload: KimiUsagePayload): KimiQuotaRow[] {
|
||||
const rows: KimiQuotaRow[] = [];
|
||||
|
||||
const usage = payload.usage;
|
||||
if (usage && typeof usage === 'object') {
|
||||
const summary = toKimiUsageRow(usage as Record<string, unknown>, {
|
||||
labelKey: 'kimi_quota.weekly_limit',
|
||||
});
|
||||
if (summary) {
|
||||
rows.push({ id: 'summary', ...summary });
|
||||
}
|
||||
}
|
||||
|
||||
const limits = payload.limits;
|
||||
if (Array.isArray(limits)) {
|
||||
limits.forEach((item, idx) => {
|
||||
@@ -250,6 +240,16 @@ export function buildKimiQuotaRows(payload: KimiUsagePayload): KimiQuotaRow[] {
|
||||
});
|
||||
}
|
||||
|
||||
const usage = payload.usage;
|
||||
if (usage && typeof usage === 'object') {
|
||||
const summary = toKimiUsageRow(usage as Record<string, unknown>, {
|
||||
labelKey: 'kimi_quota.weekly_limit',
|
||||
});
|
||||
if (summary) {
|
||||
rows.push({ id: 'summary', ...summary });
|
||||
}
|
||||
}
|
||||
|
||||
return rows;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import { describe, expect, test } from 'bun:test';
|
||||
import { buildKimiQuotaRows } from '@/utils/quota';
|
||||
|
||||
describe('Kimi quota ordering', () => {
|
||||
test('shows the 5-hour limit before the weekly limit', () => {
|
||||
const rows = buildKimiQuotaRows({
|
||||
usage: {
|
||||
used: 200,
|
||||
limit: 1000,
|
||||
},
|
||||
limits: [
|
||||
{
|
||||
detail: {
|
||||
used: 20,
|
||||
limit: 100,
|
||||
},
|
||||
window: {
|
||||
duration: 300,
|
||||
timeUnit: 'MINUTES',
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
expect(rows.map(({ id }) => id)).toEqual(['limit-0', 'summary']);
|
||||
expect(rows[0]?.labelKey).toBe('kimi_quota.limit_window');
|
||||
expect(rows[0]?.labelParams).toEqual({ duration: '5h' });
|
||||
expect(rows[1]?.labelKey).toBe('kimi_quota.weekly_limit');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user