- 重构发货通知的状态与动作获取逻辑:移除从聊天文本解析HXOPS_SHIPPING_ACTIONS注释的旧逻辑,改为统一从后端shipping_ui_state获取任务状态、动作按钮与工作流步骤 - 新增SSE实时推送shipping_ui_state事件,支持前端即时更新聊天气泡与工作台的状态与按钮 - 优化路由与登录流程:调整根路径重定向逻辑,退出登录时跳转到登录页;移除chat路由不必要的props传参;将原路由守卫中的根路径判断迁移到路由配置中 - 完善库存RPA与本地导入流程:新增本地库存文件托管接口,优化RPA回调的文件落盘与任务关联逻辑 - 新增多组单元测试覆盖焦点切换、决策处理、SSE同步等核心场景 - 修复多语言显示逻辑,使用te方法判断翻译key是否存在,避免缺失翻译时的渲染异常 - 新增reparse_inventory菜单动作,支持静默重新解析库存且不追加额外聊天消息 - 重构工作流步骤渲染函数,优先使用后端返回的步骤数据, fallback到本地推导的旧逻辑 - 清理后端旧的chat-actions API接口,将相关逻辑迁移到统一的ui_state接口中
65 lines
1.9 KiB
TypeScript
65 lines
1.9 KiB
TypeScript
/**
|
|
* features/chat/composables/useChatShipping.spec.ts
|
|
* 用途:验证发货批次切换后的默认焦点解析,避免右侧工作台沿用旧批次的 focused task。
|
|
* 依赖:vitest、useChatShipping 纯函数导出。
|
|
* 逻辑:覆盖 current focus、process summary 回退、首票回退与无任务时清空焦点原因四种路径。
|
|
*/
|
|
import { describe, expect, it } from 'vitest';
|
|
import { resolveShippingBatchFocusState } from './useChatShipping';
|
|
|
|
describe('useChatShipping batch focus sync', () => {
|
|
it('prefers batch current focus task and keeps default reason', () => {
|
|
expect(resolveShippingBatchFocusState(
|
|
{
|
|
current_focus_task_no: 'SN-BATCH-B2',
|
|
process_summary: { current_task_no: 'SN-BATCH-B1' },
|
|
},
|
|
[{ task_no: 'SN-BATCH-B0' }],
|
|
'当前聚焦任务',
|
|
)).toEqual({
|
|
taskNo: 'SN-BATCH-B2',
|
|
focusReason: '当前聚焦任务',
|
|
});
|
|
});
|
|
|
|
it('falls back to process summary and first task when current focus is absent', () => {
|
|
expect(resolveShippingBatchFocusState(
|
|
{
|
|
current_focus_task_no: '',
|
|
process_summary: { current_task_no: 'SN-BATCH-C1' },
|
|
},
|
|
[{ task_no: 'SN-BATCH-C0' }],
|
|
'当前聚焦任务',
|
|
)).toEqual({
|
|
taskNo: 'SN-BATCH-C1',
|
|
focusReason: '当前聚焦任务',
|
|
});
|
|
|
|
expect(resolveShippingBatchFocusState(
|
|
{
|
|
current_focus_task_no: '',
|
|
process_summary: { current_task_no: '' },
|
|
},
|
|
[{ task_no: 'SN-BATCH-D0' }],
|
|
'当前聚焦任务',
|
|
)).toEqual({
|
|
taskNo: 'SN-BATCH-D0',
|
|
focusReason: '当前聚焦任务',
|
|
});
|
|
});
|
|
|
|
it('clears focus state when the new batch has no resolvable task', () => {
|
|
expect(resolveShippingBatchFocusState(
|
|
{
|
|
current_focus_task_no: '',
|
|
process_summary: { current_task_no: '' },
|
|
},
|
|
[],
|
|
'当前聚焦任务',
|
|
)).toEqual({
|
|
taskNo: '',
|
|
focusReason: '',
|
|
});
|
|
});
|
|
});
|