import { describe, expect, it, vi } from 'vitest'; import { getDashboardStats } from './dashboard'; describe('dashboard api', () => { it('loads dashboard stats from backend', async () => { vi.mocked(fetch).mockResolvedValueOnce({ ok: true, headers: new Headers({ 'content-type': 'application/json' }), json: async () => ({ data: { stats: { totalCount: 1, monthCount: 1, templateCount: 2, userCount: 3, todayCount: 1, trend: [0, 1], trendLabels: ['5/1', '5/2'], trendFullDates: ['2026-05-01', '2026-05-02'], maxTrend: 1, }, }, }), } as Response); await expect(getDashboardStats('7days')).resolves.toMatchObject({ totalCount: 1, userCount: 3 }); expect(fetch).toHaveBeenCalledWith('/api/dashboard/stats?range=7days', expect.objectContaining({ credentials: 'include' })); }); });