feat(shipping-notice,receipt-report): 新增收料报表功能并优化发货通知流程
清理废弃的shipping xfa ocr automark相关代码和job配置 新增收料报表管理的前端页面、路由和侧边栏入口 新增后端收料报表配置接口、数据库模型和RPA脚本 优化发货通知流程的重试策略,将shipping相关job默认不自动重试 移除废弃的库存源确认相关逻辑,更新流程门禁规则 重构订单模板的值适配器模块,新增坐标OCR值适配器 清理前端shipping菜单和action的废弃选项 更新相关文档和测试用例,调整.gitignore忽略规则
This commit is contained in:
1 parent
260465b72d
commit
1b6483a4ea
466 files changed
+32115
-33796
No files matched your search
@@ -1,102 +1,57 @@
|
||||
/**
|
||||
* features/chat/shipping/useChatShippingDecision.spec.ts
|
||||
* 用途:验证发货通知决策处理器经 Chat Turn 发起,silent 模式不追加用户气泡。
|
||||
* 用途:验证发货 Chat 不再承载履约写,操作只刷新权威 OT 投影。
|
||||
* 依赖:vitest、vue refs、useChatShippingDecision。
|
||||
* 逻辑:mock startChatTurn,覆盖 silent/普通决策与显式 taskId 分支。
|
||||
*/
|
||||
import { computed, ref } from 'vue';
|
||||
import { describe, expect, it, vi, beforeEach } from 'vitest';
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { createShippingDecisionHandlers, type ShippingDecisionContext } from './useChatShippingDecision';
|
||||
import type { ChatMessage } from '../types/chat.types';
|
||||
|
||||
const defaultStartChatTurn = vi.fn(async (options: {
|
||||
hooks?: { onAssistantMessageFinished?: (msg: ChatMessage) => Promise<void> };
|
||||
}) => {
|
||||
await options?.hooks?.onAssistantMessageFinished?.(
|
||||
{ role: 'assistant', content: 'mock assistant' },
|
||||
);
|
||||
return true;
|
||||
});
|
||||
|
||||
const createContext = (
|
||||
overrides: Partial<ShippingDecisionContext> = {},
|
||||
): ShippingDecisionContext => ({
|
||||
messages: ref([]),
|
||||
conversationId: ref('conv-001'),
|
||||
history: ref([{ conversation_id: 'conv-001' }]),
|
||||
isShippingNoticeAgent: computed(() => true),
|
||||
currentAgentId: computed(() => 42),
|
||||
getActiveShippingTaskId: () => 'SN-FOCUS-001',
|
||||
getActiveShippingBatchNo: () => 'BATCH-001',
|
||||
loadHistory: vi.fn(async () => undefined),
|
||||
refreshShippingActions: vi.fn(async () => undefined),
|
||||
startChatTurn: defaultStartChatTurn,
|
||||
msg: {
|
||||
warning: vi.fn(),
|
||||
success: vi.fn(),
|
||||
},
|
||||
t: (key: string) => key,
|
||||
...overrides,
|
||||
});
|
||||
|
||||
describe('useChatShippingDecision', () => {
|
||||
beforeEach(() => {
|
||||
defaultStartChatTurn.mockClear();
|
||||
});
|
||||
|
||||
it('does not append local chat messages when decision runs in silent mode', async () => {
|
||||
it('does not dispatch a Chat Turn for a legacy decision', async () => {
|
||||
const ctx = createContext();
|
||||
const { executeShippingDecision } = createShippingDecisionHandlers(ctx);
|
||||
|
||||
const ok = await executeShippingDecision('reparse_inventory', '重新上传库存', { silent: true });
|
||||
|
||||
expect(ok).toBe(true);
|
||||
expect(ctx.startChatTurn).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
inputType: 'action',
|
||||
actionType: 'shipping.submit_decision',
|
||||
payload: { task_no: 'SN-FOCUS-001', decision: 'reparse_inventory' },
|
||||
silent: true,
|
||||
}),
|
||||
);
|
||||
expect(ctx.messages.value).toEqual([]);
|
||||
expect(ok).toBe(false);
|
||||
expect(ctx.refreshShippingActions).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('delegates normal decisions to startChatTurn with display text', async () => {
|
||||
it('does not dispatch a Chat Turn for a normal legacy decision', async () => {
|
||||
const ctx = createContext();
|
||||
const { executeShippingDecision } = createShippingDecisionHandlers(ctx);
|
||||
|
||||
const ok = await executeShippingDecision('confirm', '确认');
|
||||
|
||||
expect(ok).toBe(true);
|
||||
expect(ctx.startChatTurn).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
actionType: 'shipping.submit_decision',
|
||||
displayText: expect.stringContaining('SN-FOCUS-001'),
|
||||
payload: { task_no: 'SN-FOCUS-001', decision: 'confirm' },
|
||||
}),
|
||||
);
|
||||
expect(ok).toBe(false);
|
||||
expect(ctx.refreshShippingActions).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('does not show success toast for retry_rpa inside shipping agent workspace', async () => {
|
||||
it('refreshes authoritative actions when Chat decision is rejected', async () => {
|
||||
const ctx = createContext();
|
||||
const { executeShippingDecision } = createShippingDecisionHandlers(ctx);
|
||||
|
||||
const ok = await executeShippingDecision('retry_rpa', '重新获取库存');
|
||||
|
||||
expect(ok).toBe(true);
|
||||
expect(ctx.startChatTurn).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
payload: { task_no: 'SN-FOCUS-001', decision: 'retry_rpa' },
|
||||
}),
|
||||
);
|
||||
expect(ctx.msg.success).not.toHaveBeenCalled();
|
||||
expect(ok).toBe(false);
|
||||
expect(ctx.refreshShippingActions).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('prefers explicit taskId for workspace retry decisions', async () => {
|
||||
it('does not dispatch even when a legacy decision supplies an explicit taskId', async () => {
|
||||
const ctx = createContext({
|
||||
getActiveShippingTaskId: () => '',
|
||||
});
|
||||
@@ -104,22 +59,14 @@ describe('useChatShippingDecision', () => {
|
||||
|
||||
const ok = await executeShippingDecision('retry_rpa', '重新获取库存', { taskId: 'sn-target-009' });
|
||||
|
||||
expect(ok).toBe(true);
|
||||
expect(ctx.startChatTurn).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
payload: { task_no: 'SN-TARGET-009', decision: 'retry_rpa' },
|
||||
}),
|
||||
);
|
||||
expect(ctx.msg.warning).not.toHaveBeenCalled();
|
||||
expect(ok).toBe(false);
|
||||
});
|
||||
|
||||
it('returns false when startChatTurn reports failure', async () => {
|
||||
const ctx = createContext({
|
||||
startChatTurn: vi.fn(async () => false),
|
||||
});
|
||||
const { executeShippingDecision } = createShippingDecisionHandlers(ctx);
|
||||
it('does not dispatch manual upload through Chat', async () => {
|
||||
const ctx = createContext();
|
||||
const { executeShippingManualUpload } = createShippingDecisionHandlers(ctx);
|
||||
|
||||
const ok = await executeShippingDecision('confirm', '确认');
|
||||
const ok = await executeShippingManualUpload('SN-FOCUS-001');
|
||||
|
||||
expect(ok).toBe(false);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user