feat(agent): 增强 Agent 配置,新增结构化字段与聊天功能支持
This commit is contained in:
1 parent
ac4262cd75
commit
c8ce77199e
183 files changed
+11690
-2300
No files matched your search
@@ -2,24 +2,18 @@
|
||||
* features/chat/shipping/useChatShippingMenuHandler.spec.ts
|
||||
* 用途:验证发货聊天动作菜单在工作台显式 taskId 场景下会命中指定任务,而不是误用当前激活任务。
|
||||
* 依赖:vitest、vue refs、shipping.api、useChatShippingMenuHandler。
|
||||
* 逻辑:覆盖工作台点击 `retry_rpa` 与 `generate_excel` 两类动作,锁死统一按钮分发时的任务归属。
|
||||
* 逻辑:覆盖 retry_rpa、generate_excel 等动作,锁死 Chat Turn 分发时的任务归属。
|
||||
*/
|
||||
import { ref } from 'vue';
|
||||
import { computed, ref } from 'vue';
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { createShippingMenuHandlers, type ShippingMenuHandlerContext } from './useChatShippingMenuHandler';
|
||||
|
||||
const {
|
||||
confirmWorkspaceShippingInventorySource,
|
||||
generateWorkspaceShippingExcel,
|
||||
getWorkspaceShippingTask,
|
||||
matchWorkspaceShippingInventory,
|
||||
retryWorkspaceShippingUpload,
|
||||
} = vi.hoisted(() => ({
|
||||
confirmWorkspaceShippingInventorySource: vi.fn(),
|
||||
generateWorkspaceShippingExcel: vi.fn(),
|
||||
getWorkspaceShippingTask: vi.fn(),
|
||||
matchWorkspaceShippingInventory: vi.fn(),
|
||||
retryWorkspaceShippingUpload: vi.fn(),
|
||||
}));
|
||||
|
||||
const { downloadWorkspaceShippingExcelFile } = vi.hoisted(() => ({
|
||||
@@ -28,10 +22,7 @@ const { downloadWorkspaceShippingExcelFile } = vi.hoisted(() => ({
|
||||
|
||||
vi.mock('@/features/chat/api/shipping.api', () => ({
|
||||
confirmWorkspaceShippingInventorySource,
|
||||
generateWorkspaceShippingExcel,
|
||||
getWorkspaceShippingTask,
|
||||
matchWorkspaceShippingInventory,
|
||||
retryWorkspaceShippingUpload,
|
||||
}));
|
||||
|
||||
vi.mock('./shippingDownload', () => ({
|
||||
@@ -42,10 +33,10 @@ const createContext = (
|
||||
overrides: Partial<ShippingMenuHandlerContext> = {},
|
||||
): ShippingMenuHandlerContext => ({
|
||||
isThinking: ref(false),
|
||||
currentAgentId: computed(() => 42),
|
||||
getActiveShippingTaskId: () => 'SN-ACTIVE-001',
|
||||
getActiveShippingBatchNo: () => 'BATCH-001',
|
||||
messages: ref([]),
|
||||
newLocalMessageId: vi.fn((prefix: string) => `${prefix}-local-id`),
|
||||
saveLocalMessageToBackend: vi.fn(async () => undefined),
|
||||
sendShippingMenuMessage: vi.fn(async () => undefined),
|
||||
openShippingInventoryMappingFormForTask: vi.fn(async () => true),
|
||||
openShippingInventoryPicker: vi.fn((_taskId?: string) => true),
|
||||
@@ -53,6 +44,7 @@ const createContext = (
|
||||
executeShippingDecision: vi.fn(async () => true),
|
||||
executeShippingManualUpload: vi.fn(async () => true),
|
||||
refreshShippingActions: vi.fn(async () => undefined),
|
||||
startChatTurn: vi.fn(async () => true),
|
||||
msg: {
|
||||
warning: vi.fn(),
|
||||
info: vi.fn(),
|
||||
@@ -64,10 +56,7 @@ const createContext = (
|
||||
describe('useChatShippingMenuHandler', () => {
|
||||
beforeEach(() => {
|
||||
confirmWorkspaceShippingInventorySource.mockReset();
|
||||
generateWorkspaceShippingExcel.mockReset();
|
||||
getWorkspaceShippingTask.mockReset();
|
||||
matchWorkspaceShippingInventory.mockReset();
|
||||
retryWorkspaceShippingUpload.mockReset();
|
||||
downloadWorkspaceShippingExcelFile.mockReset();
|
||||
});
|
||||
|
||||
@@ -76,28 +65,24 @@ describe('useChatShippingMenuHandler', () => {
|
||||
const { handleShippingMenuAction } = createShippingMenuHandlers(ctx);
|
||||
|
||||
await handleShippingMenuAction(
|
||||
{ id: 'retry_rpa', label: '重试 RPA', message: '重试 RPA' },
|
||||
{ id: 'retry_rpa', label: '重新获取库存', message: '重新获取库存' },
|
||||
undefined,
|
||||
{ taskId: 'sn-target-009' },
|
||||
);
|
||||
|
||||
expect(ctx.executeShippingDecision).toHaveBeenCalledWith(
|
||||
'retry_rpa',
|
||||
'重试 RPA',
|
||||
'重新获取库存',
|
||||
{ taskId: 'SN-TARGET-009' },
|
||||
);
|
||||
expect(ctx.executeShippingDecision).not.toHaveBeenCalledWith(
|
||||
'retry_rpa',
|
||||
'重试 RPA',
|
||||
'重新获取库存',
|
||||
{ taskId: 'SN-ACTIVE-001' },
|
||||
);
|
||||
});
|
||||
|
||||
it('uses explicit taskId for generate_excel workspace actions', async () => {
|
||||
generateWorkspaceShippingExcel.mockResolvedValue({
|
||||
message: '发货文件已生成',
|
||||
data: {},
|
||||
});
|
||||
it('uses explicit taskId for generate_excel via Chat Turn', async () => {
|
||||
const ctx = createContext();
|
||||
const { handleShippingMenuAction } = createShippingMenuHandlers(ctx);
|
||||
|
||||
@@ -107,9 +92,14 @@ describe('useChatShippingMenuHandler', () => {
|
||||
{ taskId: 'sn-target-777' },
|
||||
);
|
||||
|
||||
expect(generateWorkspaceShippingExcel).toHaveBeenCalledWith('SN-TARGET-777');
|
||||
expect(ctx.messages.value[0]?.content).toContain('SN-TARGET-777');
|
||||
expect(ctx.messages.value[1]?.content).toContain('SN-TARGET-777');
|
||||
expect(ctx.startChatTurn).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
inputType: 'action',
|
||||
actionType: 'shipping.generate_excel',
|
||||
payload: { task_no: 'SN-TARGET-777' },
|
||||
refs: expect.objectContaining({ task_no: 'SN-TARGET-777' }),
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('passes explicit taskId into inventory picker actions', async () => {
|
||||
|
||||
Reference in new issue
Block a user