- routes across all domains: trade finance, compliance, dpp, logistics, commodities, energy, workforce, data + cross-cutting (auth/webhooks/exports/reports/admin/analytics) - service layer per domain aggregating chain reads + infra repositories into typed DTOs - indexer handlers mapping every contract group's events to repository upserts - api + workspace typecheck green Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
29 lines
1.1 KiB
TypeScript
29 lines
1.1 KiB
TypeScript
/**
|
|
* /analytics/finance route test. The plugin registers `/finance`; the
|
|
* autoloader applies the `/analytics` directory prefix in production, but here
|
|
* it is mounted un-prefixed (buildApp registers a single plugin).
|
|
*/
|
|
import { describe, expect, it } from 'vitest';
|
|
import financePlugin from '../../../src/routes/analytics/finance.js';
|
|
import { buildApp, makeDb, type Row } from '../../routers-kit.js';
|
|
|
|
const seeded: Record<string, readonly Row[]> = {
|
|
financing_listings: [{ id: 'l1' }, { id: 'l2' }],
|
|
receivables: [{ id: 'r1' }],
|
|
pools: [{ id: 'p1' }],
|
|
indexer_events: [{ id: 'e1', group_name: 'finance' }],
|
|
};
|
|
|
|
describe('analytics/finance router', () => {
|
|
it('returns the finance domain drill-down', async () => {
|
|
const app = await buildApp(financePlugin, { db: makeDb(seeded) });
|
|
const res = await app.inject({ method: 'GET', url: '/finance' });
|
|
expect(res.statusCode).toBe(200);
|
|
const data = res.json().data;
|
|
expect(data.domain).toBe('finance');
|
|
expect(data.events).toBe(1);
|
|
expect(data.metrics).toEqual({ listings: 2, receivables: 1, pools: 1 });
|
|
await app.close();
|
|
});
|
|
});
|