diff --git a/tests/agentEngine.test.ts b/tests/agentEngine.test.ts index e8a725f..e27e9ae 100644 --- a/tests/agentEngine.test.ts +++ b/tests/agentEngine.test.ts @@ -19,6 +19,21 @@ import { MissionState, PipelineStage } from '../src/lib/engine'; +import * as fs from 'fs'; +import * as path from 'path'; + +// ─── Setup ─── +beforeAll(() => { + const cacheDir = path.join(process.cwd(), '.astra', 'cache'); + if (fs.existsSync(cacheDir)) { + fs.rmSync(cacheDir, { recursive: true, force: true }); + } + const missionDir = path.join(process.cwd(), '.astra', 'missions'); + if (fs.existsSync(missionDir)) { + fs.rmSync(missionDir, { recursive: true, force: true }); + } +}); + // ─── Mock Agents ─── @@ -251,7 +266,8 @@ describe('AgentEngine Integration', () => { 'integration_001', 'Test prompt', 'brain context', createAbortSignal(), noopProgress ); - expect(result).toBe('Report: final synthesized output for the user.'); + expect(result).toContain('Report: final synthesized output for the user.'); + expect(result).toContain('standard: P-Reinforce v3.0'); }); test('Transient 오류 발생 시 자동 재시도 후 복구되어야 한다', async () => { @@ -438,7 +454,7 @@ describe('Concurrency & Stress Tests', () => { new MockSuccessAgent('Research result that meets the minimum validation length.'), new MockSuccessAgent('Normal report completed successfully with all checks passed.') ); - const p1 = engine1.runMission('mix_normal', 'Test', 'ctx', createAbortSignal(), noopProgress); + const p1 = engine1.runMission('mix_normal', 'Test Normal', 'ctx', createAbortSignal(), noopProgress); // 미션 2: Permanent 실패 const engine2 = new AgentEngine( @@ -446,7 +462,7 @@ describe('Concurrency & Stress Tests', () => { new MockSuccessAgent(), new MockSuccessAgent() ); - const p2 = engine2.runMission('mix_permanent', 'Test', 'ctx', createAbortSignal(), noopProgress) + const p2 = engine2.runMission('mix_permanent', 'Test Permanent', 'ctx', createAbortSignal(), noopProgress) .catch(e => `ERROR:${e.message}`); // 미션 3: Transient 복구 @@ -455,7 +471,7 @@ describe('Concurrency & Stress Tests', () => { new MockSuccessAgent('Research after single transient recovery for mixed test.'), new MockSuccessAgent('Report after transient recovery completed successfully.') ); - const p3 = engine3.runMission('mix_transient', 'Test', 'ctx', createAbortSignal(), noopProgress); + const p3 = engine3.runMission('mix_transient', 'Test Transient', 'ctx', createAbortSignal(), noopProgress); const [r1, r2, r3] = await Promise.all([p1, p2, p3]); @@ -463,6 +479,7 @@ describe('Concurrency & Stress Tests', () => { expect(r1).toContain('Normal report'); // Permanent 미션은 에러 메시지 반환 expect(r2).toContain('ERROR:'); + expect(r2).toContain('근본적인 문제'); // Transient 미션은 복구 후 성공 expect(r3).toContain('Report after transient');