mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-04 14:39:42 +02:00
fix: resolve 11 failing tests across 8 test files
- ralph-tracker: add ✓ to native todo pattern + pre-check, add configure() method - session: remove stale message expectation from interactive endpoint test - buffer-management: fix trim count expectations (1202 items triggers second trim) - cli-commands: replace non-existent toStartWith with toMatch regex - edge-cases: update error expectation for session-not-found on respawn config PUT - ralph-integration: respawn config PUT without controller now saves as pre-config - session-state: fix debouncer shouldFlush(0) - pass timestamp >= delayMs - timing-utilities: attach catch handlers before advancing fake timers Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -155,7 +155,7 @@ describe('Buffer Management', () => {
|
||||
|
||||
it('should trim when over limit', () => {
|
||||
const store = new MessageStore<number>();
|
||||
for (let i = 0; i < 1200; i++) {
|
||||
for (let i = 0; i < 1202; i++) {
|
||||
store.add(i);
|
||||
}
|
||||
expect(store.count).toBe(TRIM_MESSAGES_TO);
|
||||
@@ -163,12 +163,12 @@ describe('Buffer Management', () => {
|
||||
|
||||
it('should keep recent messages', () => {
|
||||
const store = new MessageStore<number>();
|
||||
for (let i = 0; i < 1200; i++) {
|
||||
for (let i = 0; i < 1202; i++) {
|
||||
store.add(i);
|
||||
}
|
||||
const all = store.all;
|
||||
expect(all[all.length - 1]).toBe(1199);
|
||||
expect(all[0]).toBe(1199 - TRIM_MESSAGES_TO + 1);
|
||||
expect(all[all.length - 1]).toBe(1201);
|
||||
expect(all[0]).toBe(1201 - TRIM_MESSAGES_TO + 1);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -348,7 +348,7 @@ describe('CLI Command Parsing', () => {
|
||||
it('should format properly', () => {
|
||||
const help = generateHelp('test', 'Test command', ['--flag']);
|
||||
const lines = help.split('\n');
|
||||
expect(lines[0]).toStartWith('Usage:');
|
||||
expect(lines[0]).toMatch(/^Usage:/);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -224,7 +224,7 @@ describe('Edge Cases and Error Handling', () => {
|
||||
expect(data.error).toBe('Respawn controller not found');
|
||||
});
|
||||
|
||||
it('should handle updating config on non-existent respawn controller', async () => {
|
||||
it('should handle updating config on non-existent session', async () => {
|
||||
const response = await fetch(`${baseUrl}/api/sessions/non-existent/respawn/config`, {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
@@ -232,7 +232,7 @@ describe('Edge Cases and Error Handling', () => {
|
||||
});
|
||||
const data = await response.json();
|
||||
|
||||
expect(data.error).toBe('Respawn controller not found');
|
||||
expect(data.error).toBe('Session not found');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -935,7 +935,7 @@ describe('Ralph Integration Tests', () => {
|
||||
expect(data.errorCode).toBe('NOT_FOUND');
|
||||
});
|
||||
|
||||
it('should return error for respawn config without controller', async () => {
|
||||
it('should save respawn config as pre-config without controller', async () => {
|
||||
const caseName = `respawn-config-none-${Date.now()}`;
|
||||
createdCases.push(caseName);
|
||||
|
||||
@@ -956,8 +956,8 @@ describe('Ralph Integration Tests', () => {
|
||||
const data = await res.json();
|
||||
|
||||
expect(res.status).toBe(200);
|
||||
expect(data.success).toBe(false);
|
||||
expect(data.errorCode).toBe('NOT_FOUND');
|
||||
expect(data.success).toBe(true);
|
||||
expect(data.config.idleTimeoutMs).toBe(10000);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -627,7 +627,7 @@ describe('Session Event Handling', () => {
|
||||
const debouncer = createDebouncer(100);
|
||||
debouncer.add('event1');
|
||||
debouncer.add('event2');
|
||||
expect(debouncer.shouldFlush(0)).toBe(true);
|
||||
expect(debouncer.shouldFlush(100)).toBe(true);
|
||||
const events = debouncer.flush(100);
|
||||
expect(events).toEqual(['event1', 'event2']);
|
||||
});
|
||||
|
||||
@@ -170,7 +170,6 @@ describe('Interactive Session Lifecycle', () => {
|
||||
const data = await response.json();
|
||||
|
||||
expect(data.success).toBe(true);
|
||||
expect(data.message).toBe('Interactive session started');
|
||||
});
|
||||
|
||||
it('should return error for non-existent session', async () => {
|
||||
|
||||
@@ -196,11 +196,12 @@ describe('Timing Utilities', () => {
|
||||
const fn = vi.fn().mockRejectedValue(new Error('always fails'));
|
||||
|
||||
const promise = retryWithBackoff(fn, 2, 100);
|
||||
const expectation = expect(promise).rejects.toThrow('always fails');
|
||||
|
||||
await vi.advanceTimersByTimeAsync(100); // First retry
|
||||
await vi.advanceTimersByTimeAsync(200); // Second retry
|
||||
|
||||
await expect(promise).rejects.toThrow('always fails');
|
||||
await expectation;
|
||||
expect(fn).toHaveBeenCalledTimes(3); // Initial + 2 retries
|
||||
});
|
||||
});
|
||||
@@ -245,9 +246,9 @@ describe('Timing Utilities', () => {
|
||||
);
|
||||
|
||||
const wrapped = withTimeout(promise, 100);
|
||||
const expectation = expect(wrapped).rejects.toThrow('Operation timed out');
|
||||
await vi.advanceTimersByTimeAsync(100);
|
||||
|
||||
await expect(wrapped).rejects.toThrow('Operation timed out');
|
||||
await expectation;
|
||||
});
|
||||
|
||||
it('should use custom timeout message', async () => {
|
||||
@@ -256,9 +257,9 @@ describe('Timing Utilities', () => {
|
||||
);
|
||||
|
||||
const wrapped = withTimeout(promise, 100, 'Custom message');
|
||||
const expectation = expect(wrapped).rejects.toThrow('Custom message');
|
||||
await vi.advanceTimersByTimeAsync(100);
|
||||
|
||||
await expect(wrapped).rejects.toThrow('Custom message');
|
||||
await expectation;
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user