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:
arkon
2026-03-01 14:33:18 +01:00
co-authored by Claude Opus 4.6
parent 97ca13916a
commit 442cc19c3c
13 changed files with 2421 additions and 428 deletions
+1 -26
View File
@@ -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 ==========