import * as path from 'path'; import * as fs from 'fs-extra'; import * as os from 'os'; import simpleGit from 'simple-git'; import { setupTestRepo, cleanupTestRepo } from './helpers'; describe('Integration Tests', () => { let testRepo: string; beforeEach(async () => { testRepo = await setupTestRepo(); }); afterEach(async () => { if (testRepo) { await cleanupTestRepo(testRepo); } }); describe('Error Handling', () => { it('should handle invalid agent names gracefully', async () => { const { sanitizeAgentName, isValidAgentName } = await import('../../src/utils/file-utils'); expect(isValidAgentName('')).toBe(false); expect(isValidAgentName('123')).toBe(false); expect(isValidAgentName('my agent')).toBe(true); expect(isValidAgentName('my@agent')).toBe(true); expect(sanitizeAgentName('My Agent')).toBe('my-agent'); }); it('should fail when not in a git repository', async () => { const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'gas-not-git-')); try { const git = simpleGit(tempDir); let errorThrown = false; try { await git.raw('rev-parse', '--is-inside-work-tree'); } catch { errorThrown = true; } expect(errorThrown).toBe(true); } finally { fs.removeSync(tempDir); } }); }); });