Files
gridpilot.gg/tests/integration/harness/orchestration/integration-test-harness.test.ts
Marc Mintel a0f41f242f
Some checks failed
CI / lint-typecheck (pull_request) Failing after 4m51s
CI / tests (pull_request) Has been skipped
CI / contract-tests (pull_request) Has been skipped
CI / e2e-tests (pull_request) Has been skipped
CI / comment-pr (pull_request) Has been skipped
CI / commit-types (pull_request) Has been skipped
integration tests
2026-01-23 00:46:34 +01:00

58 lines
1.9 KiB
TypeScript

/**
* 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');
});
});
});