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.
This commit is contained in:
33
src/api/library.test.ts
Normal file
33
src/api/library.test.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { getFieldLibrary, updateFieldLibrary } from './library';
|
||||
|
||||
describe('field library API', () => {
|
||||
it('loads the backend field library envelope', async () => {
|
||||
vi.mocked(fetch).mockResolvedValueOnce({
|
||||
ok: true,
|
||||
status: 200,
|
||||
headers: new Headers({ 'content-type': 'application/json' }),
|
||||
json: () => Promise.resolve({ data: { library: { formFields: [], customTimeFormats: [], multiSelectOptions: {}, anesthesiaOptions: [] } } }),
|
||||
text: () => Promise.resolve(''),
|
||||
} as Response);
|
||||
|
||||
await expect(getFieldLibrary()).resolves.toMatchObject({ formFields: [] });
|
||||
});
|
||||
|
||||
it('patches field library changes', async () => {
|
||||
const fetchMock = vi.mocked(fetch);
|
||||
fetchMock.mockResolvedValueOnce({
|
||||
ok: true,
|
||||
status: 200,
|
||||
headers: new Headers({ 'content-type': 'application/json' }),
|
||||
json: () => Promise.resolve({ data: { library: { formFields: [], customTimeFormats: ['HH:mm'], multiSelectOptions: {}, anesthesiaOptions: [] } } }),
|
||||
text: () => Promise.resolve(''),
|
||||
} as Response);
|
||||
|
||||
await updateFieldLibrary({ customTimeFormats: ['HH:mm'] });
|
||||
expect(fetchMock).toHaveBeenCalledWith('/api/library/fields', expect.objectContaining({
|
||||
method: 'PATCH',
|
||||
credentials: 'include',
|
||||
}));
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user