Files
lingxi-ai/tests/server/run-chat-bridge-terminal-error.test.ts
yi 7d10320a82
Build / build (push) Has been cancelled
NPM Lockfile Check / npm ci --ignore-scripts (push) Has been cancelled
Playwright / e2e (push) Has been cancelled
feat: 灵犀 Studio Web UI 定制版
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-05 11:29:11 +08:00

72 lines
2.3 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { describe, expect, it } from 'vitest'
import { bridgeTerminalError } from '../../packages/server/src/services/hermes/run-chat/handle-bridge-run'
describe('bridge terminal error detection', () => {
it('uses bridge status errors directly', () => {
expect(bridgeTerminalError({
status: 'error',
error: 'bridge crashed',
result: null,
} as any)).toBe('bridge crashed')
})
it('surfaces agent result failure flags as run failures', () => {
expect(bridgeTerminalError({
status: 'complete',
error: undefined,
result: {
failed: true,
completed: false,
error: 'API call failed after 3 retries. HTTP 503: no available channel',
final_response: 'API call failed after 3 retries. HTTP 503: no available channel',
},
} as any)).toBe('API call failed after 3 retries. HTTP 503: no available channel')
})
it('falls back to final_response for failed results without an error field', () => {
expect(bridgeTerminalError({
status: 'complete',
result: {
completed: false,
final_response: 'API call failed after 3 retries: timeout',
},
} as any)).toBe('API call failed after 3 retries: timeout')
})
it('surfaces HTTP auth/provider errors even when failure flags are missing', () => {
expect(bridgeTerminalError({
status: 'complete',
result: {
final_response: 'API call failed after 3 retries. HTTP 403: forbidden',
},
} as any)).toBe('API call failed after 3 retries. HTTP 403: forbidden')
expect(bridgeTerminalError({
status: 'complete',
result: {
error: 'HTTP 401: unauthorized',
},
} as any)).toBe('HTTP 401: unauthorized')
})
it('surfaces generic provider result errors even without failed flags', () => {
expect(bridgeTerminalError({
status: 'complete',
result: {
error: '分组 subrouter 下模型 test 无可用渠道(distributor',
},
} as any)).toBe('分组 subrouter 下模型 test 无可用渠道(distributor')
})
it('does not flag successful complete results', () => {
expect(bridgeTerminalError({
status: 'complete',
result: {
completed: true,
final_response: 'done',
},
} as any)).toBeNull()
})
})