- 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.
38 lines
1.5 KiB
TypeScript
38 lines
1.5 KiB
TypeScript
import { describe, expect, it, vi } from 'vitest';
|
|
import { listFiles, uploadFileResource } from './files';
|
|
|
|
describe('files API', () => {
|
|
it('lists file resources by kind', async () => {
|
|
const fetchMock = vi.mocked(fetch);
|
|
fetchMock.mockResolvedValueOnce({
|
|
ok: true,
|
|
status: 200,
|
|
headers: new Headers({ 'content-type': 'application/json' }),
|
|
json: () => Promise.resolve({ data: { items: [] } }),
|
|
text: () => Promise.resolve(''),
|
|
} as Response);
|
|
|
|
await expect(listFiles('TEMPLATE_ASSET')).resolves.toEqual([]);
|
|
expect(fetchMock).toHaveBeenCalledWith('/api/files?kind=TEMPLATE_ASSET', expect.objectContaining({
|
|
credentials: 'include',
|
|
}));
|
|
});
|
|
|
|
it('uploads a generic file resource', async () => {
|
|
const fetchMock = vi.mocked(fetch);
|
|
fetchMock.mockResolvedValueOnce({
|
|
ok: true,
|
|
status: 200,
|
|
headers: new Headers({ 'content-type': 'application/json' }),
|
|
json: () => Promise.resolve({ data: { file: { id: 'file_1', filename: 'a.png', mimeType: 'image/png', size: 10, url: '/api/files/file_1/content', createdAt: '2026-05-02T00:00:00.000Z' } } }),
|
|
text: () => Promise.resolve(''),
|
|
} as Response);
|
|
|
|
await expect(uploadFileResource('data:image/png;base64,AA==', { filename: 'a.png' })).resolves.toMatchObject({ id: 'file_1' });
|
|
expect(fetchMock).toHaveBeenCalledWith('/api/files', expect.objectContaining({
|
|
method: 'POST',
|
|
credentials: 'include',
|
|
}));
|
|
});
|
|
});
|