feat(shipping-notice): 收敛复核状态隔离、STP 重试幂等与 XFA 合成预览标注
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
84a881b554
commit
74270adc22
149 files changed
+20111
-3871
No files matched your search
+137
@@ -0,0 +1,137 @@
|
||||
/**
|
||||
* features/workspace/shipping-task-center/TaskTodoPanel.actionsExecutable.spec.ts
|
||||
* 用途:验收 A2——Gate 只读时 Footer 委托 invokeActionByCode 仍可写。
|
||||
* 依赖:Vitest、Vue Test Utils、TaskTodoPanel、shipping.api mock。
|
||||
* 逻辑:gateCanHandle=false + actionsExecutable=true 时匹配库存 API 被调用;
|
||||
* actionsExecutable=false 时直接返回;hidePrimaryActions 时不渲染 action_buttons。
|
||||
*/
|
||||
import { flushPromises, mount } from '@vue/test-utils';
|
||||
import { createI18n } from 'vue-i18n';
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import TaskTodoPanel from './TaskTodoPanel.vue';
|
||||
import type { ShippingTaskDetail } from '@/features/chat/types/shipping.api.types';
|
||||
|
||||
const matchInventory = vi.fn().mockResolvedValue({});
|
||||
const refreshBadge = vi.fn().mockResolvedValue(undefined);
|
||||
|
||||
vi.mock('@/features/chat/api/shipping.api', () => ({
|
||||
confirmWorkspaceShippingCustomer: vi.fn(),
|
||||
confirmWorkspaceShippingInventorySource: vi.fn(),
|
||||
freezeWorkspaceShippingOrder: vi.fn(),
|
||||
generateWorkspaceShippingExcel: vi.fn(),
|
||||
listWorkspaceShippingCustomerOptions: vi.fn().mockResolvedValue([]),
|
||||
matchWorkspaceShippingInventory: (...args: unknown[]) => matchInventory(...args),
|
||||
retryWorkspaceShippingUpload: vi.fn(),
|
||||
submitWorkspaceShippingDecision: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock('@/features/workspace/api/shipping-tasks.api', () => ({
|
||||
downloadWorkspaceShippingExcelFile: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock('@/features/workspace/composables/useShippingTodoBadge', () => ({
|
||||
refreshShippingTodoBadge: (...args: unknown[]) => refreshBadge(...args),
|
||||
}));
|
||||
|
||||
vi.mock('@/features/shipping-process-gates/components/ProcessGateRecoveryCard.vue', () => ({
|
||||
default: {
|
||||
name: 'ProcessGateRecoveryCard',
|
||||
props: ['summary', 'canHandle'],
|
||||
template: '<div data-testid="gate-stub" :data-can-handle="canHandle" />',
|
||||
},
|
||||
}));
|
||||
|
||||
const i18n = createI18n({
|
||||
legacy: false,
|
||||
locale: 'zh-CN',
|
||||
messages: {
|
||||
'zh-CN': {
|
||||
errors: {
|
||||
codes: {
|
||||
SHIPPING_PROCESSING_TASK_OWNERSHIP_MISMATCH: '归属不匹配',
|
||||
},
|
||||
},
|
||||
workspace: {
|
||||
shippingNotice: {
|
||||
todo: {
|
||||
currentTodo: '待办',
|
||||
adminViewOnly: '只读',
|
||||
waitingManualUploadNote: '上传',
|
||||
},
|
||||
actions: {
|
||||
failed: '失败',
|
||||
freezeOrder: '冻结',
|
||||
freezeConfirm: '确认',
|
||||
},
|
||||
loading: '加载中',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
function detail(): ShippingTaskDetail {
|
||||
return {
|
||||
task_no: 'SN-1',
|
||||
ui_state: {
|
||||
summary: { title: 't', message: 'm' },
|
||||
action_buttons: [],
|
||||
checkpoint_kind: 'inventory',
|
||||
process_gate: null,
|
||||
},
|
||||
} as unknown as ShippingTaskDetail;
|
||||
}
|
||||
|
||||
describe('TaskTodoPanel actionsExecutable', () => {
|
||||
beforeEach(() => {
|
||||
matchInventory.mockClear();
|
||||
refreshBadge.mockClear();
|
||||
});
|
||||
|
||||
it('invokes match API when gateCanHandle=false but actionsExecutable=true', async () => {
|
||||
const wrapper = mount(TaskTodoPanel, {
|
||||
props: {
|
||||
detail: detail(),
|
||||
gateCanHandle: false,
|
||||
actionsExecutable: true,
|
||||
hidePrimaryActions: true,
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
expect(wrapper.get('[data-testid="gate-stub"]').attributes('data-can-handle')).toBe('false');
|
||||
await (wrapper.vm as { invokeActionByCode: (id: string) => Promise<void> }).invokeActionByCode('match_inventory');
|
||||
await flushPromises();
|
||||
expect(matchInventory).toHaveBeenCalledWith('SN-1', undefined);
|
||||
});
|
||||
|
||||
it('blocks fulfillment invoke when expectedNoticeTaskNo mismatches', async () => {
|
||||
const wrapper = mount(TaskTodoPanel, {
|
||||
props: {
|
||||
detail: detail(),
|
||||
gateCanHandle: false,
|
||||
actionsExecutable: true,
|
||||
hidePrimaryActions: true,
|
||||
expectedNoticeTaskNo: 'SN-OTHER',
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await (wrapper.vm as { invokeActionByCode: (id: string) => Promise<void> }).invokeActionByCode('match_inventory');
|
||||
await flushPromises();
|
||||
expect(matchInventory).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('no-ops invokeActionByCode when actionsExecutable=false', async () => {
|
||||
const wrapper = mount(TaskTodoPanel, {
|
||||
props: {
|
||||
detail: detail(),
|
||||
gateCanHandle: false,
|
||||
actionsExecutable: false,
|
||||
hidePrimaryActions: true,
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await (wrapper.vm as { invokeActionByCode: (id: string) => Promise<void> }).invokeActionByCode('match_inventory');
|
||||
await flushPromises();
|
||||
expect(matchInventory).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user