mirror of
https://github.com/yamadashy/repomix.git
synced 2026-11-20 06:29:20 +01:00
Tighten the progress throttle and remove the duplicated safe-callback wrapper. decision(mcp-progress): messages without a stage head share one fixed stage key so they are throttled together (CodeRabbit) decision(mcp-progress): always send a stage's final "(n/n)" message so client counters do not stall short of the total decision(shared): move the throw/reject-swallowing progress wrapper into src/shared/progressCallback.ts, used by both the default and remote actions Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
29 lines
1.1 KiB
TypeScript
29 lines
1.1 KiB
TypeScript
import { describe, expect, test, vi } from 'vitest';
|
|
import { createSafeProgressCallback } from '../../src/shared/progressCallback.js';
|
|
|
|
describe('createSafeProgressCallback', () => {
|
|
test('forwards messages to the callback', () => {
|
|
const callback = vi.fn();
|
|
createSafeProgressCallback(callback)('Packing...');
|
|
expect(callback).toHaveBeenCalledWith('Packing...');
|
|
});
|
|
|
|
test('is a no-op without a callback', () => {
|
|
expect(() => createSafeProgressCallback()('Packing...')).not.toThrow();
|
|
});
|
|
|
|
test('swallows a synchronously throwing callback', () => {
|
|
const report = createSafeProgressCallback(() => {
|
|
throw new Error('boom');
|
|
});
|
|
expect(() => report('Packing...')).not.toThrow();
|
|
});
|
|
|
|
test('swallows a rejecting callback', async () => {
|
|
const report = createSafeProgressCallback(() => Promise.reject(new Error('boom')));
|
|
expect(() => report('Packing...')).not.toThrow();
|
|
// Let the rejection settle; an unhandled rejection would fail the test run.
|
|
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
});
|
|
});
|