import { test, expect, describe } from 'bun:test' import { createTestApp } from '../helpers' const app = createTestApp() describe('Monitoring API', () => { describe('GET /api/dashboard/stats', () => { test('returns 200 with dashboard stats', async () => { const res = await app.handle(new Request('http://localhost/api/dashboard/stats')) expect(res.status).toBe(200) const body = await res.json() expect(body).toHaveProperty('totalApps') expect(body).toHaveProperty('newErrors') expect(body).toHaveProperty('activeUsers') expect(body).toHaveProperty('trends') }) }) describe('GET /api/apps', () => { test('returns 200 with list of apps', async () => { const res = await app.handle(new Request('http://localhost/api/apps')) expect(res.status).toBe(200) const body = await res.json() expect(Array.isArray(body)).toBe(true) expect(body.length).toBeGreaterThan(0) expect(body[0]).toHaveProperty('id') expect(body[0]).toHaveProperty('name') expect(body[0]).toHaveProperty('status') }) }) describe('GET /api/apps/:appId', () => { test('returns 200 with specific app details', async () => { const res = await app.handle(new Request('http://localhost/api/apps/desa-plus')) expect(res.status).toBe(200) const body = await res.json() expect(body.id).toBe('desa-plus') expect(body.name).toBe('Desa+') }) test('returns fallback for unknown app', async () => { const res = await app.handle(new Request('http://localhost/api/apps/unknown-app')) expect(res.status).toBe(200) const body = await res.json() expect(body.id).toBe('unknown-app') expect(body.name).toBe('unknown-app') }) }) })