Files
Mdeical_Sur_Report/src/api/dashboard.test.ts
admin 014aca8619 Initialize backendized SurClaw report system
- Add React/Vite frontend for login, dashboard, reports, templates, users, settings, AI, speech, and media workflows.

- Add NestJS/Prisma/PostgreSQL backend with auth, dashboard stats, reports, templates, users, departments, settings, files, AI, speech, audit logs, and HTML sanitization.

- Add Prisma schema, migrations, seed data, persistent app sessions, Docker/Nginx deployment files, and upload volume configuration.

- Add Vitest, Playwright, backend integration tests, and project documentation for requirements, design, permissions, API contracts, testing, deployment, security, and progress.

- Configure production local fallback switch and remove unused Gemini direct dependency/env wiring.
2026-05-02 01:41:57 +08:00

30 lines
967 B
TypeScript

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' }));
});
});