import { describe, expect, test } from 'vitest'; import { createElement } from 'react'; import { renderToStaticMarkup } from 'react-dom/server'; import '../src/i18n/index'; import { QuotaTimeline } from '../src/features/quota/components/QuotaTimeline'; import type { QuotaFileEntry } from '../src/features/quota/logic'; import { buildKimiQuotaRows } from '../src/utils/quota'; const entries: QuotaFileEntry[] = [ { file: { name: 'weekly-only.json', type: 'claude' }, type: 'claude', }, ]; const baseProps = { entries, displayNameFor: (name: string) => name, resolvedTheme: 'light' as const, now: new Date(2026, 6, 29, 12).getTime(), }; describe('QuotaTimeline rendering', () => { test('shows the selected period date instead of always labelling it Today', () => { const markup = renderToStaticMarkup( createElement(QuotaTimeline, { ...baseProps, initialOffset: 1, quotaFor: () => ({ status: 'success', windows: [ { label: '7-day', usedPercent: 25, resetAtMs: new Date(2026, 7, 1, 12).getTime(), periodHours: 168, }, ], }), }) ); // The next weekly period starts on Sunday 08/02. The button remains the // shortcut back to Today (aria-label/title), but its visible label now // reflects the period selected with the previous/next arrows. expect(markup).toMatch( /