- Add test-helpers.ts with buildTestApp() + resetMemoryDatastore() - notes: 11 tests (CRUD, archive, filter, search, validation) - workspaces: 7 tests (CRUD, summaries with noteCount, validation) - note-tasks: 6 tests (CRUD, filter by workspaceId, validation) - note-artifacts: 7 tests (CRUD, filter by noteId, validation) - note-relationships: 4 tests (create, list, validation) - note-agent-actions: 8 tests (CRUD, pending, batch-review, validation) - saved-views: 8 tests (CRUD, filter by scope, delete, validation) - Fix listPendingActions to avoid unsupported $in operator in memory provider - Total: 75 backend tests (was 24)
27 lines
708 B
TypeScript
27 lines
708 B
TypeScript
import Fastify from 'fastify';
|
|
import { MemoryDatastoreProvider } from '@bytelyst/datastore';
|
|
import { setProvider } from './lib/datastore.js';
|
|
|
|
export function resetMemoryDatastore(): void {
|
|
const provider = new MemoryDatastoreProvider();
|
|
setProvider(provider);
|
|
}
|
|
|
|
export async function buildTestApp(
|
|
routePlugin: (app: ReturnType<typeof Fastify>) => Promise<void>,
|
|
) {
|
|
resetMemoryDatastore();
|
|
|
|
const app = Fastify({ logger: false });
|
|
await app.register(routePlugin, { prefix: '/api' });
|
|
await app.ready();
|
|
return app;
|
|
}
|
|
|
|
export const TEST_USER_ID = 'test-user-1';
|
|
export const TEST_PRODUCT_ID = 'notelett';
|
|
|
|
export function authHeader() {
|
|
return { authorization: 'Bearer test-token' };
|
|
}
|