feat(backend): add /diagnostics/flags + /diagnostics/telemetry routes
- GET /api/diagnostics/flags — returns all feature flags - GET /api/diagnostics/telemetry — returns buffered telemetry events - POST /api/diagnostics/telemetry/flush — flush telemetry buffer - Fix server.test.ts mock to include get/post + feature-flags/telemetry mocks - 80/80 tests pass
This commit is contained in:
parent
4a5a782333
commit
90b4bface4
@ -8,6 +8,8 @@ const initDatastoreMock = vi.fn(() => undefined);
|
||||
|
||||
const appMock = {
|
||||
register: vi.fn(async () => undefined),
|
||||
get: vi.fn(),
|
||||
post: vi.fn(),
|
||||
};
|
||||
|
||||
vi.mock('@bytelyst/fastify-core', () => ({
|
||||
@ -39,6 +41,8 @@ vi.mock('./lib/config.js', () => ({
|
||||
},
|
||||
}));
|
||||
vi.mock('./lib/product-config.js', () => ({ DISPLAY_NAME: 'NoteLett' }));
|
||||
vi.mock('./lib/feature-flags.js', () => ({ getAllFlags: vi.fn(() => ({})) }));
|
||||
vi.mock('./lib/telemetry.js', () => ({ getBufferedEvents: vi.fn(() => []), flushEvents: vi.fn(() => []) }));
|
||||
|
||||
describe('server bootstrap', () => {
|
||||
beforeEach(() => {
|
||||
|
||||
@ -10,6 +10,8 @@ import { workspaceRoutes } from './modules/workspaces/routes.js';
|
||||
import { initCosmosIfNeeded } from './lib/cosmos-init.js';
|
||||
import { initDatastore } from './lib/datastore.js';
|
||||
import { config } from './lib/config.js';
|
||||
import { getAllFlags } from './lib/feature-flags.js';
|
||||
import { getBufferedEvents, flushEvents } from './lib/telemetry.js';
|
||||
import { DISPLAY_NAME } from './lib/product-config.js';
|
||||
import type { JwtPayload } from './lib/request-context.js';
|
||||
|
||||
@ -53,4 +55,9 @@ await registerApiPlugin(noteTaskRoutes);
|
||||
await registerApiPlugin(savedViewRoutes);
|
||||
await registerApiPlugin(workspaceRoutes);
|
||||
|
||||
// ── Diagnostics routes (no auth) ────────────────────────────────
|
||||
app.get('/api/diagnostics/flags', async () => getAllFlags());
|
||||
app.get('/api/diagnostics/telemetry', async () => ({ events: getBufferedEvents() }));
|
||||
app.post('/api/diagnostics/telemetry/flush', async () => ({ flushed: flushEvents().length }));
|
||||
|
||||
await startService(app, { port: config.PORT, host: config.HOST });
|
||||
|
||||
Loading…
Reference in New Issue
Block a user