/** * Integration Test: IntegrationTestHarness * * Tests the IntegrationTestHarness orchestration capabilities */ import { describe, it, expect } from 'vitest'; import { setupHarnessTest } from '../HarnessTestContext'; describe('IntegrationTestHarness - Orchestration Tests', () => { const context = setupHarnessTest(); describe('Accessors', () => { it('should provide access to all managers', () => { expect(context.testHarness.getDatabase()).toBeDefined(); expect(context.testHarness.getApi()).toBeDefined(); expect(context.testHarness.getDocker()).toBeDefined(); expect(context.testHarness.getFactory()).toBeDefined(); }); }); describe('Transaction Management', () => { it('should execute callback within transaction and rollback', async () => { const result = await context.testHarness.withTransaction(async (db) => { const queryResult = await db.query('SELECT 1 as val'); return queryResult.rows[0].val; }); expect(result).toBe(1); }); }); describe('Constraint Violation Detection', () => { it('should detect constraint violations', async () => { await expect( context.testHarness.expectConstraintViolation(async () => { throw new Error('constraint violation: duplicate key'); }) ).resolves.not.toThrow(); }); it('should fail if no violation occurs', async () => { await expect( context.testHarness.expectConstraintViolation(async () => { // Success }) ).rejects.toThrow('Expected constraint violation but operation succeeded'); }); it('should fail if different error occurs', async () => { await expect( context.testHarness.expectConstraintViolation(async () => { throw new Error('Some other error'); }) ).rejects.toThrow('Expected constraint violation but got: Some other error'); }); }); });