Files
repomix-mirror/tests/shared/progressCallback.test.ts
Kazuki YamadaandClaude Opus 5.5 2861510a64 fix(mcp): Address progress notification review feedback
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>
2026-10-25 15:31:09 +09:00

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));
});
});