feat(shipping-notice): 落地字段资产治理与唯一 Schema,自动建单随版本冻结

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
hugoandCursor committed 2026-07-29 16:23:15 +08:00
1 parent b7307fc573
commit 3a1dbf7ce5
144 files changed
+15167 -4480

No files matched your search

@@ -1,8 +1,8 @@
/**
* useChatShippingRefresh.spec.ts
* 用途:验证发货动作按钮刷新时的任务定位优先级与 focus 切换刷新保护。
* 用途:验证发货 UI State 刷新只同步通知态,不再把 action_buttons 映射为消息按钮。
* 依赖:vitest、vue refs、useChatShippingRefresh 纯函数导出。
* 逻辑:覆盖任务编号解析优先级,以及批次 focus 变化后应先锁定新 task 再拉取按钮。
* 逻辑:覆盖任务编号解析优先级,以及刷新后 shipping_actions 始终清空。
*/
import { computed, ref } from 'vue';
import { beforeEach, describe, expect, it, vi } from 'vitest';
@@ -39,7 +39,7 @@ describe('useChatShippingRefresh', () => {
})).toBe('');
});
it('locks onto the latest focus task before refreshing chat buttons', async () => {
it('syncs ui_state for notifications without attaching chat action buttons', async () => {
getWorkspaceShippingTaskUiState.mockResolvedValue({
task_no: 'SN-FOCUS-B',
batch_no: 'SB-FOCUS-001',
@@ -54,6 +54,7 @@ describe('useChatShippingRefresh', () => {
title: '可生成发货文件',
message: '库存匹配已满足发货条件,可以生成发货文件。',
error_message: null,
entry_surface: 'task_workbench',
},
action_buttons: [
{
@@ -94,13 +95,12 @@ describe('useChatShippingRefresh', () => {
await refreshShippingActions();
expect(resolvedShippingTaskId.value).toBe('SN-FOCUS-B');
expect(getWorkspaceShippingTaskUiState).toHaveBeenCalledTimes(1);
expect(getWorkspaceShippingTaskUiState).toHaveBeenCalledWith('SN-FOCUS-B');
expect(messages.value[0].shipping_ui_state?.task_no).toBe('SN-FOCUS-B');
expect(messages.value[0].shipping_actions?.map((item) => item.id)).toEqual(['generate_excel']);
expect(messages.value[0].shipping_actions).toBeUndefined();
});
it('treats backend ui_state.action_buttons as the only button source when api refresh succeeds', async () => {
it('clears legacy shipping_actions even when api returns action_buttons', async () => {
getWorkspaceShippingTaskUiState.mockResolvedValue({
task_no: 'SN-SOURCE-001',
batch_no: 'SB-SOURCE-001',
@@ -163,8 +163,8 @@ describe('useChatShippingRefresh', () => {
await refreshShippingActions();
expect(messages.value[0].shipping_actions?.map((item) => item.id)).toEqual(['download_excel']);
expect(messages.value[0].shipping_ui_state?.action_buttons?.map((item) => item.id)).toEqual(['download_excel']);
expect(messages.value[0].shipping_actions).toBeUndefined();
expect(messages.value[0].shipping_ui_state?.summary?.title).toBe('可生成发货文件');
});
it('does not guess a task id from history metadata when no explicit anchor exists', async () => {