self-serve-integration-service
Version:
Self-Serve Integration Service for managing multiple funder integrations including REST APIs, SOAP APIs, and UI automation
66 lines (56 loc) • 2.24 kB
text/typescript
import request from 'supertest';
import express from 'express';
import healthRoutes from '../routes/healthRoutes';
// Create a test app
const app = express();
app.use(express.json());
app.use('/health', healthRoutes);
describe('Health Routes', () => {
describe('GET /health', () => {
it('should return 200 and health status', async () => {
const response = await request(app).get('/health').expect(200);
expect(response.body).toEqual({
status: 'healthy',
database: 'connected',
timestamp: expect.any(String),
});
});
});
// Note: /health/detailed endpoint doesn't exist in the current implementation
// This test is commented out until the endpoint is implemented
/*
describe('GET /health/detailed', () => {
it('should return detailed health information', async () => {
const response = await request(app)
.get('/health/detailed')
.expect(200);
expect(response.body.success).toBe(true);
expect(response.body.message).toBe('Detailed health check completed');
expect(response.body.service).toBe('self-serve-integration-service');
expect(response.body.version).toBe('1.0.0');
expect(response.body.checks).toBeDefined();
expect(response.body.checks.database).toBeDefined();
expect(response.body.checks.codeweavers).toBeDefined();
expect(response.body.checks.environment).toBeDefined();
});
});
*/
describe('GET /health/ready', () => {
it('should return ready status', async () => {
const response = await request(app).get('/health/ready').expect(200);
expect(response.body.status).toBe('ready');
expect(response.body.timestamp).toBeDefined();
expect(response.body.checks).toBeDefined();
expect(response.body.checks.database).toBe('healthy');
expect(response.body.checks.funders).toBe('healthy');
});
});
describe('GET /health/live', () => {
it('should return liveness status', async () => {
const response = await request(app).get('/health/live').expect(200);
expect(response.body.status).toBe('alive');
expect(response.body.timestamp).toBeDefined();
expect(response.body.uptime).toBeDefined();
});
});
});