Files
Agent-System/web/src/api/chatRetry.test.ts
T

23 lines
966 B
TypeScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { shouldAutoRetry, autoRetryDelayMs, fallbackErrorClass } from './chatRetry';
test('shouldAutoRetry: transient only, max 2', () => {
assert.equal(shouldAutoRetry({ class: 'transient' }, 0), true);
assert.equal(shouldAutoRetry({ class: 'transient' }, 1), true);
assert.equal(shouldAutoRetry({ class: 'transient' }, 2), false);
assert.equal(shouldAutoRetry({ class: 'fatal' }, 0), false);
assert.equal(shouldAutoRetry({ class: 'resumable' }, 0), false);
});
test('autoRetryDelayMs: 1s then 2s', () => {
assert.equal(autoRetryDelayMs(0), 1000);
assert.equal(autoRetryDelayMs(1), 2000);
});
test('fallbackErrorClass: network → transient, workspace → resumable', () => {
assert.equal(fallbackErrorClass({ network: true }), 'transient');
assert.equal(fallbackErrorClass({ workspaceId: 'research_1' }), 'resumable');
assert.equal(fallbackErrorClass({}), 'fatal');
});