feat: expand test coverage and configure comprehensive alerting

- Add unit tests for all core services (identity, intake, finance, dataroom)
- Create integration test framework with shared setup utilities
- Add E2E test suite for complete user workflows
- Add test utilities package (server factory)
- Configure Prometheus alert rules (service health, infrastructure, database, Azure)
- Add alert rules ConfigMap for Kubernetes
- Update Prometheus deployment with alert rules
- Fix tsconfig.json to include test files
- Add tests/tsconfig.json for integration/E2E tests
- Fix server-factory.ts linting issues
This commit is contained in:
defiQUG
2025-11-13 10:04:32 -08:00
parent dea584aa2c
commit 3d43155312
20 changed files with 822 additions and 35 deletions

View File

@@ -0,0 +1,45 @@
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
import { FastifyInstance } from 'fastify';
import { createServer } from '../src/index';
describe('Dataroom Service', () => {
let server: FastifyInstance;
beforeEach(async () => {
server = await createServer();
await server.ready();
});
afterEach(async () => {
await server.close();
});
describe('Health Check', () => {
it('should return 200 on health check', async () => {
const response = await server.inject({
method: 'GET',
url: '/health',
});
expect(response.statusCode).toBe(200);
expect(response.json()).toMatchObject({
status: 'ok',
});
});
});
describe('Deal Management', () => {
it('should validate deal creation request', async () => {
const response = await server.inject({
method: 'POST',
url: '/api/v1/deals',
payload: {
// Invalid payload to test validation
},
});
expect(response.statusCode).toBe(400);
});
});
});

View File

@@ -5,7 +5,7 @@
"rootDir": "./src",
"composite": true
},
"include": ["src/**/*"],
"include": ["src/**/*", "tests/**/*"],
"exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.spec.ts"],
"references": [
{ "path": "../../packages/shared" },

View File

@@ -0,0 +1,45 @@
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
import { FastifyInstance } from 'fastify';
import { createServer } from '../src/index';
describe('Finance Service', () => {
let server: FastifyInstance;
beforeEach(async () => {
server = await createServer();
await server.ready();
});
afterEach(async () => {
await server.close();
});
describe('Health Check', () => {
it('should return 200 on health check', async () => {
const response = await server.inject({
method: 'GET',
url: '/health',
});
expect(response.statusCode).toBe(200);
expect(response.json()).toMatchObject({
status: 'ok',
});
});
});
describe('Payment Processing', () => {
it('should validate payment request schema', async () => {
const response = await server.inject({
method: 'POST',
url: '/api/v1/payments',
payload: {
// Invalid payload to test validation
},
});
expect(response.statusCode).toBe(400);
});
});
});

View File

@@ -5,7 +5,7 @@
"rootDir": "./src",
"composite": true
},
"include": ["src/**/*"],
"include": ["src/**/*", "tests/**/*"],
"exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.spec.ts"],
"references": [
{ "path": "../../packages/shared" },

View File

@@ -0,0 +1,45 @@
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
import { FastifyInstance } from 'fastify';
import { createServer } from '../src/index';
describe('Identity Service', () => {
let server: FastifyInstance;
beforeEach(async () => {
server = await createServer();
await server.ready();
});
afterEach(async () => {
await server.close();
});
describe('Health Check', () => {
it('should return 200 on health check', async () => {
const response = await server.inject({
method: 'GET',
url: '/health',
});
expect(response.statusCode).toBe(200);
expect(response.json()).toMatchObject({
status: 'ok',
});
});
});
describe('Credential Issuance', () => {
it('should validate credential request schema', async () => {
const response = await server.inject({
method: 'POST',
url: '/api/v1/credentials/issue',
payload: {
// Invalid payload to test validation
},
});
expect(response.statusCode).toBe(400);
});
});
});

View File

@@ -4,7 +4,7 @@
"outDir": "./dist",
"composite": true
},
"include": ["src/**/*"],
"include": ["src/**/*", "tests/**/*"],
"exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.spec.ts"],
"references": [
{ "path": "../../packages/shared" },

View File

@@ -0,0 +1,45 @@
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
import { FastifyInstance } from 'fastify';
import { createServer } from '../src/index';
describe('Intake Service', () => {
let server: FastifyInstance;
beforeEach(async () => {
server = await createServer();
await server.ready();
});
afterEach(async () => {
await server.close();
});
describe('Health Check', () => {
it('should return 200 on health check', async () => {
const response = await server.inject({
method: 'GET',
url: '/health',
});
expect(response.statusCode).toBe(200);
expect(response.json()).toMatchObject({
status: 'ok',
});
});
});
describe('Document Upload', () => {
it('should validate document upload request', async () => {
const response = await server.inject({
method: 'POST',
url: '/api/v1/documents',
payload: {
// Invalid payload to test validation
},
});
expect(response.statusCode).toBe(400);
});
});
});

View File

@@ -5,7 +5,7 @@
"rootDir": "./src",
"composite": true
},
"include": ["src/**/*"],
"include": ["src/**/*", "tests/**/*"],
"exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.spec.ts"],
"references": [
{ "path": "../../packages/shared" },