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:
64
tests/integration/setup.ts
Normal file
64
tests/integration/setup.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* Integration Test Setup
|
||||
* Provides shared utilities and fixtures for integration tests
|
||||
*/
|
||||
|
||||
import { FastifyInstance } from 'fastify';
|
||||
import { getPool } from '@the-order/database';
|
||||
|
||||
export interface TestContext {
|
||||
identityService: FastifyInstance;
|
||||
intakeService: FastifyInstance;
|
||||
financeService: FastifyInstance;
|
||||
dataroomService: FastifyInstance;
|
||||
dbPool: ReturnType<typeof getPool>;
|
||||
}
|
||||
|
||||
export async function setupTestContext(): Promise<TestContext> {
|
||||
// Import services dynamically to avoid circular dependencies
|
||||
const { createServer: createIdentityServer } = await import('../../services/identity/src/index');
|
||||
const { createServer: createIntakeServer } = await import('../../services/intake/src/index');
|
||||
const { createServer: createFinanceServer } = await import('../../services/finance/src/index');
|
||||
const { createServer: createDataroomServer } = await import('../../services/dataroom/src/index');
|
||||
|
||||
const identityService = await createIdentityServer();
|
||||
const intakeService = await createIntakeServer();
|
||||
const financeService = await createFinanceServer();
|
||||
const dataroomService = await createDataroomServer();
|
||||
|
||||
await Promise.all([
|
||||
identityService.ready(),
|
||||
intakeService.ready(),
|
||||
financeService.ready(),
|
||||
dataroomService.ready(),
|
||||
]);
|
||||
|
||||
const dbPool = getPool({
|
||||
connectionString: process.env.TEST_DATABASE_URL || process.env.DATABASE_URL || '',
|
||||
});
|
||||
|
||||
return {
|
||||
identityService,
|
||||
intakeService,
|
||||
financeService,
|
||||
dataroomService,
|
||||
dbPool,
|
||||
};
|
||||
}
|
||||
|
||||
export async function teardownTestContext(context: TestContext): Promise<void> {
|
||||
await Promise.all([
|
||||
context.identityService.close(),
|
||||
context.intakeService.close(),
|
||||
context.financeService.close(),
|
||||
context.dataroomService.close(),
|
||||
]);
|
||||
|
||||
await context.dbPool.end();
|
||||
}
|
||||
|
||||
export async function cleanupDatabase(pool: ReturnType<typeof getPool>): Promise<void> {
|
||||
// Clean up test data
|
||||
await pool.query('TRUNCATE TABLE credentials, documents, payments, deals CASCADE');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user