/** * features/chat/shipping/shippingActionBusy.spec.ts * 用途:验证发货工作台动作忙碌态只在真实活跃 run 存在时才阻塞。 * 依赖:vitest、shippingActionBusy 纯函数。 * 逻辑:覆盖正常运行中、残留 isThinking、缺失 activeRunId 回退扫描三类路径,避免 retry_rpa 被误锁死。 */ import { describe, expect, it } from 'vitest'; import { hasActiveRunningChatRun } from './shippingActionBusy'; describe('shippingActionBusy', () => { it('returns true when active run is still running', () => { expect(hasActiveRunningChatRun(true, 12, [ { runId: 12, agentId: 1, viewId: 1, query: '继续处理', messages: [], conversationId: 'conv-1', status: 'running', createdAt: '2026-07-02T00:00:00.000Z', }, ])).toBe(true); }); it('returns false when isThinking is stale and no run is running', () => { expect(hasActiveRunningChatRun(true, 12, [ { runId: 12, agentId: 1, viewId: 1, query: '继续处理', messages: [], conversationId: 'conv-1', status: 'done', createdAt: '2026-07-02T00:00:00.000Z', }, ])).toBe(false); }); it('falls back to scanning all runs when activeRunId is missing', () => { expect(hasActiveRunningChatRun(true, null, [ { runId: 21, agentId: 1, viewId: 2, query: '查询库存', messages: [], conversationId: 'conv-2', status: 'running', createdAt: '2026-07-02T00:00:00.000Z', }, ])).toBe(true); }); });