upd: tampilan
This commit is contained in:
30
tests/integration/dashboard.test.ts
Normal file
30
tests/integration/dashboard.test.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { test, expect, describe } from 'bun:test'
|
||||
import { createTestApp } from '../helpers'
|
||||
|
||||
const app = createTestApp()
|
||||
|
||||
describe('Dashboard Routes (SPA)', () => {
|
||||
test('GET /dashboard returns 200 HTML', async () => {
|
||||
const res = await app.handle(new Request('http://localhost/dashboard'))
|
||||
expect(res.status).toBe(200)
|
||||
expect(res.headers.get('content-type')).toContain('text/html')
|
||||
})
|
||||
|
||||
test('GET /apps returns 200 HTML', async () => {
|
||||
const res = await app.handle(new Request('http://localhost/apps'))
|
||||
expect(res.status).toBe(200)
|
||||
expect(res.headers.get('content-type')).toContain('text/html')
|
||||
})
|
||||
|
||||
test('GET /apps/desa-plus returns 200 HTML', async () => {
|
||||
const res = await app.handle(new Request('http://localhost/apps/desa-plus'))
|
||||
expect(res.status).toBe(200)
|
||||
expect(res.headers.get('content-type')).toContain('text/html')
|
||||
})
|
||||
|
||||
test('GET /settings returns 200 HTML', async () => {
|
||||
const res = await app.handle(new Request('http://localhost/settings'))
|
||||
expect(res.status).toBe(200)
|
||||
expect(res.headers.get('content-type')).toContain('text/html')
|
||||
})
|
||||
})
|
||||
49
tests/integration/monitoring-api.test.ts
Normal file
49
tests/integration/monitoring-api.test.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
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')
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user