Files
automaker/apps/server/tests/utils/helpers.ts
Kacper 23ff99d2e2 feat: add comprehensive integration tests for auto-mode-service
- Created git-test-repo helper for managing test git repositories
- Added 13 integration tests covering:
  - Worktree operations (create, error handling, non-worktree mode)
  - Feature execution (status updates, model selection, duplicate prevention)
  - Auto loop (start/stop, pending features, max concurrency, events)
  - Error handling (provider errors, continue after failures)
- Integration tests use real git operations with temporary repos
- All 416 tests passing with 72.65% overall coverage
- Service coverage improved: agent-service 58%, auto-mode-service 44%, feature-loader 66%

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-13 13:34:27 +01:00

39 lines
838 B
TypeScript

/**
* Test helper functions
*/
/**
* Collect all values from an async generator
*/
export async function collectAsyncGenerator<T>(gen: AsyncGenerator<T>): Promise<T[]> {
const results: T[] = [];
for await (const item of gen) {
results.push(item);
}
return results;
}
/**
* Wait for a condition to be true
*/
export async function waitFor(
condition: () => boolean,
timeout = 1000,
interval = 10
): Promise<void> {
const start = Date.now();
while (!condition()) {
if (Date.now() - start > timeout) {
throw new Error("Timeout waiting for condition");
}
await new Promise((resolve) => setTimeout(resolve, interval));
}
}
/**
* Create a temporary directory for tests
*/
export function createTempDir(): string {
return `/tmp/test-${Date.now()}-${Math.random().toString(36).slice(2)}`;
}