mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-09 16:59:43 +02:00
test: add shared mock infrastructure and route tests (phase 7)
Consolidate duplicated MockSession/MockStateStore into test/mocks/, migrate respawn tests to shared mocks, and add 58 route tests for session, system, and respawn endpoints using Fastify app.inject(). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -11,32 +11,7 @@ import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
|
||||
import { RespawnController } from '../src/respawn-controller.js';
|
||||
import { Session } from '../src/session.js';
|
||||
import { TeamWatcher } from '../src/team-watcher.js';
|
||||
import { EventEmitter } from 'node:events';
|
||||
|
||||
// ========== Mock Session ==========
|
||||
|
||||
class MockSession extends EventEmitter {
|
||||
id = 'test-session-123';
|
||||
workingDir = '/tmp/test';
|
||||
status = 'idle';
|
||||
pid = 12345;
|
||||
isWorking = false;
|
||||
writeBuffer: string[] = [];
|
||||
ralphTracker: null = null;
|
||||
|
||||
async writeViaMux(data: string): Promise<boolean> {
|
||||
this.writeBuffer.push(data);
|
||||
return true;
|
||||
}
|
||||
|
||||
write(data: string): void {
|
||||
this.writeBuffer.push(data);
|
||||
}
|
||||
|
||||
simulateCompletionMessage(): void {
|
||||
this.emit('terminal', '✻ Worked for 2m 46s');
|
||||
}
|
||||
}
|
||||
import { MockSession } from './mocks/index.js';
|
||||
|
||||
// ========== Mock TeamWatcher ==========
|
||||
|
||||
|
||||
Reference in New Issue
Block a user